1
0
Fork 0

(svn r18005) -Codechange: Convert the Prices struct into an array and an enum.

release/1.0
frosch 2009-11-07 22:47:54 +00:00
parent 7984d90c40
commit ba1fc280e3
30 changed files with 249 additions and 242 deletions

View File

@ -30,7 +30,7 @@
if (!IsValidAirportType(type)) return -1; if (!IsValidAirportType(type)) return -1;
const AirportFTAClass *afc = ::GetAirport(type); 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) /* static */ bool AIAirport::IsHangarTile(TileIndex tile)

View File

@ -145,7 +145,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
{ {
if (!IsValidBridge(bridge_id)) return -1; 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) /* static */ int32 AIBridge::GetMaxLength(BridgeID bridge_id)

View File

@ -537,7 +537,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v)
Money Aircraft::GetRunningCost() const 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() void Aircraft::OnNewDay()

View File

@ -407,7 +407,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
item->spec = GetBridgeSpec(brd_type); item->spec = GetBridgeSpec(brd_type);
/* Add to terraforming & bulldozing costs the cost of the /* Add to terraforming & bulldozing costs the cost of the
* bridge itself (not computed with DC_QUERY_COST) */ * 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);
} }
} }
} }

View File

@ -446,7 +446,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
} }
/* Running cost */ /* Running cost */
if (rvi->running_cost_class != 0xFF) { if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost()); SetDParam(0, e->GetRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL; y += FONT_HEIGHT_NORMAL;
@ -480,7 +480,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
} }
/* Running cost */ /* Running cost */
if (rvi->running_cost_class != 0xFF) { if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost()); SetDParam(0, e->GetRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST); DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL; y += FONT_HEIGHT_NORMAL;

View File

