diff options
author | peter1138 <peter1138@openttd.org> | 2007-05-07 13:26:10 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-05-07 13:26:10 +0000 |
commit | 4591fb5b0d7f9ade45093a86d6a7150c80414dc5 (patch) | |
tree | 5f24fcf49bbf30b6652cc9804840346fce6e2eec | |
parent | 0de85b7eb0375f3b857c10fc172f3894a906d758 (diff) | |
download | openttd-4591fb5b0d7f9ade45093a86d6a7150c80414dc5.tar.xz |
(svn r9806) -Codechange: [NewGRF] Add callback 36 support for purchase cost, for all vehicle types.
-rw-r--r-- | src/aircraft_cmd.cpp | 6 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 10 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 2 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 2 | ||||
-rw-r--r-- | src/train_cmd.cpp | 8 |
5 files changed, 14 insertions, 14 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index fa4ec2c3c..3dfca75bb 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -227,9 +227,9 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height) height = spr->height; } -static int32 EstimateAircraftCost(const AircraftVehicleInfo *avi) +static int32 EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi) { - return avi->base_cost * (_price.aircraft_base >> 3) >> 5; + return GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5; } @@ -270,7 +270,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_player)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE); const AircraftVehicleInfo *avi = AircraftVehInfo(p1); - int32 value = EstimateAircraftCost(avi); + int32 value = EstimateAircraftCost(p1, avi); /* to just query the cost, it is not neccessary to have a valid tile (automation/AI) */ if (flags & DC_QUERY_COST) return value; diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index b19b32f31..828b1ef89 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -379,7 +379,7 @@ static const StringID _sort_listing[][10] = {{ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi) { /* Purchase cost */ - SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8); + SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); DrawString(x, y, STR_PURCHASE_INFO_COST, 0); y += 10; @@ -404,7 +404,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); /* Purchase Cost - Engine weight */ - SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5); + SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); SetDParam(1, rvi->weight << multihead); DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, 0); y += 10; @@ -444,7 +444,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R bool refittable = (_engine_info[engine_number].refit_mask != 0); /* Purchase cost - Max speed */ - SetDParam(0, rvi->base_cost * (_price.roadveh_base >> 3) >> 5); + SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5); SetDParam(1, rvi->max_speed * 10 / 32); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -468,7 +468,7 @@ static int DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number, const R static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi) { /* Purchase cost - Max speed */ - SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); + SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5); SetDParam(1, svi->max_speed * 10 / 32); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -494,7 +494,7 @@ static int DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number, const CargoID cargo; /* Purchase cost - Max speed */ - SetDParam(0, avi->base_cost * (_price.aircraft_base >> 3) >> 5); + SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5); SetDParam(1, avi->max_speed * 10 / 16); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 43664a6ff..390a14d30 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -117,7 +117,7 @@ void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal) static int32 EstimateRoadVehCost(EngineID engine_type) { - return ((_price.roadveh_base >> 3) * RoadVehInfo(engine_type)->base_cost) >> 5; + return ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5; } /** Build a road vehicle. diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 77244bfb6..c3ddb5226 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -421,7 +421,7 @@ static bool ShipAccelerate(Vehicle *v) static int32 EstimateShipCost(EngineID engine_type) { - return ShipVehInfo(engine_type)->base_cost * (_price.ship_base>>3)>>5; + return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base>>3)>>5; } static void ShipArrivesAt(const Vehicle* v, Station* st) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4b49136a2..71cdccdd6 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -566,7 +566,7 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); const RailVehicleInfo *rvi = RailVehInfo(engine); - int32 value = (rvi->base_cost * _price.build_railwagon) >> 8; + int32 value = (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8; uint num_vehicles = 1 + CountArticulatedParts(engine); @@ -666,9 +666,9 @@ static void NormalizeTrainVehInDepot(const Vehicle* u) } } -static int32 EstimateTrainCost(const RailVehicleInfo* rvi) +static int32 EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi) { - return rvi->base_cost * (_price.build_railvehicle >> 3) >> 5; + return GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5; } static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool building) @@ -728,7 +728,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags); - int32 value = EstimateTrainCost(rvi); + int32 value = EstimateTrainCost(p1, rvi); uint num_vehicles = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) + |