forked from townforge/townforge
cc: fix roadworks discoveries not giving expected bonuses
This commit is contained in:
parent
d7996c99cf
commit
1def4cd6da
@ -125,25 +125,18 @@ public:
|
||||
inline void dec_influence_bonus(uint32_t delta) { if (influence_bonus < delta) influence_bonus = 0; else influence_bonus -= delta; }
|
||||
inline void set_influence_bonus(uint32_t bonus) { influence_bonus = bonus; }
|
||||
inline uint64_t calculate_shares(const cryptonote::BlockchainDB &db, cc_command_game_update_t &cg, cc::game_events_t &events) const {
|
||||
uint64_t shares;
|
||||
if (role == ROLE_ROAD)
|
||||
return road_shares + (road_shares ? road_propagated_shares : road_propagated_shares / 2);
|
||||
uint64_t shares = cc::get_shares(x0, y0, x1, y1, role, economic_power, repair, age, influence_bonus, elevation_bonus) * road_bonus / 100;
|
||||
switch (role)
|
||||
{
|
||||
#define ADD_PERCENT(discovery, owner, id, shares, x) \
|
||||
do \
|
||||
{ \
|
||||
if (cc::is_discovery_enabled(db, discovery, owner)) \
|
||||
{ \
|
||||
events.add(cg, owner, id) << "gets +" << std::to_string(x) << "% from " << cc::get_discovery_name(discovery); \
|
||||
(shares) = (shares) + ((shares) * (x)) / 100; \
|
||||
} \
|
||||
} while (0)
|
||||
case ROLE_ROAD:
|
||||
ADD_PERCENT(DISCOVERY_IMPROVED_ROADWORKS, owner, id, shares, 4);
|
||||
ADD_PERCENT(DISCOVERY_ADVANCED_ROADWORKS, owner, id, shares, 8);
|
||||
break;
|
||||
#undef ADD_PERCENT
|
||||
shares = road_shares + (road_shares ? road_propagated_shares : road_propagated_shares / 2);
|
||||
if (cc::is_discovery_enabled(db, DISCOVERY_ADVANCED_ROADWORKS, owner))
|
||||
shares += shares * 8 / 100;
|
||||
else if (cc::is_discovery_enabled(db, DISCOVERY_ADVANCED_ROADWORKS, owner))
|
||||
shares += shares * 4 / 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
shares = cc::get_shares(x0, y0, x1, y1, role, economic_power, repair, age, influence_bonus, elevation_bonus) * road_bonus / 100;
|
||||
}
|
||||
return shares;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user