@ -28,18 +28,18 @@
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags) static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
{ {
static const Money * const clear_price_table[] = { static const Price clear_price_table[] = {
&_price.clear_grass, PR_CLEAR_GRASS,
&_price.clear_roughland, PR_CLEAR_ROUGH,
&_price.clear_rocks, PR_CLEAR_ROCKS,
&_price.clear_fields, PR_CLEAR_FILEDS,
&_price.clear_roughland, PR_CLEAR_ROUGH,
&_price.clear_roughland, PR_CLEAR_ROUGH,
}; };
CommandCost price(EXPENSES_CONSTRUCTION); CommandCost price(EXPENSES_CONSTRUCTION);
if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) { 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); if (flags & DC_EXEC) DoClearSquare(tile);

View File

@ -123,7 +123,7 @@ Money CalculateCompanyValue(const Company *c)
if (st->owner == owner) num += CountBits((byte)st->facilities); if (st->owner == owner) num += CountBits((byte)st->facilities);
} }
value += num * _price.station_value * 25; value += num * _price[PR_STATION_VALUE] * 25;
Vehicle *v; Vehicle *v;
FOR_ALL_VEHICLES(v) { FOR_ALL_VEHICLES(v) {
@ -558,7 +558,7 @@ static void CompaniesGenStatistics()
FOR_ALL_STATIONS(st) { FOR_ALL_STATIONS(st) {
_current_company = st->owner; _current_company = st->owner;
CommandCost cost(EXPENSES_PROPERTY, _price.station_value >> 1); CommandCost cost(EXPENSES_PROPERTY, _price[PR_STATION_VALUE] >> 1);
SubtractMoneyFromCompany(cost); 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_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; _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) Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)

View File

@ -40,7 +40,7 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount,
void PrepareUnload(Vehicle *front_v); void PrepareUnload(Vehicle *front_v);
void LoadUnloadStation(Station *st); void LoadUnloadStation(Station *st);
Money GetPriceByIndex(uint8 index); Money GetPriceByIndex(Price index);
void InitializeEconomy(); void InitializeEconomy();
void RecomputePrices(); void RecomputePrices();

View File

@ -59,61 +59,62 @@ struct ScoreInfo {
int score; ///< How much score it will give int score; ///< How much score it will give
}; };
struct Prices { enum Price {
Money station_value; PR_STATION_VALUE = 0,
Money build_rail; PR_BUILD_RAIL,
Money build_road; PR_BUILD_ROAD,
Money build_signals; PR_BUILD_SIGNALS,
Money build_bridge; PR_BUILD_BRIDGE,
Money build_train_depot; PR_BUILD_DEPOT_TRAIN,
Money build_road_depot; PR_BUILD_DEPOT_ROAD,
Money build_ship_depot; PR_BUILD_DEPOT_SHIP,
Money build_tunnel; PR_BUILD_TUNNEL,
Money train_station_track; PR_BUILD_STATION_RAIL,
Money train_station_length; PR_BUILD_STATION_RAIL_LENGTH,
Money build_airport; PR_BUILD_STATION_AIRPORT,
Money build_bus_station; PR_BUILD_STATION_BUS,
Money build_truck_station; PR_BUILD_STATION_TRUCK,
Money build_dock; PR_BUILD_STATION_DOCK,
Money build_railvehicle; PR_BUILD_VEHICLE_TRAIN,
Money build_railwagon; PR_BUILD_VEHICLE_WAGON,
Money aircraft_base; PR_BUILD_VEHICLE_AIRCRAFT,
Money roadveh_base; PR_BUILD_VEHICLE_ROAD,
Money ship_base; PR_BUILD_VEHICLE_SHIP,
Money build_trees; PR_BUILD_TREES,
Money terraform; PR_TERRAFORM,
Money clear_grass; PR_CLEAR_GRASS,
Money clear_roughland; PR_CLEAR_ROUGH,
Money clear_rocks; PR_CLEAR_ROCKS,
Money clear_fields; PR_CLEAR_FILEDS,
Money remove_trees; PR_CLEAR_TREES,
Money remove_rail; PR_CLEAR_RAIL,
Money remove_signals; PR_CLEAR_SIGNALS,
Money clear_bridge; PR_CLEAR_BRIDGE,
Money remove_train_depot; PR_CLEAR_DEPOT_TRAIN,
Money remove_road_depot; PR_CLEAR_DEPOT_ROAD,
Money remove_ship_depot; PR_CLEAR_DEPOT_SHIP,
Money clear_tunnel; PR_CLEAR_TUNNEL,
Money clear_water; PR_CLEAR_WATER,
Money remove_rail_station; PR_CLEAR_STATION_RAIL,
Money remove_airport; PR_CLEAR_STATION_AIRPORT,
Money remove_bus_station; PR_CLEAR_STATION_BUS,
Money remove_truck_station; PR_CLEAR_STATION_TRUCK,
Money remove_dock; PR_CLEAR_STATION_DOCK,
Money remove_house; PR_CLEAR_HOUSE,
Money remove_road; PR_CLEAR_ROAD,
Money running_rail[3]; PR_RUNNING_TRAIN_STEAM,
Money aircraft_running; PR_RUNNING_TRAIN_DIESEL,
Money roadveh_running; PR_RUNNING_TRAIN_ELECTRIC,
Money ship_running; PR_RUNNING_AIRCRAFT,
Money build_industry; PR_RUNNING_ROADVEH,
PR_RUNNING_SHIP,
PR_BUILD_INDUSTRY,
NUM_PRICES,
INVALID_PRICE = 0xFF
}; };
enum { typedef Money Prices[NUM_PRICES];
NUM_PRICES = 49,
};
assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices));
enum ExpensesType { enum ExpensesType {
EXPENSES_CONSTRUCTION = 0, EXPENSES_CONSTRUCTION = 0,

View File

@ -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; 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: 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: 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(); default: NOT_REACHED();
} }
@ -225,19 +225,19 @@ Money Engine::GetCost() const
{ {
switch (this->type) { switch (this->type) {
case VEH_ROAD: 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: case VEH_TRAIN:
if (this->u.rail.railveh_type == RAILVEH_WAGON) { 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 { } 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: 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: 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(); default: NOT_REACHED();
} }

View File

@ -12,6 +12,7 @@
#ifndef ENGINE_TYPE_H #ifndef ENGINE_TYPE_H
#define ENGINE_TYPE_H #define ENGINE_TYPE_H
#include "economy_type.h"
#include "rail_type.h" #include "rail_type.h"
#include "cargo_type.h" #include "cargo_type.h"
#include "vehicle_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 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. 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; ///< 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 EngineClass engclass; ///< Class of engine for this vehicle
byte capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine. 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 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 image_index;
byte cost_factor; byte cost_factor;
byte running_cost; byte running_cost;
byte running_cost_class; Price running_cost_class;
SoundID sfx; SoundID sfx;
uint16 max_speed; ///< Maximum speed in mph/3.2 units uint16 max_speed; ///< Maximum speed in mph/3.2 units
byte capacity; byte capacity;

View File

@ -2423,7 +2423,7 @@ bool IndustrySpec::IsRawIndustry() const
Money IndustrySpec::GetConstructionCost() const Money IndustrySpec::GetConstructionCost() const
{ {
return (_price.build_industry * return (_price[PR_BUILD_INDUSTRY] *
(_settings_game.construction.raw_industry_construction == 1 && this->IsRawIndustry() ? (_settings_game.construction.raw_industry_construction == 1 && this->IsRawIndustry() ?
this->raw_industry_cost_multiplier : this->raw_industry_cost_multiplier :
this->cost_multiplier this->cost_multiplier
@ -2432,7 +2432,7 @@ Money IndustrySpec::GetConstructionCost() const
Money IndustrySpec::GetRemovalCost() 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) 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 (HasBit(itspec->callback_mask, CBM_INDT_AUTOSLOPE)) {
/* If the callback fails, allow autoslope. */ /* If the callback fails, allow autoslope. */
uint16 res = GetIndustryTileCallback(CBID_INDUSTRY_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile); 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 { } else {
/* allow autoslope */ /* allow autoslope */
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]);
} }
} }
} }

View File

@ -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 * See http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts
* @param base_pointer TTD(P) Base Price Pointer * @param base_pointer TTD(P) Base Price Pointer
* @param error_location Function name for grf error messages * @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 * @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' */ /* Special value for 'none' */
if (base_pointer == 0) { if (base_pointer == 0) {
*index = 0xFF; *index = INVALID_PRICE;
return; return;
} }
@ -440,7 +440,7 @@ static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location,
return; return;
} }
*index = (base_pointer - start) / size; *index = (Price)((base_pointer - start) / size);
} }
enum ChangeInfoResult { enum ChangeInfoResult {

View File

@ -194,7 +194,7 @@ static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
static inline Money RailBuildCost(RailType railtype) static inline Money RailBuildCost(RailType railtype)
{ {
assert(railtype < RAILTYPE_END); 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 */ /* 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); Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data);

View File

@ -297,7 +297,7 @@ static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits ex
} }
Foundation f_old = GetRailFoundation(tileh, existing); 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 */ /* Validate functions for rail building */
@ -422,8 +422,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
cost.AddCost(ret); cost.AddCost(ret);
if (water_ground) { if (water_ground) {
cost.AddCost(-_price.clear_water); cost.AddCost(-_price[PR_CLEAR_WATER]);
cost.AddCost(_price.clear_roughland); cost.AddCost(_price[PR_CLEAR_ROUGH]);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -454,7 +454,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
{ {
Track track = (Track)p2; Track track = (Track)p2;
TrackBits trackbit; TrackBits trackbit;
CommandCost cost(EXPENSES_CONSTRUCTION, _price.remove_rail ); CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_RAIL] );
bool crossing = false; bool crossing = false;
if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR; if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
@ -808,7 +808,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); 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, /** Build signals, alternate between double/single, signal/semaphore,
@ -874,17 +874,17 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (!HasSignalOnTrack(tile, track)) { if (!HasSignalOnTrack(tile, track)) {
/* build new signals */ /* build new signals */
cost = CommandCost(EXPENSES_CONSTRUCTION, _price.build_signals); cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS]);
} else { } else {
if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) { if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) {
/* convert signals <-> semaphores */ /* 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) { } else if (convert_signal) {
/* convert button pressed */ /* convert button pressed */
if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) { if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) {
/* convert electric <-> semaphore */ /* 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 { } else {
/* it is free to change signal type: normal-pre-exit-combo */ /* it is free to change signal type: normal-pre-exit-combo */
cost = CommandCost(); cost = CommandCost();
@ -1230,7 +1230,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_signals); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_SIGNALS]);
} }
/** Remove signals on a stretch of track. /** Remove signals on a stretch of track.
@ -1471,7 +1471,7 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
if (v != NULL) TryPathReserve(v, true); 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) 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. */ /* The track was removed, and left a coast tile. Now also clear the water. */
if (flags & DC_EXEC) DoClearSquare(tile); if (flags & DC_EXEC) DoClearSquare(tile);
cost.AddCost(_price.clear_water); cost.AddCost(_price[PR_CLEAR_WATER]);
} }
return cost; 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; case TRACK_BIT_UPPER: track_corner = CORNER_N; break;
/* Surface slope must not be changed */ /* 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. */ /* 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); z_new += GetSlopeZInCorner(RemoveHalftileSlope(tileh_new), track_corner);
if (z_old != z_new) return CMD_ERROR; 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 */ /* Make the ground dirty, if surface slope has changed */
if (tileh_old != tileh_new) { if (tileh_old != tileh_new) {
/* If there is flat water on the lower halftile add the cost for clearing it */ /* 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); if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
} }
return cost; 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); if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
/* allow terraforming */ /* 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() && } else if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() &&
AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) { 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); return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
} }

View File

@ -209,7 +209,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
if (IsTileType(tile, MP_TUNNELBRIDGE)) { if (IsTileType(tile, MP_TUNNELBRIDGE)) {
TileIndex other_end = GetOtherTunnelBridgeEnd(tile); TileIndex other_end = GetOtherTunnelBridgeEnd(tile);
/* Pay for *every* tile of the bridge or tunnel */ /* 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) { if (flags & DC_EXEC) {
SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt)); SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt));
SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
@ -234,7 +234,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
} }
} else { } else {
assert(IsDriveThroughStopTile(tile)); assert(IsDriveThroughStopTile(tile));
cost.AddCost(_price.remove_road * 2); cost.AddCost(_price[PR_CLEAR_ROAD] * 2);
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
MarkTileDirtyByTile(tile); 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. */ /* If we change the foundation we have to pay for it. */
return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price.remove_road + return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD] +
((GetRoadFoundation(tileh, present) != f) ? _price.terraform : (Money)0)); ((GetRoadFoundation(tileh, present) != f) ? _price[PR_TERRAFORM] : (Money)0));
} }
case ROAD_TILE_CROSSING: { case ROAD_TILE_CROSSING: {
@ -340,7 +340,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, railtrack); YapfNotifyTrackLayoutChange(tile, railtrack);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road * 2); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_ROAD] * 2);
} }
default: default:
@ -401,7 +401,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
existing |= other; existing |= other;
if ((existing == ROAD_NONE || existing == *pieces) && IsStraightRoad(*pieces)) { if ((existing == ROAD_NONE || existing == *pieces) && IsStraightRoad(*pieces)) {
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]);
} }
return CMD_ERROR; 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 (_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 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(); return CommandCost();
} }
@ -433,12 +433,12 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
if (_settings_game.construction.build_on_slopes) { if (_settings_game.construction.build_on_slopes) {
/* If we add foundation we've got to pay for it */ /* 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(); return CommandCost();
} }
} else { } else {
if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]);
return CommandCost(); return CommandCost();
} }
} }
@ -573,7 +573,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
UpdateLevelCrossing(tile, false); UpdateLevelCrossing(tile, false);
MarkTileDirtyByTile(tile); 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: { case MP_STATION: {
@ -638,7 +638,7 @@ do_clear:;
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; 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)) { if (IsTileType(tile, MP_TUNNELBRIDGE)) {
/* Pay for *every* tile of the bridge or tunnel */ /* Pay for *every* tile of the bridge or tunnel */
cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); 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); MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
return cost.AddCost(_price.build_road_depot); return cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
} }
static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags) static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
@ -908,7 +908,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
DoClearSquare(tile); 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) 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()) { if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
switch (GetRoadTileType(tile)) { switch (GetRoadTileType(tile)) {
case ROAD_TILE_CROSSING: 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; break;
case ROAD_TILE_DEPOT: 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; break;
case ROAD_TILE_NORMAL: { 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); z_new += ApplyFoundationToSlope(GetRoadFoundation(tileh_new, bits), &tileh_new);
/* The surface slope must not be changed */ /* 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; break;

View File

@ -156,7 +156,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
Money Ship::GetRunningCost() const 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() void Ship::OnNewDay()

View File

@ -696,7 +696,7 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla
(HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) { (HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) {
return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
} }
cost.AddCost(_price.terraform); cost.AddCost(_price[PR_TERRAFORM]);
flat_z += TILE_HEIGHT; 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 */ * 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); 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; 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; Station *st = NULL;
ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st); 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) { if (keep_rail) {
/* Don't refund the 'steel' of the track! */ /* 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); TileArea ta(start, end);
SmallVector<Station *, 4> affected_stations; 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; if (ret.Failed()) return ret;
/* Do all station specific functions here. */ /* Do all station specific functions here. */
@ -1372,7 +1372,7 @@ CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint
TileArea ta(start, end); TileArea ta(start, end);
SmallVector<Waypoint *, 4> affected_stations; 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; if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
cost.AddCost(_price.remove_rail_station); cost.AddCost(_price[PR_CLEAR_STATION_RAIL]);
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* read variables before the station tile is removed */ /* read variables before the station tile is removed */
Track track = GetRailStationTrack(tile); 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); CommandCost cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road);
if (CmdFailed(cost)) return cost; if (CmdFailed(cost)) return cost;
uint roadbits_to_build = CountBits(rts) * 2 - num_roadbits; 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; Station *st = NULL;
CommandCost ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 5), TileArea(tile, 1, 1), &st); 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) { if (flags & DC_EXEC) {
RoadStop *road_stop = new RoadStop(tile); RoadStop *road_stop = new RoadStop(tile);
@ -1723,7 +1723,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
DeleteStationIfEmpty(st); 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 /** 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) { if (flags & DC_EXEC) {
/* Always add the noise, so there will be no need to recalculate when option toggles */ /* 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 w = afc->size_x;
int h = afc->size_y; 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; const Aircraft *a;
FOR_ALL_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); 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); DeleteStationIfEmpty(st);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_dock); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_STATION_DOCK]);
} }
#include "table/station_land.h" #include "table/station_land.h"
@ -3234,11 +3234,11 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, ui
DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile)); DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile));
if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break; if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(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: case STATION_AIRPORT:
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_TERRAFORM]);
case STATION_TRUCK: case STATION_TRUCK:
case STATION_BUS: { case STATION_BUS: {
@ -3247,7 +3247,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, ui
if (IsDriveThroughStopTile(tile)) { if (IsDriveThroughStopTile(tile)) {
if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(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]);
} }
default: break; default: break;

View File

@ -14,14 +14,6 @@
#ifndef ENGINES_H #ifndef ENGINES_H
#define 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. /** Writes the properties of a train or road vehicle into the EngineInfo struct.
* @see EngineInfo * @see EngineInfo
* @param a Introduction date * @param a Introduction date
@ -378,6 +370,11 @@ static const EngineInfo _orig_engine_info[] = {
#define O RAILTYPE_MONO #define O RAILTYPE_MONO
#define L RAILTYPE_MAGLEV #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[] = { static const RailVehicleInfo _orig_rail_vehicle_info[] = {
/* image_index max_speed (kph) running_cost engclass /* image_index max_speed (kph) running_cost engclass
* | flags | power (hp) | running_cost_class * | 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(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 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 L
#undef O #undef O
#undef C #undef C
@ -625,7 +626,7 @@ static const AircraftVehicleInfo _orig_aircraft_vehicle_info[] = {
* @param g weight (1/4ton) * @param g weight (1/4ton)
* @param h power (10hp) * @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[] = { static const RoadVehicleInfo _orig_road_vehicle_info[] = {
/* image_index sfx max_speed power /* image_index sfx max_speed power
* | base_cost | | capacity | * | base_cost | | capacity |

View File

@ -10,53 +10,53 @@
/** @file pricebase.h Price Bases */ /** @file pricebase.h Price Bases */
static const PriceBaseSpec _price_base_specs[NUM_PRICES] = { static const PriceBaseSpec _price_base_specs[NUM_PRICES] = {
{ 100, PCAT_NONE }, ///< station_value { 100, PCAT_NONE }, ///< PR_STATION_VALUE
{ 100, PCAT_CONSTRUCTION}, ///< build_rail { 100, PCAT_CONSTRUCTION}, ///< PR_BUILD_RAIL
{ 95, PCAT_CONSTRUCTION}, ///< build_road { 95, PCAT_CONSTRUCTION}, ///< PR_BUILD_ROAD
{ 65, PCAT_CONSTRUCTION}, ///< build_signals { 65, PCAT_CONSTRUCTION}, ///< PR_BUILD_SIGNALS
{ 275, PCAT_CONSTRUCTION}, ///< build_bridge { 275, PCAT_CONSTRUCTION}, ///< PR_BUILD_BRIDGE
{ 600, PCAT_CONSTRUCTION}, ///< build_train_depot { 600, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_TRAIN
{ 500, PCAT_CONSTRUCTION}, ///< build_road_depot { 500, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_ROAD
{ 700, PCAT_CONSTRUCTION}, ///< build_ship_depot { 700, PCAT_CONSTRUCTION}, ///< PR_BUILD_DEPOT_SHIP
{ 450, PCAT_CONSTRUCTION}, ///< build_tunnel { 450, PCAT_CONSTRUCTION}, ///< PR_BUILD_TUNNEL
{ 200, PCAT_CONSTRUCTION}, ///< train_station_track { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_RAIL
{ 180, PCAT_CONSTRUCTION}, ///< train_station_length { 180, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_RAIL_LENGTH
{ 600, PCAT_CONSTRUCTION}, ///< build_airport { 600, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_AIRPORT
{ 200, PCAT_CONSTRUCTION}, ///< build_bus_station { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_BUS
{ 200, PCAT_CONSTRUCTION}, ///< build_truck_station { 200, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_TRUCK
{ 350, PCAT_CONSTRUCTION}, ///< build_dock { 350, PCAT_CONSTRUCTION}, ///< PR_BUILD_STATION_DOCK
{ 400000, PCAT_CONSTRUCTION}, ///< build_railvehicle { 400000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_TRAIN
{ 2000, PCAT_CONSTRUCTION}, ///< build_railwagon { 2000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_WAGON
{ 700000, PCAT_CONSTRUCTION}, ///< aircraft_base { 700000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_AIRCRAFT
{ 14000, PCAT_CONSTRUCTION}, ///< roadveh_base { 14000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_ROAD
{ 65000, PCAT_CONSTRUCTION}, ///< ship_base { 65000, PCAT_CONSTRUCTION}, ///< PR_BUILD_VEHICLE_SHIP
{ 20, PCAT_CONSTRUCTION}, ///< build_trees { 20, PCAT_CONSTRUCTION}, ///< PR_BUILD_TREES
{ 250, PCAT_CONSTRUCTION}, ///< terraform { 250, PCAT_CONSTRUCTION}, ///< PR_TERRAFORM
{ 20, PCAT_CONSTRUCTION}, ///< clear_grass { 20, PCAT_CONSTRUCTION}, ///< PR_CLEAR_GRASS
{ 40, PCAT_CONSTRUCTION}, ///< clear_roughland { 40, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROUGH
{ 200, PCAT_CONSTRUCTION}, ///< clear_rocks { 200, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROCKS
{ 500, PCAT_CONSTRUCTION}, ///< clear_fields { 500, PCAT_CONSTRUCTION}, ///< PR_CLEAR_FILEDS
{ 20, PCAT_CONSTRUCTION}, ///< remove_trees { 20, PCAT_CONSTRUCTION}, ///< PR_CLEAR_TREES
{ -70, PCAT_CONSTRUCTION}, ///< remove_rail { -70, PCAT_CONSTRUCTION}, ///< PR_CLEAR_RAIL
{ 10, PCAT_CONSTRUCTION}, ///< remove_signals { 10, PCAT_CONSTRUCTION}, ///< PR_CLEAR_SIGNALS
{ 50, PCAT_CONSTRUCTION}, ///< clear_bridge { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_BRIDGE
{ 80, PCAT_CONSTRUCTION}, ///< remove_train_depot { 80, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_TRAIN
{ 80, PCAT_CONSTRUCTION}, ///< remove_road_depot { 80, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_ROAD
{ 90, PCAT_CONSTRUCTION}, ///< remove_ship_depot { 90, PCAT_CONSTRUCTION}, ///< PR_CLEAR_DEPOT_SHIP
{ 30, PCAT_CONSTRUCTION}, ///< clear_tunnel { 30, PCAT_CONSTRUCTION}, ///< PR_CLEAR_TUNNEL
{ 10000, PCAT_CONSTRUCTION}, ///< clear_water { 10000, PCAT_CONSTRUCTION}, ///< PR_CLEAR_WATER
{ 50, PCAT_CONSTRUCTION}, ///< remove_rail_station { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_RAIL
{ 30, PCAT_CONSTRUCTION}, ///< remove_airport { 30, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_AIRPORT
{ 50, PCAT_CONSTRUCTION}, ///< remove_bus_station { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_BUS
{ 50, PCAT_CONSTRUCTION}, ///< remove_truck_station { 50, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_TRUCK
{ 55, PCAT_CONSTRUCTION}, ///< remove_dock { 55, PCAT_CONSTRUCTION}, ///< PR_CLEAR_STATION_DOCK
{ 1600, PCAT_CONSTRUCTION}, ///< remove_house { 1600, PCAT_CONSTRUCTION}, ///< PR_CLEAR_HOUSE
{ 40, PCAT_CONSTRUCTION}, ///< remove_road { 40, PCAT_CONSTRUCTION}, ///< PR_CLEAR_ROAD
{ 5600, PCAT_RUNNING }, ///< running_rail[0] steam { 5600, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_STEAM
{ 5200, PCAT_RUNNING }, ///< running_rail[1] diesel { 5200, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_DIESEL
{ 4800, PCAT_RUNNING }, ///< running_rail[2] electric { 4800, PCAT_RUNNING }, ///< PR_RUNNING_TRAIN_ELECTRIC
{ 9600, PCAT_RUNNING }, ///< aircraft_running { 9600, PCAT_RUNNING }, ///< PR_RUNNING_AIRCRAFT
{ 1600, PCAT_RUNNING }, ///< roadveh_running { 1600, PCAT_RUNNING }, ///< PR_RUNNING_ROADVEH
{ 5600, PCAT_RUNNING }, ///< ship_running { 5600, PCAT_RUNNING }, ///< PR_RUNNING_SHIP
{1000000, PCAT_CONSTRUCTION}, ///< build_industry {1000000, PCAT_CONSTRUCTION}, ///< PR_BUILD_INDUSTRY
}; };

View File

@ -187,7 +187,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int
CommandCost total_cost(EXPENSES_CONSTRUCTION); CommandCost total_cost(EXPENSES_CONSTRUCTION);
/* Increment cost */ /* Increment cost */
total_cost.AddCost(_price.terraform); total_cost.AddCost(_price[PR_TERRAFORM]);
/* Recurse to neighboured corners if height difference is larger than 1 */ /* Recurse to neighboured corners if height difference is larger than 1 */
{ {

View File

@ -157,7 +157,7 @@ void Town::InitializeLayout(TownLayout layout)
Money HouseSpec::GetRemovalCost() const Money HouseSpec::GetRemovalCost() const
{ {
return (_price.remove_house * this->removal_cost) >> 8; return (_price[PR_CLEAR_HOUSE] * this->removal_cost) >> 8;
} }
// Local // Local
@ -830,7 +830,7 @@ static bool TerraformTownTile(TileIndex tile, int edges, int dir)
assert(tile < MapSize()); assert(tile < MapSize());
CommandCost r = DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND); 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); DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_TERRAFORM_LAND);
return true; 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])) { if (cid != COMPANY_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[cid])) {
/* Things worth more than this are not shown */ /* Things worth more than this are not shown */
Money avail = Company::Get(cid)->money + _price.station_value * 200; Money avail = Company::Get(cid)->money + _price[PR_STATION_VALUE] * 200;
Money ref = _price.build_industry >> 8; Money ref = _price[PR_BUILD_INDUSTRY] >> 8;
/* Check the action bits for validity and /* Check the action bits for validity and
* if they are valid add them */ * 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; 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) { if (flags & DC_EXEC) {
_town_action_proc[p2](t); _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 ((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]);
} }
} }

