1
0
Fork 0

(svn r11331) -Fix: do not misuse CommandCost for overflow safe stuff as Money supports that now too.

release/0.6
rubidium 2007-10-21 16:44:19 +00:00
parent f4775d06bb
commit af9521ff14
1 changed files with 17 additions and 22 deletions

View File

@ -63,9 +63,8 @@ Money CalculateCompanyValue(const Player* p)
{ {
PlayerID owner = p->index; PlayerID owner = p->index;
/* Do a little nasty by using CommandCost, so we can use the "overflow" protection of CommandCost */ /* Do a little nasty by using CommandCost, so we can use the "overflow" protection of CommandCost */
CommandCost value; Money value = 0;
{
Station *st; Station *st;
uint num = 0; uint num = 0;
@ -73,12 +72,9 @@ Money CalculateCompanyValue(const Player* p)
if (st->owner == owner) num += COUNTBITS(st->facilities); if (st->owner == owner) num += COUNTBITS(st->facilities);
} }
value.AddCost(num * _price.station_value * 25); value += num * _price.station_value * 25;
}
{
Vehicle *v; Vehicle *v;
FOR_ALL_VEHICLES(v) { FOR_ALL_VEHICLES(v) {
if (v->owner != owner) continue; if (v->owner != owner) continue;
@ -86,16 +82,15 @@ Money CalculateCompanyValue(const Player* p)
v->type == VEH_ROAD || v->type == VEH_ROAD ||
(v->type == VEH_AIRCRAFT && IsNormalAircraft(v)) || (v->type == VEH_AIRCRAFT && IsNormalAircraft(v)) ||
v->type == VEH_SHIP) { v->type == VEH_SHIP) {
value.AddCost(v->value * 3 >> 1); value += v->value * 3 >> 1;
}
} }
} }
/* Add real money value */ /* Add real money value */
value.AddCost(-p->current_loan); value -= p->current_loan;
value.AddCost(p->player_money); value += p->player_money;
return max(value.GetCost(), (Money)1); return max(value, (Money)1);
} }
/** if update is set to true, the economy is updated with this score /** if update is set to true, the economy is updated with this score