(svn r18266) -Codechange: Add a function to compute prices from price base and cost factor and use it consistently for vehicle purchase, running cost, and refit cost.

This commit is contained in:
frosch
2009-11-24 13:12:34 +00:00
parent b6b5515335
commit 912bce0b8c
8 changed files with 76 additions and 37 deletions

View File

@@ -1827,13 +1827,13 @@ static bool RoadVehController(RoadVehicle *v)
Money RoadVehicle::GetRunningCost() const
{
const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
if (rvi->running_cost_class == INVALID_PRICE) return 0;
const Engine *e = Engine::Get(this->engine_type);
if (e->u.road.running_cost_class == INVALID_PRICE) return 0;
uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, rvi->running_cost);
uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, e->u.road.running_cost);
if (cost_factor == 0) return 0;
return cost_factor * GetPriceByIndex(rvi->running_cost_class);
return GetPrice(e->u.road.running_cost_class, cost_factor);
}
bool RoadVehicle::Tick()