#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, Money cst) | |
Creates a command return value with the given start cost and expense type. | |
CommandCost | AddCost (CommandCost ret) |
Adds the cost of the given command return value to this cost. | |
CommandCost | AddCost (Money cost) |
Adds the given cost to the cost of the command. | |
CommandCost | MultiplyCost (int factor) |
Multiplies the cost of the command by the given factor. | |
Money | GetCost () const |
The costs as made up to this moment. | |
ExpensesType | GetExpensesType () const |
The expense type of the cost. | |
void | SetGlobalErrorMessage () const |
Sets the global error message *if* this class has one. | |
bool | Succeeded () const |
Did this command succeed? | |
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. |
Wraps the cost and a possible error message/state together.
Definition at line 16 of file command_type.h.
CommandCost::CommandCost | ( | ExpensesType | ex_t | ) | [inline] |
Creates a command cost with given expense type and start cost of 0.
ex_t | the expense type |
Definition at line 37 of file command_type.h.
CommandCost::CommandCost | ( | ExpensesType | ex_t, | |
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 44 of file command_type.h.
CommandCost CommandCost::AddCost | ( | CommandCost | ret | ) |
Adds the cost of the given command return value to this cost.
Also takes a possible error message when it is set.
ret | the command to add the cost of. |
Definition at line 669 of file command.cpp.
References cost, message, and success.
Referenced by CheckFlatLandBelow(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildCompanyHQ(), CmdBuildLongRoad(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuyShareInCompany(), CmdClearArea(), CmdCloneVehicle(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLevelLand(), CmdPlantTree(), CmdPurchaseLandArea(), CmdRailTrackHelper(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRemoveLongRoad(), CmdRemoveSingleRail(), CmdSellRailWagon(), CmdSignalTrackHelper(), CmdTerraformLand(), RemoveRoad(), TerraformTileHeight(), and TestAutoslopeOnRailTile().
CommandCost CommandCost::AddCost | ( | Money | cost | ) |
Adds the given cost to the cost of the command.
cost | the cost to add |
Definition at line 679 of file command.cpp.
CommandCost CommandCost::MultiplyCost | ( | int | factor | ) |
Multiplies the cost of the command by the given factor.
cost | factor to multiply the costs with |
Definition at line 685 of file command.cpp.
References cost.
Referenced by CmdBuildRoad().
Money CommandCost::GetCost | ( | ) | const |
The costs as made up to this moment.
Definition at line 691 of file command.cpp.
References cost.
Referenced by CmdBuildAircraft(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildRailroadStation(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoad(), CmdBuildRoadVeh(), CmdBuildShip(), CmdBuildTunnel(), CmdClearArea(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdGiveMoney(), CmdLevelLand(), CmdPlantTree(), CmdRailTrackHelper(), CmdRemoveLongRoad(), DoCommand(), and DoCommandP().
ExpensesType CommandCost::GetExpensesType | ( | ) | const |
The expense type of the cost.
Definition at line 696 of file command.cpp.
References expense_type.
bool CommandCost::Succeeded | ( | ) | const |
Did this command succeed?
Definition at line 707 of file command.cpp.
References success.
Referenced by CmdSucceeded().
bool CommandCost::Failed | ( | ) | const |
Did this command fail?
Definition at line 712 of file command.cpp.
References success.
Referenced by CmdFailed().