View File

@ -175,7 +175,7 @@ public:
switch (widget) { switch (widget) {
case TWA_ACTION_INFO: case TWA_ACTION_INFO:
if (this->sel_index != -1) { 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); 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, 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); STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
@ -214,7 +214,7 @@ public:
size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
Dimension d = {0, 0}; Dimension d = {0, 0};
for (int i = 0; i < TACT_COUNT; i++) { 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); SetDParam(0, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i);
d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size)); d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size));
} }

View File

@ -368,7 +368,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
/* 2x as expensive to add more trees to an existing 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; break;
case MP_WATER: 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)) if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS))
SetTropicZone(tile, TROPICZONE_RAINFOREST); SetTropicZone(tile, TROPICZONE_RAINFOREST);
} }
cost.AddCost(_price.build_trees); cost.AddCost(_price[PR_BUILD_TREES]);
break; break;
default: default:
@ -551,7 +551,7 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) DoClearSquare(tile); 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) static void GetTileDesc_Trees(TileIndex tile, TileDesc *td)

View File

@ -133,7 +133,7 @@ static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, uint *z)
if (f == FOUNDATION_NONE) return CommandCost(); 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(); 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) 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); 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); owner = GetTileOwner(tile_start);
/* Do not remove road types when upgrading a bridge */ /* 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); 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. */ /* 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; return cost;
@ -520,12 +520,12 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
tiles_bump *= 2; 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 cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels
} }
/* Add the cost of the entrance */ /* Add the cost of the entrance */
cost.AddCost(_price.build_tunnel); cost.AddCost(_price[PR_BUILD_TUNNEL]);
cost.AddCost(ret); cost.AddCost(ret);
/* if the command fails from here on we want the end tile to be highlighted */ /* 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); ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret; if (CmdFailed(ret)) return ret;
} }
cost.AddCost(_price.build_tunnel); cost.AddCost(_price[PR_BUILD_TUNNEL]);
cost.AddCost(ret); cost.AddCost(ret);
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -656,7 +656,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
DoClearSquare(endtile); 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) 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? */ /* 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); return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);

View File

@ -23,8 +23,8 @@ struct UnmovableSpec {
uint8 buy_cost_multiplier; uint8 buy_cost_multiplier;
uint8 sell_cost_multiplier; uint8 sell_cost_multiplier;
Money GetRemovalCost() const { return (_price.clear_roughland * this->sell_cost_multiplier); } Money GetRemovalCost() const { return (_price[PR_CLEAR_ROUGH] * this->sell_cost_multiplier); }
Money GetBuildingCost() const { return (_price.clear_roughland * this->buy_cost_multiplier); } Money GetBuildingCost() const { return (_price[PR_CLEAR_ROUGH] * this->buy_cost_multiplier); }
}; };

View File

@ -500,7 +500,7 @@ static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags,
if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost(); if (IsOwnedLand(tile) && CheckTileOwnership(tile)) return CommandCost();
if (AutoslopeEnabled() && (IsStatue(tile) || IsCompanyHQ(tile))) { 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); return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);

View File

@ -267,23 +267,22 @@ static CommandCost GetRefitCost(EngineID engine_type)
const Engine *e = Engine::Get(engine_type); const Engine *e = Engine::Get(engine_type);
switch (e->type) { switch (e->type) {
case VEH_SHIP: case VEH_SHIP:
base_cost = _price.ship_base; base_cost = _price[PR_BUILD_VEHICLE_SHIP];
expense_type = EXPENSES_SHIP_RUN; expense_type = EXPENSES_SHIP_RUN;
break; break;
case VEH_ROAD: case VEH_ROAD:
base_cost = _price.roadveh_base; base_cost = _price[PR_BUILD_VEHICLE_ROAD];
expense_type = EXPENSES_ROADVEH_RUN; expense_type = EXPENSES_ROADVEH_RUN;
break; break;
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
base_cost = _price.aircraft_base; base_cost = _price[PR_BUILD_VEHICLE_AIRCRAFT];
expense_type = EXPENSES_AIRCRAFT_RUN; expense_type = EXPENSES_AIRCRAFT_RUN;
break; break;
case VEH_TRAIN: case VEH_TRAIN:
base_cost = 2 * ((e->u.rail.railveh_type == RAILVEH_WAGON) ? base_cost = 2 * _price[(e->u.rail.railveh_type == RAILVEH_WAGON) ? PR_BUILD_VEHICLE_WAGON : PR_BUILD_VEHICLE_TRAIN];
_price.build_railwagon : _price.build_railvehicle);
expense_type = EXPENSES_TRAIN_RUN; expense_type = EXPENSES_TRAIN_RUN;
break; break;

View File

@ -148,7 +148,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
MarkTileDirtyByTile(tile2); 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) void MakeWaterKeepingClass(TileIndex tile, Owner o)
@ -193,7 +193,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
MarkTileDirtyByTile(tile2); MarkTileDirtyByTile(tile2);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_DEPOT_SHIP]);
} }
/** build a shiplift */ /** build a shiplift */
@ -240,7 +240,7 @@ static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, DoCommandF
MarkCanalsAndRiversAroundDirty(tile + delta); 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) static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
@ -263,7 +263,7 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
MarkCanalsAndRiversAroundDirty(tile + delta); 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) /** Builds a lock (ship-lift)
@ -346,7 +346,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MarkCanalsAndRiversAroundDirty(tile); MarkCanalsAndRiversAroundDirty(tile);
} }
cost.AddCost(_price.clear_water); cost.AddCost(_price[PR_CLEAR_WATER]);
} }
if (cost.GetCost() == 0) { if (cost.GetCost() == 0) {
@ -377,7 +377,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
DoClearSquare(tile); DoClearSquare(tile);
MarkCanalsAndRiversAroundDirty(tile); MarkCanalsAndRiversAroundDirty(tile);
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER]);
case WATER_TILE_COAST: { case WATER_TILE_COAST: {
Slope slope = GetTileSlope(tile, NULL); Slope slope = GetTileSlope(tile, NULL);
@ -390,9 +390,9 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
MarkCanalsAndRiversAroundDirty(tile); MarkCanalsAndRiversAroundDirty(tile);
} }
if (IsSlopeWithOneCornerRaised(slope)) { if (IsSlopeWithOneCornerRaised(slope)) {
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER]);
} else { } else {
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_roughland); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_ROUGH]);
} }
} }

View File

@ -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. /** Build a buoy.
@ -366,7 +366,7 @@ CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); 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; wp->delete_ctr = 0;
} }
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_truck_station); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_STATION_TRUCK]);
} }