OpenTTD Source 20250312-master-gcdcc6b491d
|
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. | |
CommandCost (ExpensesType ex_t, const Money &cst) | |
Creates a command return value with the given start cost and expense type. | |
void | SetErrorOwner (Owner owner) |
Set the 'owner' (the originator) of this error message. | |
CompanyID | GetErrorOwner () const |
Get the originator owner for this error. | |
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. | |
StringID | GetErrorMessage () const |
Returns the error message of a command. | |
StringID | GetExtraErrorMessage () const |
Returns the extra error message of a command. | |
bool | Succeeded () const |
Did this command succeed? | |
bool | Failed () const |
Did this command fail? | |
Static Public Member Functions | |
static void | SetEncodedMessage (EncodedString &&message) |
Set the encoded message string. | |
static EncodedString & | GetEncodedMessage () |
Get the last encoded error message. | |
Private Attributes | |
Money | cost |
The cost of this action. | |
StringID | message |
Warning message for when success is unset. | |
ExpensesType | expense_type |
the type of expence as shown on the finances view | |
bool | success |
Whether the command went fine up to this moment. | |
Owner | owner = CompanyID::Invalid() |
Originator owner of error. | |
StringID | extra_message = INVALID_STRING_ID |
Additional warning message for when success is unset. | |
Static Private Attributes | |
static EncodedString | encoded_message |
Encoded error message, used if the error message includes parameters. | |
Common return value for all commands.
Wraps the cost and a possible error message/state together.
Definition at line 24 of file command_type.h.
|
inline |
Creates a command cost return with no cost and no error.
Definition at line 38 of file command_type.h.
|
inlineexplicit |
Creates a command return value with one, or optionally two, error message strings.
Definition at line 43 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 99 of file command_type.h.
References cost.
Referenced by AddCost(), BuildReplacementVehicle(), CalculateRailStationCost(), CalculateRoadStopCost(), CheckBuildableTile(), CheckFlatLandAirport(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), ClearTile_Town(), CmdAutoreplaceVehicle(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildObjectArea(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBuildVehicle(), CmdClearArea(), CmdCloneVehicle(), CmdConvertRail(), CmdConvertRoad(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLandscapeClear(), CmdLevelLand(), CmdPlantTree(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdRemoveSingleRail(), CmdSellRailWagon(), CmdSignalTrackHelper(), CmdTerraformLand(), CompaniesGenStatistics(), CopyHeadSpecificThings(), DoBuildLock(), RefitVehicle(), RemoveAirport(), RemoveFromRailBaseStation(), RemoveGenericRoadStop(), RemoveRailStation(), RemoveRoad(), ReplaceChain(), ReplaceFreeUnit(), TerraformTileHeight(), and TestAutoslopeOnRailTile().
|
inline |
Did this command fail?
Definition at line 178 of file command_type.h.
References success.
Referenced by BuildReplacementVehicle(), BuildStationPart(), CalculateRailStationCost(), CalculateRoadStopCost(), CanRemoveRoadWithStop(), CcAddVehicleNewGroup(), CcBuildBridge(), CcBuildPrimaryVehicle(), CcBuildWagon(), CcCloneVehicle(), CcCreateGroup(), CcPlaceSign(), CcRoadStop(), CcStartStopVehicle(), CheckAllowRemoveRoad(), CheckBuildableTile(), CheckFlatLandAirport(), CheckFlatLandRailStation(), CheckFlatLandRoadStop(), CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), ClearTile_Station(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildAirport(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildIndustry(), CmdBuildLongRoad(), CmdBuildObject(), CmdBuildObjectArea(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), CmdBuildShipDepot(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdBulkChangeTimetable(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdClearArea(), CmdCloneOrder(), CmdCloneVehicle(), CmdConvertRail(), CmdConvertRoad(), CmdDeleteOrder(), CmdDeleteTown(), CmdDoTownAction(), CmdForceTrainProceed(), CmdFoundTown(), CmdInsertOrder(), CmdLevelLand(), CmdModifyOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdPlantTree(), CmdRailTrackHelper(), CmdRefitVehicle(), CmdRemoveFromRailStation(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdRenameDepot(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellRailWagon(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSignalTrackHelper(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTerraformLand(), CmdTurnRoadVeh(), CreateNewIndustry(), CreateNewIndustryHelper(), DoBuildLock(), DoClearBridge(), DoClearTunnel(), ScriptInstance::DoCommandCallback(), ExploreSegment(), FindJoiningBaseStation(), CommandHelperBase::InternalExecuteProcessResult(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), CommandHelperBase::InternalPostResult(), IsRoadAllowedHere(), IsValidTileForWaypoint(), RemoveAirport(), RemoveBuoy(), RemoveDock(), RemoveFromRailBaseStation(), RemoveGenericRoadStop(), RemoveLock(), RemoveRailStation(), RemoveRoad(), RemoveRoadStop(), RemoveRoadWaypointStop(), ReplaceChain(), Vehicle::SendToDepot(), ShowBuildBridgeWindow(), ValidateTrains(), and VehicleEnterDepot().
|
inline |
The costs as made up to this moment.
Definition at line 119 of file command_type.h.
References cost.
Referenced by CheckCompanyHasMoney(), CmdAutoreplaceVehicle(), CmdBuildBridge(), CmdBuildCanal(), CmdBuildObjectArea(), CmdBuildRoad(), CmdBuildTunnel(), CmdBuildVehicle(), CmdClearArea(), CmdFoundTown(), CmdGiveMoney(), CmdLevelLand(), CmdPlantTree(), CmdRemoveLongRoad(), ScriptInstance::DoCommandCallback(), HandleStationRefit(), CommandHelperBase::InternalExecuteProcessResult(), CommandHelperBase::InternalPostResult(), Aircraft::OnNewEconomyDay(), RoadVehicle::OnNewEconomyDay(), Ship::OnNewEconomyDay(), Train::OnNewEconomyDay(), ReplaceChain(), ShowBuildBridgeWindow(), SubtractMoneyFromAnyCompany(), SubtractMoneyFromCompanyFract(), and VehicleEnterDepot().
|
inlinestatic |
Get the last encoded error message.
Definition at line 82 of file command_type.h.
References encoded_message.
Referenced by ShowErrorMessage().
|
inline |
Returns the error message of a command.
Definition at line 149 of file command_type.h.
References INVALID_STRING_ID, and message.
Referenced by CcBuildIndustry(), CmdBuildLongRoad(), CmdLevelLand(), CmdRailTrackHelper(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), ScriptInstance::DoCommandCallback(), ReplaceChain(), ShowBuildBridgeWindow(), and ShowErrorMessage().
|
inline |
Get the originator owner for this error.
Definition at line 90 of file command_type.h.
References owner.
Referenced by ShowErrorMessage().
|
inline |
The expense type of the cost.
Definition at line 128 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 159 of file command_type.h.
References extra_message, and INVALID_STRING_ID.
Referenced by ShowErrorMessage().
|
inline |
Makes this CommandCost behave like an error command.
message | The error message. |
Definition at line 137 of file command_type.h.
References INVALID_STRING_ID, and message.
Referenced by CheckCompanyHasMoney(), CmdConvertRail(), and CmdConvertRoad().
|
inline |
Multiplies the cost of the command by the given factor.
factor | factor to multiply the costs with |
Definition at line 110 of file command_type.h.
Referenced by CmdFoundTown().
|
inlinestatic |
Set the encoded message string.
If set, this is used by the error message window instead of the error StringID, to allow more information to be displayed to the local player.
message | EncodedString message to set. |
Definition at line 73 of file command_type.h.
References encoded_message, and message.
Referenced by CheckCompanyHasMoney(), CmdConvertRoad(), CommandCostWithParam(), and GetErrorMessageFromLocationCallbackResult().
|
inline |
Set the 'owner' (the originator) of this error message.
This is used to show a company owner's face if you attempt an action on something owned by other company.
Definition at line 62 of file command_type.h.
References owner.
|
inline |
Did this command succeed?
Definition at line 169 of file command_type.h.
References success.
Referenced by AddNearbyStation(), BuildReplacementVehicle(), CanBuildTramTrackOnTile(), CcBuildIndustry(), CcBuildRailTunnel(), CcBuildRoadTunnel(), CheckAllowRemoveTunnelBridge(), CheckClearTile(), ClearMakeHouseTile(), CmdAutoreplaceVehicle(), CmdBuildIndustry(), CmdBuildSingleRail(), CmdBuildVehicle(), CmdCloneVehicle(), CmdDepotMassAutoReplace(), CmdDepotSellAllVehicles(), CmdLevelLand(), CmdPlaceHouse(), CmdRemoveLongRoad(), CmdSignalTrackHelper(), CmdTerraformLand(), CopyHeadSpecificThings(), CreateRandomTown(), DoBuildLock(), ScriptInstance::DoCommandCallback(), HandleStationRefit(), CommandHelperBase::InternalDoAfter(), IsValidTileForWaypoint(), RemoveDock(), RemoveLock(), ReplaceChain(), ReplaceFreeUnit(), SendAllVehiclesToDepot(), and ShowBuildBridgeWindow().
|
private |
The cost of this action.
Definition at line 25 of file command_type.h.
|
staticprivate |
Encoded error message, used if the error message includes parameters.
Definition at line 32 of file command_type.h.
Referenced by GetEncodedMessage(), and SetEncodedMessage().
|
private |
the type of expence as shown on the finances view
Definition at line 27 of file command_type.h.
Referenced by GetExpensesType().
|
private |
Additional warning message for when success is unset.
Definition at line 30 of file command_type.h.
Referenced by GetExtraErrorMessage().
|
private |
Warning message for when success is unset.
Definition at line 26 of file command_type.h.
Referenced by AddCost(), GetErrorMessage(), MakeError(), and SetEncodedMessage().
|
private |
Originator owner of error.
Definition at line 29 of file command_type.h.
Referenced by GetErrorOwner(), and SetErrorOwner().
|
private |
Whether the command went fine up to this moment.
Definition at line 28 of file command_type.h.
Referenced by AddCost(), Failed(), and Succeeded().