OpenTTD
|
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. | |
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. | |
void | 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 | MakeError (StringID message) |
Makes this CommandCost behave like an error command. | |
void | UseTextRefStack (const GRFFile *grffile, uint num_registers) |
Activate usage of the NewGRF TextRefStack for the error message. | |
const GRFFile * | GetTextRefStackGRF () const |
Returns the NewGRF providing the TextRefStack of the error message. | |
uint | GetTextRefStackSize () const |
Returns the number of uint32 values for the TextRefStack of the error message. | |
const uint32 * | GetTextRefStack () const |
Returns a pointer to the values for the TextRefStack of the error message. | |
StringID | GetErrorMessage () const |
Returns the error message of a command. | |
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. | |
const GRFFile * | textref_stack_grffile |
NewGRF providing the TextRefStack content. | |
uint | textref_stack_size |
Number of uint32 values to put on the TextRefStack for the error message. |
Static Private Attributes | |
static uint32 | textref_stack [16] |
Values to put on the TextRefStack for the error message. |
Common return value for all commands.
Wraps the cost and a possible error message/state together.
Definition at line 25 of file command_type.h.
|
inlineexplicit |
Creates a command cost with given expense type and start cost of 0.
ex_t | the expense type |
Definition at line 50 of file command_type.h.
|
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 57 of file command_type.h.
|
inline |
Adds the given cost to the cost of the command.
cost | the cost to add |
Definition at line 64 of file command_type.h.
References cost.
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(), CompaniesGenStatistics(), CopyHeadSpecificThings(), DoBuildLock(), RemoveAirport(), RemoveFromRailBaseStation(), RemoveRailStation(), RemoveRoad(), TerraformTileHeight(), and TestAutoslopeOnRailTile().
void CommandCost::AddCost | ( | const CommandCost & | ret | ) |
|
inline |
Did this command fail?
Definition at line 161 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), BuildStationPart(), CcAddVehicleNewGroup(), CcBuildBridge(), CcBuildPrimaryVehicle(), CcBuildWagon(), CcCloneVehicle(), CcCreateGroup(), CcPlaceSign(), CcRoadStop(), CcStartStopVehicle(), CheckAllowRemoveRoad(), CheckBuildableTile(), CheckFlatLand(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CheckIfIndustryTilesAreFree(), CmdAddVehicleGroup(), 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(), CmdOpenCloseAirport(), 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(), ScriptInstance::DoCommandCallback(), DoCommandP(), DoCommandPInternal(), ExploreSegment(), FindJoiningBaseStation(), RefitWindow::GetCapacityString(), IsRoadAllowedHere(), IsValidTileForWaypoint(), NormalizeTrainVehInDepot(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRailStation(), RemoveRoad(), RemoveRoadStop(), ReplaceChain(), Vehicle::SendToDepot(), ShowBuildBridgeWindow(), StationJoinerNeeded(), TerraformTileHeight(), ValidateTrains(), and VehicleEnterDepot().
|
inline |
The costs as made up to this moment.
Definition at line 84 of file command_type.h.
References cost.
Referenced by CheckCompanyHasMoney(), CmdAutoreplaceVehicle(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildRoad(), CmdBuildTunnel(), CmdClearArea(), CmdConvertRail(), CmdFoundTown(), CmdGiveMoney(), CmdLevelLand(), CmdPlantTree(), CmdRemoveLongRoad(), ScriptInstance::DoCommandCallback(), DoCommandP(), DoCommandPInternal(), RefitWindow::GetCapacityString(), HandleStationRefit(), LandInfoWindow::OnInit(), Ship::OnNewDay(), Aircraft::OnNewDay(), RoadVehicle::OnNewDay(), Train::OnNewDay(), ReplaceChain(), ShowBuildBridgeWindow(), SubtractMoneyFromAnyCompany(), SubtractMoneyFromCompanyFract(), and VehicleEnterDepot().
|
inline |
Returns the error message of a command.
Definition at line 142 of file command_type.h.
References INVALID_STRING_ID, message, and success.
Referenced by CcBuildIndustry(), CmdBuildLongRoad(), CmdLevelLand(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), ScriptInstance::DoCommandCallback(), DoCommandP(), ReplaceChain(), and ShowBuildBridgeWindow().
|
inline |
The expense type of the cost.
Definition at line 93 of file command_type.h.
References expense_type.
Referenced by SubtractMoneyFromAnyCompany(), and SubtractMoneyFromCompanyFract().
|
inline |
Returns a pointer to the values for the TextRefStack of the error message.
Definition at line 133 of file command_type.h.
References textref_stack.
Referenced by DoCommandP().
|
inline |
Returns the NewGRF providing the TextRefStack of the error message.
Definition at line 115 of file command_type.h.
References textref_stack_grffile.
Referenced by DoCommandP().
|
inline |
Returns the number of uint32 values for the TextRefStack of the error message.
Definition at line 124 of file command_type.h.
References textref_stack_size.
Referenced by DoCommandP().
|
inline |
Makes this CommandCost behave like an error command.
message | The error message. |
Definition at line 102 of file command_type.h.
References INVALID_STRING_ID, message, and success.
Referenced by CheckCompanyHasMoney(), and CmdConvertRail().
|
inline |
Multiplies the cost of the command by the given factor.
factor | factor to multiply the costs with |
Definition at line 75 of file command_type.h.
References cost.
Referenced by CmdFoundTown().
|
inline |
Did this command succeed?
Definition at line 152 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), CanBuildHouseHere(), CanBuildTramTrackOnTile(), CcBuildIndustry(), CcBuildRailTunnel(), CcBuildRoadTunnel(), CheckAllowRemoveTunnelBridge(), ClearMakeHouseTile(), CmdAutoreplaceVehicle(), CmdBuildIndustry(), CmdBuildSingleRail(), CmdCloneVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdRemoveLongRoad(), CopyHeadSpecificThings(), DoBuildLock(), ScriptInstance::DoCommandCallback(), DoCommandP(), FloodHalftile(), GrowTown(), GrowTownWithRoad(), HandleStationRefit(), IsValidTileForWaypoint(), LandInfoWindow::OnInit(), RemoveDock(), RemoveLock(), ReplaceChain(), SendAllVehiclesToDepot(), ShowBuildBridgeWindow(), and TryClearTile().
void CommandCost::UseTextRefStack | ( | const GRFFile * | grffile, |
uint | num_registers | ||
) |
Activate usage of the NewGRF TextRefStack for the error message.
grffile | NewGRF that provides the TextRefStack |
num_registers | number of entries to copy from the temporary NewGRF registers |
Definition at line 795 of file command.cpp.
References TemporaryStorageArray< TYPE, SIZE >::GetValue(), lengthof, textref_stack, textref_stack_grffile, and textref_stack_size.
Referenced by GetErrorMessageFromLocationCallbackResult().
|
staticprivate |
Values to put on the TextRefStack for the error message.
There is only one static instance of the array, just like there is only one instance of normal DParams.
Definition at line 33 of file command_type.h.
Referenced by GetTextRefStack(), and UseTextRefStack().