diff options
-rw-r--r-- | src/ai/api/ai_airport.cpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_bridge.cpp | 2 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 2 | ||||
-rw-r--r-- | src/bridge_gui.cpp | 2 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 4 | ||||
-rw-r--r-- | src/clear_cmd.cpp | 16 | ||||
-rw-r--r-- | src/economy.cpp | 17 | ||||
-rw-r--r-- | src/economy_func.h | 2 | ||||
-rw-r--r-- | src/economy_type.h | 107 | ||||
-rw-r--r-- | src/engine.cpp | 14 | ||||
-rw-r--r-- | src/engine_type.h | 5 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 8 | ||||
-rw-r--r-- | src/newgrf.cpp | 8 | ||||
-rw-r--r-- | src/rail.h | 4 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 32 | ||||
-rw-r--r-- | src/road_cmd.cpp | 32 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 2 | ||||
-rw-r--r-- | src/station_cmd.cpp | 32 | ||||
-rw-r--r-- | src/table/engines.h | 19 | ||||
-rw-r--r-- | src/table/pricebase.h | 98 | ||||
-rw-r--r-- | src/terraform_cmd.cpp | 2 | ||||
-rw-r--r-- | src/town_cmd.cpp | 12 | ||||
-rw-r--r-- | src/town_gui.cpp | 4 | ||||
-rw-r--r-- | src/tree_cmd.cpp | 6 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 22 | ||||
-rw-r--r-- | src/unmovable.h | 4 | ||||
-rw-r--r-- | src/unmovable_cmd.cpp | 2 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 9 | ||||
-rw-r--r-- | src/water_cmd.cpp | 16 | ||||
-rw-r--r-- | src/waypoint_cmd.cpp | 6 |
30 files changed, 249 insertions, 242 deletions
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp index 27870cb3a..204a3a5bf 100644 --- a/src/ai/api/ai_airport.cpp +++ b/src/ai/api/ai_airport.cpp @@ -30,7 +30,7 @@ if (!IsValidAirportType(type)) return -1; const AirportFTAClass *afc = ::GetAirport(type); - return _price.build_airport * afc->size_x * afc->size_y; + return _price[PR_BUILD_STATION_AIRPORT] * afc->size_x * afc->size_y; } /* static */ bool AIAirport::IsHangarTile(TileIndex tile) diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp index 4fb9e1778..514bcd2d8 100644 --- a/src/ai/api/ai_bridge.cpp +++ b/src/ai/api/ai_bridge.cpp @@ -145,7 +145,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance) { if (!IsValidBridge(bridge_id)) return -1; - return ::CalcBridgeLenCostFactor(length) * _price.build_bridge * ::GetBridgeSpec(bridge_id)->price >> 8; + return ::CalcBridgeLenCostFactor(length) * _price[PR_BUILD_BRIDGE] * ::GetBridgeSpec(bridge_id)->price >> 8; } /* static */ int32 AIBridge::GetMaxLength(BridgeID bridge_id) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 52ec58de2..2d4e2160b 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -537,7 +537,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v) Money Aircraft::GetRunningCost() const { - return GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running; + return GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, AircraftVehInfo(this->engine_type)->running_cost) * _price[PR_RUNNING_AIRCRAFT]; } void Aircraft::OnNewDay() diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 0b57fb19d..6eb790475 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -407,7 +407,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo item->spec = GetBridgeSpec(brd_type); /* Add to terraforming & bulldozing costs the cost of the * bridge itself (not computed with DC_QUERY_COST) */ - item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * item->spec->price) >> 8); + item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8); } } } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 87bad3050..80d84e5a0 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -446,7 +446,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine } /* Running cost */ - if (rvi->running_cost_class != 0xFF) { + if (rvi->running_cost_class != INVALID_PRICE) { SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); y += FONT_HEIGHT_NORMAL; @@ -480,7 +480,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin } /* Running cost */ - if (rvi->running_cost_class != 0xFF) { + if (rvi->running_cost_class != INVALID_PRICE) { SetDParam(0, e->GetRunningCost()); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); y += FONT_HEIGHT_NORMAL; diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index bce21924a..32f4a7f75 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -28,18 +28,18 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags) { - static const Money * const clear_price_table[] = { - &_price.clear_grass, - &_price.clear_roughland, - &_price.clear_rocks, - &_price.clear_fields, - &_price.clear_roughland, - &_price.clear_roughland, + static const Price clear_price_table[] = { + PR_CLEAR_GRASS, + PR_CLEAR_ROUGH, + PR_CLEAR_ROCKS, + PR_CLEAR_FILEDS, + PR_CLEAR_ROUGH, + PR_CLEAR_ROUGH, }; CommandCost price(EXPENSES_CONSTRUCTION); if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) { - price.AddCost(*clear_price_table[GetClearGround(tile)]); + price.AddCost(_price[clear_price_table[GetClearGround(tile)]]); } if (flags & DC_EXEC) DoClearSquare(tile); diff --git a/src/economy.cpp b/src/economy.cpp index 78521011b..2e70af61f 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -123,7 +123,7 @@ Money CalculateCompanyValue(const Company *c) if (st->owner == owner) num += CountBits((byte)st->facilities); } - value += num * _price.station_value * 25; + value += num * _price[PR_STATION_VALUE] * 25; Vehicle *v; FOR_ALL_VEHICLES(v) { @@ -558,7 +558,7 @@ static void CompaniesGenStatistics() FOR_ALL_STATIONS(st) { _current_company = st->owner; - CommandCost cost(EXPENSES_PROPERTY, _price.station_value >> 1); + CommandCost cost(EXPENSES_PROPERTY, _price[PR_STATION_VALUE] >> 1); SubtractMoneyFromCompany(cost); } @@ -698,7 +698,7 @@ static void CompaniesPayInterest() SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INT, up_to_this_month - up_to_previous_month)); - SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price.station_value >> 2)); + SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price[PR_STATION_VALUE] >> 2)); } } @@ -793,11 +793,16 @@ void InitializeEconomy() _economy.inflation_prices = _economy.inflation_payment = 1 << 16; } -Money GetPriceByIndex(uint8 index) +/** + * Determine a certain base price with range checking + * @param index Price of interest + * @return Base price, or zero if out of range + */ +Money GetPriceByIndex(Price index) { - if (index > NUM_PRICES) return 0; + if (index >= NUM_PRICES) return 0; - return ((Money*)&_price)[index]; + return _price[index]; } Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type) diff --git a/src/economy_func.h b/src/economy_func.h index 2c66d5506..3ad447aa6 100644 --- a/src/economy_func.h +++ b/src/economy_func.h @@ -40,7 +40,7 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount, void PrepareUnload(Vehicle *front_v); void LoadUnloadStation(Station *st); -Money GetPriceByIndex(uint8 index); +Money GetPriceByIndex(Price index); void InitializeEconomy(); void RecomputePrices(); diff --git a/src/economy_type.h b/src/economy_type.h index c66da86bc..0f5a88ceb 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -59,61 +59,62 @@ struct ScoreInfo { int score; ///< How much score it will give }; -struct Prices { - Money station_value; - Money build_rail; - Money build_road; - Money build_signals; - Money build_bridge; - Money build_train_depot; - Money build_road_depot; - Money build_ship_depot; - Money build_tunnel; - Money train_station_track; - Money train_station_length; - Money build_airport; - Money build_bus_station; - Money build_truck_station; - Money build_dock; - Money build_railvehicle; - Money build_railwagon; - Money aircraft_base; - Money roadveh_base; - Money ship_base; - Money build_trees; - Money terraform; - Money clear_grass; - Money clear_roughland; - Money clear_rocks; - Money clear_fields; - Money remove_trees; - Money remove_rail; - Money remove_signals; - Money clear_bridge; - Money remove_train_depot; - Money remove_road_depot; - Money remove_ship_depot; - Money clear_tunnel; - Money clear_water; - Money remove_rail_station; - Money remove_airport; - Money remove_bus_station; - Money remove_truck_station; - Money remove_dock; - Money remove_house; - Money remove_road; - Money running_rail[3]; - Money aircraft_running; - Money roadveh_running; - Money ship_running; - Money build_industry; +enum Price { + PR_STATION_VALUE = 0, + PR_BUILD_RAIL, + PR_BUILD_ROAD, + PR_BUILD_SIGNALS, + PR_BUILD_BRIDGE, + PR_BUILD_DEPOT_TRAIN, + PR_BUILD_DEPOT_ROAD, + PR_BUILD_DEPOT_SHIP, + PR_BUILD_TUNNEL, + PR_BUILD_STATION_RAIL, + PR_BUILD_STATION_RAIL_LENGTH, + PR_BUILD_STATION_AIRPORT, + PR_BUILD_STATION_BUS, + PR_BUILD_STATION_TRUCK, + PR_BUILD_STATION_DOCK, + PR_BUILD_VEHICLE_TRAIN, + PR_BUILD_VEHICLE_WAGON, + PR_BUILD_VEHICLE_AIRCRAFT, + PR_BUILD_VEHICLE_ROAD, + PR_BUILD_VEHICLE_SHIP, + PR_BUILD_TREES, + PR_TERRAFORM, + PR_CLEAR_GRASS, + PR_CLEAR_ROUGH, + PR_CLEAR_ROCKS, + PR_CLEAR_FILEDS, + PR_CLEAR_TREES, + PR_CLEAR_RAIL, + PR_CLEAR_SIGNALS, + PR_CLEAR_BRIDGE, + PR_CLEAR_DEPOT_TRAIN, + PR_CLEAR_DEPOT_ROAD, + PR_CLEAR_DEPOT_SHIP, + PR_CLEAR_TUNNEL, + PR_CLEAR_WATER, + PR_CLEAR_STATION_RAIL, + PR_CLEAR_STATION_AIRPORT, + PR_CLEAR_STATION_BUS, + PR_CLEAR_STATION_TRUCK, + PR_CLEAR_STATION_DOCK, + PR_CLEAR_HOUSE, + PR_CLEAR_ROAD, + PR_RUNNING_TRAIN_STEAM, + PR_RUNNING_TRAIN_DIESEL, + PR_RUNNING_TRAIN_ELECTRIC, + PR_RUNNING_AIRCRAFT, + PR_RUNNING_ROADVEH, + PR_RUNNING_SHIP, + PR_BUILD_INDUSTRY, + + NUM_PRICES, + INVALID_PRICE = 0xFF }; -enum { - NUM_PRICES = 49, -}; - -assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices)); +typedef Money Prices[NUM_PRICES]; enum ExpensesType { EXPENSES_CONSTRUCTION = 0, diff --git a/src/engine.cpp b/src/engine.cpp index 45cdb8a40..1f49f2bce 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -212,10 +212,10 @@ Money Engine::GetRunningCost() const return GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost) * GetPriceByIndex(this->u.rail.running_cost_class) >> 8; case VEH_SHIP: - return GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost) * _price.ship_running >> 8; + return GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost) * _price[PR_RUNNING_SHIP] >> 8; case VEH_AIRCRAFT: - return GetEngineProperty(this->index, PROP_AIRCRAFT_RUNNING_COST_FACTOR, this->u.air.running_cost) * _price.aircraft_running >> 8; + return GetEngineProperty(this->index, PROP_AIRCRAFT_RUNNING_COST_FACTOR, this->u.air.running_cost) * _price[PR_RUNNING_AIRCRAFT] >> 8; default: NOT_REACHED(); } @@ -225,19 +225,19 @@ Money Engine::GetCost() const { switch (this->type) { case VEH_ROAD: - return GetEngineProperty(this->index, PROP_ROADVEH_COST_FACTOR, this->u.road.cost_factor) * (_price.roadveh_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_ROADVEH_COST_FACTOR, this->u.road.cost_factor) * (_price[PR_BUILD_VEHICLE_ROAD] >> 3) >> 5; case VEH_TRAIN: if (this->u.rail.railveh_type == RAILVEH_WAGON) { - return (GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * _price.build_railwagon) >> 8; + return (GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * _price[PR_BUILD_VEHICLE_WAGON]) >> 8; } else { - return GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * (_price.build_railvehicle >> 3) >> 5; + return GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * (_price[PR_BUILD_VEHICLE_TRAIN] >> 3) >> 5; } case VEH_SHIP: - return GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor) * (_price.ship_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor) * (_price[PR_BUILD_VEHICLE_SHIP] >> 3) >> 5; case VEH_AIRCRAFT: - return GetEngineProperty(this->index, PROP_AIRCRAFT_COST_FACTOR, this->u.air.cost_factor) * (_price.aircraft_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_AIRCRAFT_COST_FACTOR, this->u.air.cost_factor) * (_price[PR_BUILD_VEHICLE_AIRCRAFT] >> 3) >> 5; default: NOT_REACHED(); } diff --git a/src/engine_type.h b/src/engine_type.h index a1a9ccada..234bc27e3 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -12,6 +12,7 @@ #ifndef ENGINE_TYPE_H #define ENGINE_TYPE_H +#include "economy_type.h" #include "rail_type.h" #include "cargo_type.h" #include "vehicle_type.h" @@ -48,7 +49,7 @@ struct RailVehicleInfo { uint16 power; ///< Power of engine; For multiheaded engines the sum of both engine powers. uint16 weight; ///< Weight of vehicle; For multiheaded engines the weight of each single engine. byte running_cost; ///< Running cost of engine; For multiheaded engines the sum of both running costs. - byte running_cost_class; + Price running_cost_class; EngineClass engclass; ///< Class of engine for this vehicle byte capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine. byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only @@ -95,7 +96,7 @@ struct RoadVehicleInfo { byte image_index; byte cost_factor; byte running_cost; - byte running_cost_class; + Price running_cost_class; SoundID sfx; uint16 max_speed; ///< Maximum speed in mph/3.2 units byte capacity; diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 57d112f47..42b66ca12 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -2423,7 +2423,7 @@ bool IndustrySpec::IsRawIndustry() const Money IndustrySpec::GetConstructionCost() const { - return (_price.build_industry * + return (_price[PR_BUILD_INDUSTRY] * (_settings_game.construction.raw_industry_construction == 1 && this->IsRawIndustry() ? this->raw_industry_cost_multiplier : this->cost_multiplier @@ -2432,7 +2432,7 @@ Money IndustrySpec::GetConstructionCost() const Money IndustrySpec::GetRemovalCost() const { - return (_price.remove_house * this->removal_cost_multiplier) >> 8; + return (_price[PR_CLEAR_HOUSE] * this->removal_cost_multiplier) >> 8; } static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new) @@ -2454,10 +2454,10 @@ static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, u if (HasBit(itspec->callback_mask, CBM_INDT_AUTOSLOPE)) { /* If the callback fails, allow autoslope. */ uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile); - if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } else { /* allow autoslope */ - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } } } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 7c35388c8..21412ef95 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -418,17 +418,17 @@ static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) } /** - * Converts TTD(P) Base Price pointers into the index used by OTTD + * Converts TTD(P) Base Price pointers into the enum used by OTTD * See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts * @param base_pointer TTD(P) Base Price Pointer * @param error_location Function name for grf error messages * @param index If #base_pointer is valid, #index is assigned to the matching price; else it is left unchanged */ -static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location, byte *index) +static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location, Price *index) { /* Special value for 'none' */ if (base_pointer == 0) { - *index = 0xFF; + *index = INVALID_PRICE; return; } @@ -440,7 +440,7 @@ static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location, return; } - *index = (base_pointer - start) / size; + *index = (Price)((base_pointer - start) / size); } enum ChangeInfoResult { diff --git a/src/rail.h b/src/rail.h index 27b25895d..ae19c97c1 100644 --- a/src/rail.h +++ b/src/rail.h @@ -194,7 +194,7 @@ static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype) static inline Money RailBuildCost(RailType railtype) { assert(railtype < RAILTYPE_END); - return (_price.build_rail * GetRailTypeInfo(railtype)->cost_multiplier) >> 3; + return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3; } /** @@ -224,7 +224,7 @@ static inline Money RailConvertCost(RailType from, RailType to) } /* make the price the same as remove + build new type */ - return RailBuildCost(to) + _price.remove_rail; + return RailBuildCost(to) + _price[PR_CLEAR_RAIL]; } Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data); diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index fd84a2c22..eca108f02 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -297,7 +297,7 @@ static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits ex } Foundation f_old = GetRailFoundation(tileh, existing); - return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0); + return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price[PR_TERRAFORM] : (Money)0); } /* Validate functions for rail building */ @@ -422,8 +422,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u cost.AddCost(ret); if (water_ground) { - cost.AddCost(-_price.clear_water); - cost.AddCost(_price.clear_roughland); + cost.AddCost(-_price[PR_CLEAR_WATER]); + cost.AddCost(_price[PR_CLEAR_ROUGH]); } if (flags & DC_EXEC) { @@ -454,7 +454,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, { Track track = (Track)p2; TrackBits trackbit; - CommandCost cost(EXPENSES_CONSTRUCTION, _price.remove_rail ); + CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_RAIL] ); bool crossing = false; if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR; @@ -808,7 +808,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); } - return cost.AddCost(_price.build_train_depot); + return cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN]); } /** Build signals, alternate between double/single, signal/semaphore, @@ -874,17 +874,17 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, if (!HasSignalOnTrack(tile, track)) { /* build new signals */ - cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals); + cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS]); } else { if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) { /* convert signals <-> semaphores */ - cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals + _price.remove_signals); + cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] + _price[PR_CLEAR_SIGNALS]); } else if (convert_signal) { /* convert button pressed */ if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) { /* convert electric <-> semaphore */ - cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals + _price.remove_signals); + cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] + _price[PR_CLEAR_SIGNALS]); } else { /* it is free to change signal type: normal-pre-exit-combo */ cost = CommandCost(); @@ -1230,7 +1230,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1 MarkTileDirtyByTile(tile); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_signals); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_SIGNALS]); } /** Remove signals on a stretch of track. @@ -1471,7 +1471,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags) if (v != NULL) TryPathReserve(v, true); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_TRAIN]); } static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags) @@ -1512,7 +1512,7 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags) /* The track was removed, and left a coast tile. Now also clear the water. */ if (flags & DC_EXEC) DoClearSquare(tile); - cost.AddCost(_price.clear_water); + cost.AddCost(_price[PR_CLEAR_WATER]); } return cost; @@ -2490,7 +2490,7 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_ol case TRACK_BIT_UPPER: track_corner = CORNER_N; break; /* Surface slope must not be changed */ - default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, _price.terraform)); + default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM])); } /* The height of the track_corner must not be changed. The rest ensures GetRailFoundation() already. */ @@ -2498,11 +2498,11 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_ol z_new += GetSlopeZInCorner(RemoveHalftileSlope(tileh_new), track_corner); if (z_old != z_new) return CMD_ERROR; - CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); /* Make the ground dirty, if surface slope has changed */ if (tileh_old != tileh_new) { /* If there is flat water on the lower halftile add the cost for clearing it */ - if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price.clear_water); + if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price[PR_CLEAR_WATER]); if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN); } return cost; @@ -2547,10 +2547,10 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN); /* allow terraforming */ - return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0); + return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price[PR_CLEAR_WATER] : (Money)0); } else if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() && AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) { - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index bea59bd4d..ff610554f 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -209,7 +209,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec if (IsTileType(tile, MP_TUNNELBRIDGE)) { TileIndex other_end = GetOtherTunnelBridgeEnd(tile); /* Pay for *every* tile of the bridge or tunnel */ - cost.AddCost((GetTunnelBridgeLength(other_end, tile) + 2) * _price.remove_road); + cost.AddCost((GetTunnelBridgeLength(other_end, tile) + 2) * _price[PR_CLEAR_ROAD]); if (flags & DC_EXEC) { SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt)); SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); @@ -234,7 +234,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec } } else { assert(IsDriveThroughStopTile(tile)); - cost.AddCost(_price.remove_road * 2); + cost.AddCost(_price[PR_CLEAR_ROAD] * 2); if (flags & DC_EXEC) { SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); MarkTileDirtyByTile(tile); @@ -312,8 +312,8 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec } /* If we change the foundation we have to pay for it. */ - return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price.remove_road + - ((GetRoadFoundation(tileh, present) != f) ? _price.terraform : (Money)0)); + return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD] + + ((GetRoadFoundation(tileh, present) != f) ? _price[PR_TERRAFORM] : (Money)0)); } case ROAD_TILE_CROSSING: { @@ -340,7 +340,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec MarkTileDirtyByTile(tile); YapfNotifyTrackLayoutChange(tile, railtrack); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road * 2); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_ROAD] * 2); } default: @@ -401,7 +401,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi existing |= other; if ((existing == ROAD_NONE || existing == *pieces) && IsStraightRoad(*pieces)) { - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } return CMD_ERROR; } @@ -413,7 +413,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi if (_settings_game.construction.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) { /* If we add leveling we've got to pay for it */ - if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); return CommandCost(); } @@ -433,12 +433,12 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi if (_settings_game.construction.build_on_slopes) { /* If we add foundation we've got to pay for it */ - if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); return CommandCost(); } } else { - if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); return CommandCost(); } } @@ -573,7 +573,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 UpdateLevelCrossing(tile, false); MarkTileDirtyByTile(tile); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4)); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_ROAD] * (rt == ROADTYPE_ROAD ? 2 : 4)); } case MP_STATION: { @@ -638,7 +638,7 @@ do_clear:; if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; - cost.AddCost(CountBits(pieces) * _price.build_road); + cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]); if (IsTileType(tile, MP_TUNNELBRIDGE)) { /* Pay for *every* tile of the bridge or tunnel */ cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); @@ -894,7 +894,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui MakeRoadDepot(tile, _current_company, dep->index, dir, rt); MarkTileDirtyByTile(tile); } - return cost.AddCost(_price.build_road_depot); + return cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]); } static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags) @@ -908,7 +908,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags) DoClearSquare(tile); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_ROAD]); } static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags) @@ -1608,11 +1608,11 @@ static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlag flags, uint if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) { switch (GetRoadTileType(tile)) { case ROAD_TILE_CROSSING: - if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); break; case ROAD_TILE_DEPOT: - if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); break; case ROAD_TILE_NORMAL: { @@ -1630,7 +1630,7 @@ static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlag flags, uint z_new += ApplyFoundationToSlope(GetRoadFoundation(tileh_new, bits), &tileh_new); /* The surface slope must not be changed */ - if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } } break; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index c56f2dcf3..05e77d534 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -156,7 +156,7 @@ static void CheckIfShipNeedsService(Vehicle *v) Money Ship::GetRunningCost() const { - return GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running; + return GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, ShipVehInfo(this->engine_type)->running_cost) * _price[PR_RUNNING_SHIP]; } void Ship::OnNewDay() diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 769c8d2d0..3e12f6d5f 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -696,7 +696,7 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla (HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) { return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); } - cost.AddCost(_price.terraform); + cost.AddCost(_price[PR_TERRAFORM]); flat_z += TILE_HEIGHT; } @@ -1002,7 +1002,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 * https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */ CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL, true, rt); if (CmdFailed(ret)) return ret; - CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len); + CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len); Station *st = NULL; ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st); @@ -1292,7 +1292,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected } if (keep_rail) { /* Don't refund the 'steel' of the track! */ - total_cost.AddCost(-_price.remove_rail); + total_cost.AddCost(-_price[PR_CLEAR_RAIL]); } } @@ -1338,7 +1338,7 @@ CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint3 TileArea ta(start, end); SmallVector<Station *, 4> affected_stations; - CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_rail_station, HasBit(p2, 0)); + CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_STATION_RAIL], HasBit(p2, 0)); if (ret.Failed()) return ret; /* Do all station specific functions here. */ @@ -1372,7 +1372,7 @@ CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint TileArea ta(start, end); SmallVector<Waypoint *, 4> affected_stations; - return RemoveFromRailBaseStation(ta, affected_stations, flags, _price.remove_train_depot, HasBit(p2, 0)); + return RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_DEPOT_TRAIN], HasBit(p2, 0)); } @@ -1402,7 +1402,7 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags) if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; - cost.AddCost(_price.remove_rail_station); + cost.AddCost(_price[PR_CLEAR_STATION_RAIL]); if (flags & DC_EXEC) { /* read variables before the station tile is removed */ Track track = GetRailStationTrack(tile); @@ -1574,7 +1574,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin CommandCost cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road); if (CmdFailed(cost)) return cost; uint roadbits_to_build = CountBits(rts) * 2 - num_roadbits; - cost.AddCost(_price.build_road * roadbits_to_build); + cost.AddCost(_price[PR_BUILD_ROAD] * roadbits_to_build); Station *st = NULL; CommandCost ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 5), TileArea(tile, 1, 1), &st); @@ -1613,7 +1613,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } } - cost.AddCost((type) ? _price.build_truck_station : _price.build_bus_station); + cost.AddCost(_price[type ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS]); if (flags & DC_EXEC) { RoadStop *road_stop = new RoadStop(tile); @@ -1723,7 +1723,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags) DeleteStationIfEmpty(st); } - return CommandCost(EXPENSES_CONSTRUCTION, (is_truck) ? _price.remove_truck_station : _price.remove_bus_station); + return CommandCost(EXPENSES_CONSTRUCTION, _price[is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS]); } /** Remove a bus or truck stop @@ -1971,7 +1971,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } } - cost.AddCost(_price.build_airport * w * h); + cost.AddCost(_price[PR_BUILD_STATION_AIRPORT] * w * h); if (flags & DC_EXEC) { /* Always add the noise, so there will be no need to recalculate when option toggles */ @@ -2037,7 +2037,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags) int w = afc->size_x; int h = afc->size_y; - CommandCost cost(EXPENSES_CONSTRUCTION, w * h * _price.remove_airport); + CommandCost cost(EXPENSES_CONSTRUCTION, w * h * _price[PR_CLEAR_STATION_AIRPORT]); const Aircraft *a; FOR_ALL_AIRCRAFT(a) { @@ -2222,7 +2222,7 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_SHIPS); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_STATION_DOCK]); } /** @@ -2260,7 +2260,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags) DeleteStationIfEmpty(st); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_dock); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_STATION_DOCK]); } #include "table/station_land.h" @@ -3234,11 +3234,11 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, ui DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile)); if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break; if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break; - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } case STATION_AIRPORT: - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); case STATION_TRUCK: case STATION_BUS: { @@ -3247,7 +3247,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, ui if (IsDriveThroughStopTile(tile)) { if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break; } - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } default: break; diff --git a/src/table/engines.h b/src/table/engines.h index 321b9f41a..6820da116 100644 --- a/src/table/engines.h +++ b/src/table/engines.h @@ -14,14 +14,6 @@ #ifndef ENGINES_H #define ENGINES_H -enum { - RC_W = 0xFF, ///< Running cost price index (out of range) of wagons - RC_S = 0x2A, ///< Running cost price index of steam - RC_D = 0x2B, ///< Running cost price index of diesel - RC_E = 0x2C, ///< Running cost price index of electric - RC_R = 0x2E, ///< Running cost price index of road vehicles -}; - /** Writes the properties of a train or road vehicle into the EngineInfo struct. * @see EngineInfo * @param a Introduction date @@ -378,6 +370,11 @@ static const EngineInfo _orig_engine_info[] = { #define O RAILTYPE_MONO #define L RAILTYPE_MAGLEV +#define RC_S PR_RUNNING_TRAIN_STEAM +#define RC_D PR_RUNNING_TRAIN_DIESEL +#define RC_E PR_RUNNING_TRAIN_ELECTRIC +#define RC_W INVALID_PRICE + static const RailVehicleInfo _orig_rail_vehicle_info[] = { /* image_index max_speed (kph) running_cost engclass * | flags | power (hp) | running_cost_class @@ -501,6 +498,10 @@ static const RailVehicleInfo _orig_rail_vehicle_info[] = { RVI(58, W, 193, 0, 0, 18, 0, RC_W, 32, L, A), // 114 RVI(59, W, 191, 0, 0, 18, 0, RC_W, 37, L, A), // 115 }; +#undef RC_W +#undef RC_E +#undef RC_D +#undef RC_S #undef L #undef O #undef C @@ -625,7 +626,7 @@ static const AircraftVehicleInfo _orig_aircraft_vehicle_info[] = { * @param g weight (1/4ton) * @param h power (10hp) */ -#define ROV(a, b, c, d, e, f, g, h) { a, b, c, RC_R, d, e, f, g, h, 76, 0 } +#define ROV(a, b, c, d, e, f, g, h) { a, b, c, PR_RUNNING_ROADVEH, d, e, f, g, h, 76, 0 } static const RoadVehicleInfo _orig_road_vehicle_info[] = { /* image_index sfx max_speed power * | base_cost | | capacity | diff --git a/src/table/pricebase.h b/src/table/pricebase.h index 364dd3f82..d42d2da1f 100644 --- a/src/table/pricebase.h +++ b/src/table/pricebase.h @@ -10,53 +10,53 @@ /** @file pricebase.h Price Bases */ static const PriceBaseSpec _price_base_specs[NUM_PRICES] = { - { 100, PCAT_NONE }, ///< station_value - { 100, PCAT_CONSTRUCTION}, ///< build_rail - { 95, PCAT_CONSTRUCTION}, ///< build_road - { 65, PCAT_CONSTRUCTION}, ///< build_signals - { 275, PCAT_CONSTRUCTION}, ///< build_bridge - { 600, PCAT_CONSTRUCTION}, ///< build_train_depot - { 500, PCAT_CONSTRUCTION}, ///< build_road_depot - { 700, PCAT_CONSTRUCTION}, ///< build_ship_depot - { 450, PCAT_CONSTRUCTION}, ///< build_tunnel - { 200, PCAT_CONSTRUCTION}, ///< train_station_track - { 180, PCAT_CONSTRUCTION}, ///< train_station_length - { 600, PCAT_CONSTRUCTION}, ///< build_airport - { 200, PCAT_CONSTRUCTION}, ///< build_bus_station - { 200, PCAT_CONSTRUCTION}, ///< build_truck_station - { 350, PCAT_CONSTRUCTION}, ///< build_dock - { 400000, PCAT_CONSTRUCTION}, ///< build_railvehicle - { 2000, PCAT_CONSTRUCTION}, ///< build_railwagon - { 700000, PCAT_CONSTRUCTION}, ///< aircraft_base - { 14000, PCAT_CONSTRUCTION}, ///< roadveh_base - { 65000, PCAT_CONSTRUCTION}, ///< ship_base - { 20, PCAT_CONSTRUCTION}, ///< build_trees - { 250, PCAT_CONSTRUCTION}, ///< terraform - { 20, PCAT_CONSTRUCTION}, ///< clear_grass - { 40, PCAT_CONSTRUCTION}, ///< clear_roughland - { 200, PCAT_CONSTRUCTION}, ///< clear_rocks - { 500, PCAT_CONSTRUCTION}, ///< clear_fields - { 20, PCAT_CONSTRUCTION}, ///< remove_trees - { -70, PCAT_CONSTRUCTION}, ///< remove_rail - { 10, PCAT_CONSTRUCTION}, ///< remove_signals - { 50, PCAT_CONSTRUCTION}, ///< clear_bridge - { 80, PCAT_CONSTRUCTION}, ///< remove_train_depot - { 80, PCAT_CONSTRUCTION}, ///< remove_road_depot - { 90, PCAT_CONSTRUCTION}, ///< remove_ship_depot - { 30, PCAT_CONSTRUCTION}, ///< clear_tunnel - { 10000, PCAT_CONSTRUCTION}, ///< clear_water - { 50, PCAT_CONSTRUCTION}, ///< remove_rail_station - { 30, PCAT_CONSTRUCTION}, ///< remove_airport - { 50, PCAT_CONSTRUCTION}, ///< remove_bus_station - { 50, PCAT_CONSTRUCTION}, ///< remove_truck_station - { 55, PCAT_CONSTRUCTION}, ///< remove_dock - { 1600, PCAT_CONSTRUCTION}, ///< remove_house - { 40, PCAT_CONSTRUCTION}, ///< remove_road - { 5600, PCAT_RUNNING }, ///< running_rail[0] steam - { 5200, PCAT_RUNNING }, ///< running_rail[1] diesel - { 4800, PCAT_RUNNING }, ///< running_rail[2] electric - { 9600, PCAT_RUNNING }, ///< aircraft_running - { 1600, PCAT_RUNNING }, ///< roadveh_running - { 5600, PCAT_RUNNING }, ///< ship_running - {1000000, PCAT_CONSTRUCTION}, ///< build_industry + { 100, PCAT_NONE }, ///< PR_STATION_VALUE + { 100, PCAT_CONSTRUCTION}, ///< PR_BUILD_RAIL + { 95, PCAT_CONSTRUCTION}, ///< PR_BUILD_ROAD + { 65, PCAT_CONSTRUCTION}, ///< PR_BUILD_SIGNALS + { 275, PCAT_CONSTRUCTION}, ///< PR_BUILD_BRIDGE + { 600, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_TRAIN + { 500, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_ROAD + { 700, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_SHIP + { 450, PCAT_CONSTRUCTION}, ///< PR_BUILD_TUNNEL + { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_RAIL + { 180, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_RAIL_LENGTH + { 600, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_AIRPORT + { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_BUS + { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_TRUCK + { 350, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_DOCK + { 400000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_TRAIN + { 2000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_WAGON + { 700000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_AIRCRAFT + { 14000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_ROAD + { 65000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_SHIP + { 20, PCAT_CONSTRUCTION}, ///< PR_BUILD_TREES + { 250, PCAT_CONSTRUCTION}, ///< PR_TERRAFORM + { 20, PCAT_CONSTRUCTION}, ///< PR_CLEAR_GRASS + { 40, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROUGH + { 200, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROCKS + { 500, PCAT_CONSTRUCTION}, ///< PR_CLEAR_FILEDS + { 20, PCAT_CONSTRUCTION}, ///< PR_CLEAR_TREES + { -70, PCAT_CONSTRUCTION}, ///< PR_CLEAR_RAIL + { 10, PCAT_CONSTRUCTION}, ///< PR_CLEAR_SIGNALS + { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_BRIDGE + { 80, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_TRAIN + { 80, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_ROAD + { 90, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_SHIP + { 30, PCAT_CONSTRUCTION}, ///< PR_CLEAR_TUNNEL + { 10000, PCAT_CONSTRUCTION}, ///< PR_CLEAR_WATER + { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_RAIL + { 30, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_AIRPORT + { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_BUS + { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_TRUCK + { 55, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_DOCK + { 1600, PCAT_CONSTRUCTION}, ///< PR_CLEAR_HOUSE + { 40, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROAD + { 5600, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_STEAM + { 5200, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_DIESEL + { 4800, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_ELECTRIC + { 9600, PCAT_RUNNING }, ///< PR_RUNNING_AIRCRAFT + { 1600, PCAT_RUNNING }, ///< PR_RUNNING_ROADVEH + { 5600, PCAT_RUNNING }, ///< PR_RUNNING_SHIP + {1000000, PCAT_CONSTRUCTION}, ///< PR_BUILD_INDUSTRY }; diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 5a82bf669..f9b227be3 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -187,7 +187,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int CommandCost total_cost(EXPENSES_CONSTRUCTION); /* Increment cost */ - total_cost.AddCost(_price.terraform); + total_cost.AddCost(_price[PR_TERRAFORM]); /* Recurse to neighboured corners if height difference is larger than 1 */ { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 975eeda63..60246f370 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -157,7 +157,7 @@ void Town::InitializeLayout(TownLayout layout) Money HouseSpec::GetRemovalCost() const { - return (_price.remove_house * this->removal_cost) >> 8; + return (_price[PR_CLEAR_HOUSE] * this->removal_cost) >> 8; } // Local @@ -830,7 +830,7 @@ static bool TerraformTownTile(TileIndex tile, int edges, int dir) assert(tile < MapSize()); CommandCost r = DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND); - if (CmdFailed(r) || r.GetCost() >= (_price.terraform + 2) * 8) return false; + if (CmdFailed(r) || r.GetCost() >= (_price[PR_TERRAFORM] + 2) * 8) return false; DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_TERRAFORM_LAND); return true; } @@ -2477,8 +2477,8 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t) if (cid != COMPANY_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[cid])) { /* Things worth more than this are not shown */ - Money avail = Company::Get(cid)->money + _price.station_value * 200; - Money ref = _price.build_industry >> 8; + Money avail = Company::Get(cid)->money + _price[PR_STATION_VALUE] * 200; + Money ref = _price[PR_BUILD_INDUSTRY] >> 8; /* Check the action bits for validity and * if they are valid add them */ @@ -2525,7 +2525,7 @@ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR; - CommandCost cost(EXPENSES_OTHER, (_price.build_industry >> 8) * _town_action_costs[p2]); + CommandCost cost(EXPENSES_OTHER, (_price[PR_BUILD_INDUSTRY] >> 8) * _town_action_costs[p2]); if (flags & DC_EXEC) { _town_action_proc[p2](t); @@ -2861,7 +2861,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, uint if ((res != 0) && (res != CALLBACK_FAILED)) allow_terraform = false; } - if (allow_terraform) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (allow_terraform) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 8b6733416..c5585a595 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -175,7 +175,7 @@ public: switch (widget) { case TWA_ACTION_INFO: if (this->sel_index != -1) { - SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[this->sel_index]); + SetDParam(1, (_price[PR_BUILD_INDUSTRY] >> 8) * _town_action_costs[this->sel_index]); SetDParam(0, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + this->sel_index); DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM, STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index); @@ -214,7 +214,7 @@ public: size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; Dimension d = {0, 0}; for (int i = 0; i < TACT_COUNT; i++) { - SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); + SetDParam(1, (_price[PR_BUILD_INDUSTRY] >> 8) * _town_action_costs[i]); SetDParam(0, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i); d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size)); } diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 3720be8c0..d0dec00e2 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -368,7 +368,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 MarkTileDirtyByTile(tile); } /* 2x as expensive to add more trees to an existing tile */ - cost.AddCost(_price.build_trees * 2); + cost.AddCost(_price[PR_BUILD_TREES] * 2); break; case MP_WATER: @@ -420,7 +420,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) SetTropicZone(tile, TROPICZONE_RAINFOREST); } - cost.AddCost(_price.build_trees); + cost.AddCost(_price[PR_BUILD_TREES]); break; default: @@ -551,7 +551,7 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags) if (flags & DC_EXEC) DoClearSquare(tile); - return CommandCost(EXPENSES_CONSTRUCTION, num * _price.remove_trees); + return CommandCost(EXPENSES_CONSTRUCTION, num * _price[PR_CLEAR_TREES]); } static void GetTileDesc_Trees(TileIndex tile, TileDesc *td) diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index aafae7fdc..3602805e0 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -133,7 +133,7 @@ static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, uint *z) if (f == FOUNDATION_NONE) return CommandCost(); - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } /** @@ -154,7 +154,7 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z) if (f == FOUNDATION_NONE) return CommandCost(); - return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags) @@ -290,7 +290,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u return_cmd_error(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER); } - cost.AddCost((bridge_len + 1) * _price.clear_bridge); // The cost of clearing the current bridge. + cost.AddCost((bridge_len + 1) * _price[PR_CLEAR_BRIDGE]); // The cost of clearing the current bridge. owner = GetTileOwner(tile_start); /* Do not remove road types when upgrading a bridge */ @@ -438,10 +438,10 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u if (c != NULL) bridge_len = CalcBridgeLenCostFactor(bridge_len); - cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8); + cost.AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8); /* Aqueducts are a little more expensive. */ - if (transport_type == TRANSPORT_WATER) cost.AddCost((int64)bridge_len * _price.clear_water); + if (transport_type == TRANSPORT_WATER) cost.AddCost((int64)bridge_len * _price[PR_CLEAR_WATER]); } return cost; @@ -520,12 +520,12 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, tiles_bump *= 2; } - cost.AddCost(_price.build_tunnel); + cost.AddCost(_price[PR_BUILD_TUNNEL]); cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels } /* Add the cost of the entrance */ - cost.AddCost(_price.build_tunnel); + cost.AddCost(_price[PR_BUILD_TUNNEL]); cost.AddCost(ret); /* if the command fails from here on we want the end tile to be highlighted */ @@ -548,7 +548,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return ret; } - cost.AddCost(_price.build_tunnel); + cost.AddCost(_price[PR_BUILD_TUNNEL]); cost.AddCost(ret); if (flags & DC_EXEC) { @@ -656,7 +656,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) DoClearSquare(endtile); } } - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (GetTunnelBridgeLength(tile, endtile) + 2)); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_TUNNEL] * (GetTunnelBridgeLength(tile, endtile) + 2)); } @@ -730,7 +730,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) } } - return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price.clear_bridge); + return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price[PR_CLEAR_BRIDGE]); } static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags) @@ -1505,7 +1505,7 @@ static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flag } /* Surface slope is valid and remains unchanged? */ - if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); diff --git a/src/unmovable.h b/src/unmovable.h index 56f7b8a9a..8e99cff11 100644 --- a/src/unmovable.h +++ b/src/unmovable.h @@ -23,8 +23,8 @@ struct UnmovableSpec { uint8 buy_cost_multiplier; uint8 sell_cost_multiplier; - Money GetRemovalCost() const { return (_price.clear_roughland * this->sell_cost_multiplier); } - Money GetBuildingCost() const { return (_price.clear_roughland * this->buy_cost_multiplier); } + Money GetRemovalCost() const { return (_price[PR_CLEAR_ROUGH] * this->sell_cost_multiplier); } + Money GetBuildingCost() const { return (_price[PR_CLEAR_ROUGH] * this->buy_cost_multiplier); } }; diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp index 0bbce5952..93ac08998 100644 --- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -500,7 +500,7 @@ static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost(); if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) { - if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); + if (!IsSteepSlope(tileh_new) && (z_new + GetSlopeMaxZ(tileh_new) == GetTileMaxZ(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]); } return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 9bd27ad60..529d31adc 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -267,23 +267,22 @@ static CommandCost GetRefitCost(EngineID engine_type) const Engine *e = Engine::Get(engine_type); switch (e->type) { case VEH_SHIP: - base_cost = _price.ship_base; + base_cost = _price[PR_BUILD_VEHICLE_SHIP]; expense_type = EXPENSES_SHIP_RUN; break; case VEH_ROAD: - base_cost = _price.roadveh_base; + base_cost = _price[PR_BUILD_VEHICLE_ROAD]; expense_type = EXPENSES_ROADVEH_RUN; break; case VEH_AIRCRAFT: - base_cost = _price.aircraft_base; + base_cost = _price[PR_BUILD_VEHICLE_AIRCRAFT]; expense_type = EXPENSES_AIRCRAFT_RUN; break; case VEH_TRAIN: - base_cost = 2 * ((e->u.rail.railveh_type == RAILVEH_WAGON) ? - _price.build_railwagon : _price.build_railvehicle); + base_cost = 2 * _price[(e->u.rail.railveh_type == RAILVEH_WAGON) ? PR_BUILD_VEHICLE_WAGON : PR_BUILD_VEHICLE_TRAIN]; expense_type = EXPENSES_TRAIN_RUN; break; diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 914961461..909f41bee 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -148,7 +148,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui MarkTileDirtyByTile(tile2); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]); } void MakeWaterKeepingClass(TileIndex tile, Owner o) @@ -193,7 +193,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags) MarkTileDirtyByTile(tile2); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_SHIP]); } /** build a shiplift */ @@ -240,7 +240,7 @@ static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, DoCommandF MarkCanalsAndRiversAroundDirty(tile + delta); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 22 >> 3); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER] * 22 >> 3); } static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags) @@ -263,7 +263,7 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags) MarkCanalsAndRiversAroundDirty(tile + delta); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER] * 2); } /** Builds a lock (ship-lift) @@ -346,7 +346,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 MarkCanalsAndRiversAroundDirty(tile); } - cost.AddCost(_price.clear_water); + cost.AddCost(_price[PR_CLEAR_WATER]); } if (cost.GetCost() == 0) { @@ -377,7 +377,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags) DoClearSquare(tile); MarkCanalsAndRiversAroundDirty(tile); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER]); case WATER_TILE_COAST: { Slope slope = GetTileSlope(tile, NULL); @@ -390,9 +390,9 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags) MarkCanalsAndRiversAroundDirty(tile); } if (IsSlopeWithOneCornerRaised(slope)) { - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER]); } else { - return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_roughland); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_ROUGH]); } } diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index b96805104..bab3eb4ac 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -319,7 +319,7 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint } } - return CommandCost(EXPENSES_CONSTRUCTION, count * _price.build_train_depot); + return CommandCost(EXPENSES_CONSTRUCTION, count * _price[PR_BUILD_DEPOT_TRAIN]); } /** Build a buoy. @@ -366,7 +366,7 @@ CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); } - return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_STATION_DOCK]); } /** @@ -404,7 +404,7 @@ CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags) wp->delete_ctr = 0; } - return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_truck_station); + return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_STATION_TRUCK]); } |