(svn r6376) -Codechange: [vehicle refit] moved all refit cost calculations into GetRefitCost()

Now it's possible to tell refit costs for an EngineID without actually having build a vehicle
This commit is contained in:
bjarni
2006-09-04 09:07:52 +00:00
parent df135e8190
commit 1a0476535d
6 changed files with 25 additions and 6 deletions

View File

@@ -723,6 +723,26 @@ CargoID FindFirstRefittableCargo(EngineID engine_type)
return CT_INVALID;
}
/** Learn the price of refitting a certain engine
* @param engine Which engine to refit
* @return Price for refitting
*/
int32 GetRefitCost(EngineID engine_type)
{
int32 base_cost;
switch (GetEngine(engine_type)->type) {
case VEH_Ship: base_cost = _price.ship_base; break;
case VEH_Road: base_cost = _price.roadveh_base; break;
case VEH_Aircraft: base_cost = _price.aircraft_base; break;
case VEH_Train:
base_cost = 2 * ((RailVehInfo(engine_type)->flags & RVI_WAGON) ?
_price.build_railwagon : _price.build_railvehicle);
break;
default: NOT_REACHED(); break;
}
return (EngInfo(engine_type)->refit_cost * base_cost) >> 10;
}
static void DoDrawVehicle(const Vehicle *v)
{