Mercurial > hg > openttd
diff src/train_cmd.cpp @ 8230:5b61305fcdd4 draft
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 09 Jan 2008 16:55:48 +0000 |
parents | 8bef722f6199 |
children | d1191295967a |
line wrap: on
line diff
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -511,10 +511,8 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) { - SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); - const RailVehicleInfo *rvi = RailVehInfo(engine); - CommandCost value((GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); + CommandCost value(EXPENSES_NEW_VEHICLES, (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8); uint num_vehicles = 1 + CountArticulatedParts(engine, false); @@ -600,7 +598,7 @@ } } - return CommandCost(value); + return value; } /** Move all free vehicles in the depot to the train */ @@ -621,7 +619,7 @@ static CommandCost EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi) { - return CommandCost(GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); + return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5); } static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool building) @@ -671,8 +669,6 @@ if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; } - SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); - const RailVehicleInfo *rvi = RailVehInfo(p1); /* Check if depot and new engine uses the same kind of tracks */ @@ -1313,8 +1309,6 @@ if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); - SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); - while (IsArticulatedPart(v)) v = v->Previous(); Vehicle *first = v->First(); @@ -1334,7 +1328,7 @@ RebuildVehicleLists(); } - CommandCost cost; + CommandCost cost(EXPENSES_NEW_VEHICLES); switch (p2) { case 0: case 2: { /* Delete given wagon */ bool switch_engine = false; // update second wagon to engine? @@ -1804,9 +1798,7 @@ /* Check cargo */ if (new_cid >= NUM_CARGO) return CMD_ERROR; - SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN); - - CommandCost cost; + CommandCost cost(EXPENSES_TRAIN_RUN); uint num = 0; do { @@ -3481,11 +3473,10 @@ if ((v->vehstatus & VS_STOPPED) == 0) { /* running costs */ - CommandCost cost(v->GetRunningCost() / 364); + CommandCost cost(EXPENSES_TRAIN_RUN, v->GetRunningCost() / 364); v->profit_this_year -= cost.GetCost() >> 8; - SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN); SubtractMoneyFromPlayerFract(v->owner, cost); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);