OpenTTD Source
20241108-master-g80f628063a
|
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, StringID extra_msg=INVALID_STRING_ID) | |
Creates a command return value with one, or optionally two, error message strings. | |
CommandCost (ExpensesType ex_t) | |
Creates a command cost with given expense type and start cost of 0. More... | |
CommandCost (ExpensesType ex_t, const Money &cst) | |
Creates a command return value with the given start cost and expense type. More... | |
void | AddCost (const Money &cost) |
Adds the given cost to the cost of the command. More... | |
void | AddCost (const CommandCost &cmd_cost) |
Adds the cost of the given command return value to this cost. More... | |
void | MultiplyCost (int factor) |
Multiplies the cost of the command by the given factor. More... | |
Money | GetCost () const |
The costs as made up to this moment. More... | |
ExpensesType | GetExpensesType () const |
The expense type of the cost. More... | |
void | MakeError (StringID message, StringID extra_message=INVALID_STRING_ID) |
Makes this CommandCost behave like an error command. More... | |
void | UseTextRefStack (const GRFFile *grffile, uint num_registers) |
Activate usage of the NewGRF TextRefStack for the error message. More... | |
const GRFFile * | GetTextRefStackGRF () const |
Returns the NewGRF providing the TextRefStack of the error message. More... | |
uint | GetTextRefStackSize () const |
Returns the number of uint32_t values for the TextRefStack of the error message. More... | |
const uint32_t * | GetTextRefStack () const |
Returns a pointer to the values for the TextRefStack of the error message. More... | |
StringID | GetErrorMessage () const |
Returns the error message of a command. More... | |
StringID | GetExtraErrorMessage () const |
Returns the extra error message of a command. More... | |
bool | Succeeded () const |
Did this command succeed? More... | |
bool | Failed () const |
Did this command fail? More... | |
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 command went fine up to this moment. | |
const GRFFile * | textref_stack_grffile |
NewGRF providing the TextRefStack content. | |
uint | textref_stack_size |
Number of uint32_t values to put on the TextRefStack for the error message. | |
StringID | extra_message = INVALID_STRING_ID |
Additional warning message for when success is unset. | |
Static Private Attributes | |
static uint32_t | textref_stack [16] |
Values to put on the TextRefStack for the error message. More... | |
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.
|
inlineexplicit |
Creates a command cost with given expense type and start cost of 0.
ex_t | the expense type |
Definition at line 49 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 56 of file command_type.h.
void CommandCost::AddCost | ( | const CommandCost & | ret | ) |
|
inline |
Adds the given cost to the cost of the command.
cost | the cost to add |
Definition at line 63 of file command_type.h.
References cost.
Referenced by AddCost(), CalculateRoadStopCost(), CheckBuildableTile(), CheckFlatLandAirport(), CheckFlatLandRoadStop(), CmdAutoreplaceVehicle(), CmdBuildLongRoad(), CmdBuildObjectArea(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), CmdClearArea(), CmdConvertRail(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLandscapeClear(), CmdLevelLand(), CmdSellRailWagon(), CmdTerraformLand(), CompaniesGenStatistics(), CopyHeadSpecificThings(), DoBuildLock(), RemoveAirport(), RemoveFromRailBaseStation(), and ReplaceFreeUnit().
|
inline |
Did this command fail?
Definition at line 171 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), BuildStationPart(), CalculateRoadStopCost(), CheckBuildableTile(), CheckFlatLandAirport(), CheckFlatLandRoadStop(), CheckIfIndustryTilesAreFree(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildLongRoad(), CmdBuildObjectArea(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdConvertRail(), CmdDeleteOrder(), CmdForceTrainProceed(), CmdInsertOrder(), CmdLevelLand(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdRefitVehicle(), CmdRenameDepot(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellRailWagon(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTurnRoadVeh(), DoBuildLock(), DoClearBridge(), DoClearTunnel(), CommandHelperBase::InternalExecuteProcessResult(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), IsRoadAllowedHere(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveLock(), RemoveRoadStop(), RemoveRoadWaypointStop(), Vehicle::SendToDepot(), ShowBuildBridgeWindow(), and ValidateTrains().
|
inline |
The costs as made up to this moment.
Definition at line 83 of file command_type.h.
References cost.
Referenced by CheckCompanyHasMoney(), CmdAutoreplaceVehicle(), CmdBuildObjectArea(), CmdClearArea(), CmdGiveMoney(), CmdLevelLand(), CommandHelperBase::InternalExecuteProcessResult(), SubtractMoneyFromAnyCompany(), and SubtractMoneyFromCompanyFract().
|
inline |
Returns the error message of a command.
Definition at line 142 of file command_type.h.
References INVALID_STRING_ID, and message.
Referenced by CmdBuildLongRoad(), CmdLevelLand(), and ShowBuildBridgeWindow().
|
inline |
The expense type of the cost.
Definition at line 92 of file command_type.h.
References expense_type.
Referenced by SubtractMoneyFromAnyCompany(), and SubtractMoneyFromCompanyFract().
|
inline |
Returns the extra error message of a command.
Definition at line 152 of file command_type.h.
References extra_message, and INVALID_STRING_ID.
|
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.
|
inline |
Returns the NewGRF providing the TextRefStack of the error message.
Definition at line 115 of file command_type.h.
References textref_stack_grffile.
|
inline |
Returns the number of uint32_t values for the TextRefStack of the error message.
Definition at line 124 of file command_type.h.
References textref_stack_size.
|
inline |
Makes this CommandCost behave like an error command.
message | The error message. |
Definition at line 101 of file command_type.h.
References extra_message, INVALID_STRING_ID, and message.
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 74 of file command_type.h.
|
inline |
Did this command succeed?
Definition at line 162 of file command_type.h.
References success.
Referenced by CanBuildTramTrackOnTile(), CheckClearTile(), ClearMakeHouseTile(), CmdAutoreplaceVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLevelLand(), CopyHeadSpecificThings(), DoBuildLock(), CommandHelperBase::InternalDoAfter(), RemoveDock(), RemoveLock(), ReplaceFreeUnit(), and SendAllVehiclesToDepot().
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 422 of file command.cpp.
|
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 32 of file command_type.h.
Referenced by GetTextRefStack().