summaryrefslogtreecommitdiff
path: root/src/aircraft_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-18 19:53:50 +0000
committerrubidium <rubidium@openttd.org>2007-06-18 19:53:50 +0000
commit49220cc6f1e3570dc1b9001c40af2a8a4e35b649 (patch)
tree62843984493ffedb69f91d7b85cb631ecb61ff3e /src/aircraft_cmd.cpp
parent3771d666c0e6bb48980b7548a2b38b3594efb3ff (diff)
downloadopenttd-49220cc6f1e3570dc1b9001c40af2a8a4e35b649.tar.xz
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index de5c27ea1..5215b4a0e 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -229,7 +229,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
{
- return GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5;
+ return CommandCost(GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
}
@@ -346,7 +346,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->subtype = (avi->subtype & AIR_CTOL ? AIR_AIRCRAFT : AIR_HELICOPTER);
v->UpdateDeltaXY(INVALID_DIR);
- v->value = value;
+ v->value = (uint32)value.GetCost();
u->subtype = AIR_SHADOW;
u->UpdateDeltaXY(INVALID_DIR);
@@ -493,7 +493,7 @@ CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
DoDeleteAircraft(v);
}
- return -(int32)v->value;
+ return CommandCost(-(int32)v->value);
}
/** Start/Stop an aircraft.
@@ -534,7 +534,7 @@ CommandCost CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32
InvalidateWindowClasses(WC_AIRCRAFT_LIST);
}
- return 0;
+ return CommandCost();
}
/** Send an aircraft to the hangar.
@@ -569,7 +569,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
- return 0;
+ return CommandCost();
}
if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
@@ -609,7 +609,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
}
}
- return 0;
+ return CommandCost();
}
@@ -668,7 +668,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
_returned_refit_capacity = pass;
- CommandCost cost = 0;
+ CommandCost cost;
if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
cost = GetRefitCost(v->engine_type);
}
@@ -744,9 +744,9 @@ void OnNewDay_Aircraft(Vehicle *v)
if (v->vehstatus & VS_STOPPED) return;
- CommandCost cost = GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364;
+ CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
- v->profit_this_year -= cost >> 8;
+ v->profit_this_year -= cost.GetCost() >> 8;
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
SubtractMoneyFromPlayerFract(v->owner, cost);