Common return value for all commands. More...
#include <command_type.h>
Public Member Functions | |
CommandCost () | |
Creates a command cost return with no cost and no error. | |
CommandCost (StringID msg) | |
Creates a command return value the is failed with the given message. | |
CommandCost (ExpensesType ex_t) | |
Creates a command cost with given expense type and start cost of 0. | |
CommandCost (ExpensesType ex_t, const Money &cst) | |
Creates a command return value with the given start cost and expense type. | |
FORCEINLINE void | AddCost (const Money &cost) |
Adds the given cost to the cost of the command. | |
void | AddCost (const CommandCost &cmd_cost) |
Adds the cost of the given command return value to this cost. | |
FORCEINLINE void | MultiplyCost (int factor) |
Multiplies the cost of the command by the given factor. | |
FORCEINLINE Money | GetCost () const |
The costs as made up to this moment. | |
FORCEINLINE ExpensesType | GetExpensesType () const |
The expense type of the cost. | |
void | MakeError (StringID message) |
Makes this CommandCost behave like an error command. | |
StringID | GetErrorMessage () const |
Returns the error message of a command. | |
FORCEINLINE bool | Succeeded () const |
Did this command succeed? | |
FORCEINLINE bool | Failed () const |
Did this command fail? | |
Private Attributes | |
ExpensesType | expense_type |
the type of expence as shown on the finances view | |
Money | cost |
The cost of this action. | |
StringID | message |
Warning message for when success is unset. | |
bool | success |
Whether the comment went fine up to this moment. |
Common return value for all commands.
Wraps the cost and a possible error message/state together.
Definition at line 23 of file command_type.h.
CommandCost::CommandCost | ( | ExpensesType | ex_t | ) | [inline, explicit] |
Creates a command cost with given expense type and start cost of 0.
ex_t | the expense type |
Definition at line 44 of file command_type.h.
CommandCost::CommandCost | ( | ExpensesType | ex_t, | |
const Money & | cst | |||
) | [inline] |
Creates a command return value with the given start cost and expense type.
ex_t | the expense type | |
cst | the initial cost of this command |
Definition at line 51 of file command_type.h.
void CommandCost::AddCost | ( | const CommandCost & | ret | ) |
FORCEINLINE void CommandCost::AddCost | ( | const Money & | cost | ) | [inline] |
Adds the given cost to the cost of the command.
cost | the cost to add |
Definition at line 58 of file command_type.h.
Referenced by AddCost(), BuildReplacementVehicle(), CheckBuildableTile(), CheckFlatLand(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CmdAutoreplaceVehicle(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailStation(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuyShareInCompany(), CmdClearArea(), CmdCloneVehicle(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLandscapeClear(), CmdLevelLand(), CmdPlantTree(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), CmdRemoveSingleRail(), CmdSellRailWagon(), CmdSignalTrackHelper(), CmdTerraformLand(), CopyHeadSpecificThings(), DoBuildLock(), AIObject::IncreaseDoCommandCosts(), RemoveAirport(), RemoveFromRailBaseStation(), RemoveRailStation(), RemoveRoad(), TerraformTileHeight(), and TestAutoslopeOnRailTile().
FORCEINLINE bool CommandCost::Failed | ( | ) | const [inline] |
Did this command fail?
Definition at line 126 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), CcAI(), CcBuildPrimaryVehicle(), CcCloneVehicle(), CcCreateGroup(), CcPlaceSign(), CcRoadStop(), CcStartStopVehicle(), CheckAllowRemoveRoad(), CheckBuildableTile(), CheckFlatLand(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CheckIfIndustryTilesAreFree(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildIndustry(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdConvertRail(), CmdDeleteOrder(), CmdDeleteTown(), CmdDoTownAction(), CmdForceTrainProceed(), CmdFoundTown(), CmdInsertOrder(), CmdLevelLand(), CmdModifyOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOrderRefit(), CmdPlantTree(), CmdRailTrackHelper(), CmdRefitVehicle(), CmdRemoveFromRailStation(), CmdRemoveRoadStop(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdRenameDepot(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellRailWagon(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSignalTrackHelper(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTerraformLand(), CmdTurnRoadVeh(), CreateNewIndustry(), CreateNewIndustryHelper(), DoBuildLock(), DoClearBridge(), DoClearTunnel(), DoCommand(), AIObject::DoCommand(), DoCommandP(), DoCommandPInternal(), ExploreSegment(), FindJoiningBaseStation(), RefitWindow::GetCapacityString(), IsRoadAllowedHere(), IsValidTileForWaypoint(), NormalizeTrainVehInDepot(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRailStation(), RemoveRoad(), RemoveRoadStop(), SearchTileForStatue(), Vehicle::SendToDepot(), ShowBuildBridgeWindow(), StationJoinerNeeded(), TerraformTileHeight(), and ValidateTrains().
FORCEINLINE Money CommandCost::GetCost | ( | ) | const [inline] |
The costs as made up to this moment.
Definition at line 78 of file command_type.h.
References cost.
Referenced by CcAI(), CheckCompanyHasMoney(), CmdAutoreplaceVehicle(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildRoad(), CmdBuildTunnel(), CmdClearArea(), CmdConvertRail(), CmdFoundTown(), CmdGiveMoney(), CmdLevelLand(), CmdPlantTree(), CmdRemoveLongRoad(), AIObject::DoCommand(), DoCommandP(), DoCommandPInternal(), RefitWindow::GetCapacityString(), AIObject::GetDoCommandCosts(), Train::OnNewDay(), Ship::OnNewDay(), RoadVehicle::OnNewDay(), Aircraft::OnNewDay(), ReplaceChain(), ShowBuildBridgeWindow(), SubtractMoneyFromAnyCompany(), and SubtractMoneyFromCompanyFract().
StringID CommandCost::GetErrorMessage | ( | ) | const [inline] |
Returns the error message of a command.
Definition at line 107 of file command_type.h.
References INVALID_STRING_ID, message, and success.
Referenced by CcAI(), CcBuildIndustry(), CmdBuildLongRoad(), CmdLevelLand(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), AIObject::DoCommand(), DoCommandP(), and ShowBuildBridgeWindow().
FORCEINLINE ExpensesType CommandCost::GetExpensesType | ( | ) | const [inline] |
The expense type of the cost.
Definition at line 87 of file command_type.h.
References expense_type.
Referenced by SubtractMoneyFromAnyCompany(), and SubtractMoneyFromCompanyFract().
void CommandCost::MakeError | ( | StringID | message | ) | [inline] |
Makes this CommandCost behave like an error command.
message | The error message. |
Definition at line 96 of file command_type.h.
References INVALID_STRING_ID, and success.
Referenced by CheckCompanyHasMoney(), and CmdConvertRail().
FORCEINLINE void CommandCost::MultiplyCost | ( | int | factor | ) | [inline] |
Multiplies the cost of the command by the given factor.
factor | factor to multiply the costs with |
Definition at line 69 of file command_type.h.
References cost.
Referenced by CmdBuildRoad(), and CmdFoundTown().
FORCEINLINE bool CommandCost::Succeeded | ( | ) | const [inline] |
Did this command succeed?
Definition at line 117 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), CanBuildHouseHere(), CanBuildTramTrackOnTile(), CanRemoveRoadWithStop(), CcAI(), CcBuildBridge(), CcBuildIndustry(), CcBuildRailTunnel(), CheckAllowRemoveTunnelBridge(), ClearMakeHouseTile(), CmdAutoreplaceVehicle(), CmdBuildIndustry(), CmdBuildSingleRail(), CmdCloneVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), CopyHeadSpecificThings(), DoCommandP(), FloodHalftile(), AIVehicle::GetRefitCapacity(), GrowTown(), GrowTownWithRoad(), IsValidTileForWaypoint(), RemoveDock(), RemoveLock(), ReplaceChain(), SendAllVehiclesToDepot(), and ShowBuildBridgeWindow().