111 this->cost *= factor;
139 this->success =
false;
449template <
typename... Targs>
451 using Args = std::tuple<std::decay_t<Targs>...>;
452 using RetTypes = void;
456template <
template <
typename...>
typename Tret,
typename... Tretargs,
typename... Targs>
458 using Args = std::tuple<std::decay_t<Targs>...>;
459 using RetTypes = std::tuple<std::decay_t<Tretargs>...>;
460 using CbArgs = std::tuple<std::decay_t<Tretargs>..., std::decay_t<Targs>...>;
467#define DEF_CMD_TRAIT(cmd_, proc_, flags_, type_) \
468 template <> struct CommandTraits<cmd_> { \
469 using ProcType = decltype(&proc_); \
470 using Args = typename CommandFunctionTraitHelper<ProcType>::Args; \
471 using RetTypes = typename CommandFunctionTraitHelper<ProcType>::RetTypes; \
472 using CbArgs = typename CommandFunctionTraitHelper<ProcType>::CbArgs; \
473 using RetCallbackProc = typename CommandFunctionTraitHelper<ProcType>::CbProcType; \
474 static constexpr Commands cmd = cmd_; \
475 static constexpr auto &proc = proc_; \
476 static constexpr CommandFlags flags = flags_; \
477 static constexpr CommandType type = type_; \
478 static inline constexpr std::string_view name = #proc_; \
Common return value for all commands.
ExpensesType GetExpensesType() const
The expense type of the cost.
bool Succeeded() const
Did this command succeed?
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
void MakeError(StringID message)
Makes this CommandCost behave like an error command.
Money cost
The cost of this action.
StringID extra_message
Additional warning message for when success is unset.
CommandCost(ExpensesType ex_t, const Money &cst)
Creates a command return value with the given start cost and expense type.
Money GetCost() const
The costs as made up to this moment.
CommandCost(ExpensesType ex_t)
Creates a command cost with given expense type and start cost of 0.
void SetEncodedMessage(EncodedString &&message)
Set the encoded message string.
Owner owner
Originator owner of error.
CommandCost(StringID msg, StringID extra_msg=INVALID_STRING_ID)
Creates a command return value with one, or optionally two, error message strings.
StringID message
Warning message for when success is unset.
bool Failed() const
Did this command fail?
EncodedString & GetEncodedMessage()
Get the last encoded error message.
CommandCost()
Creates a command cost return with no cost and no error.
void MultiplyCost(int factor)
Multiplies the cost of the command by the given factor.
StringID GetErrorMessage() const
Returns the error message of a command.
void SetErrorOwner(Owner owner)
Set the 'owner' (the originator) of this error message.
bool success
Whether the command went fine up to this moment.
CompanyID GetErrorOwner() const
Get the originator owner for this error.
ExpensesType expense_type
the type of expense as shown on the finances view
StringID GetExtraErrorMessage() const
Returns the extra error message of a command.
EncodedString encoded_message
Encoded error message, used if the error message includes parameters.
Container for an encoded string, created by GetEncodedString.
CommandType
Types of commands we have.
@ VehicleConstruction
Construction, modification (incl. refit) and destruction of vehicles.
@ RouteManagement
Modifications to route management (orders, groups, etc).
@ Cheat
A cheat of some sorts.
@ OtherManagement
Renaming stuff, changing company colours, placing signs, etc.
@ LandscapeConstruction
Construction and destruction of objects on the map.
@ MoneyManagement
Management of money, i.e. loans.
@ CompanySetting
Changing settings related to a company.
@ VehicleManagement
Stopping, starting, sending to depot, turning around, replace orders etc.
@ ServerSetting
Pausing/removing companies/server settings.
void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile)
Define a callback function for the client, after the command is finished.
DoCommandFlag
List of flags for a command.
@ Auto
don't allow building on structures
@ QueryCost
query cost only, don't build.
@ NoModifyTownRating
do not change town rating
@ NoWater
don't allow building on water
@ Execute
execute the given command
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
@ AllTiles
allow this command also on TileType::Void tiles
@ NoCargoCapacityCheck
when autoreplace/autorenew is in progress, this shall prevent truncating the amount of cargo in the v...
@ ForceClearTile
do not only remove the object on the tile, but also clear any water left on it
@ AutoReplace
autoreplace/autorenew is in progress, this shall disable vehicle limits when building,...
@ NoTestTownRating
town rating does not disallow you from building
CommandCost CommandCostWithParam(StringID str, uint64_t value)
Return an error status, with string and parameter.
CommandFlag
Command flags for the command table _command_proc_table.
@ NoEst
the command is never estimated.
@ Deity
the command may be executed by COMPANY_DEITY
@ Spectator
the command may be initiated by a spectator
@ Offline
the command cannot be executed in a multiplayer game; single-player only
@ Server
the command can only be initiated by the server
@ ClientID
set p2 with the ClientID of the sending client.
@ StrCtrl
the command's string may contain control strings
@ Location
the command has implicit location argument.
@ NoTest
the command's output may differ between test and execute due to town rating changes etc.
CommandPauseLevel
Different command pause levels.
@ NoLandscaping
No landscaping actions may be executed.
@ NoConstruction
No construction actions may be executed.
@ NoActions
No user actions may be executed.
@ AllActions
All actions may be executed.
void CommandCallbackData(Commands cmd, const CommandCost &result, const CommandDataBuffer &data, CommandDataBuffer result_data)
Define a callback function for the client, after the command is finished.
std::vector< uint8_t > CommandDataBuffer
Storage buffer for serialized command data.
Commands
List of commands.
@ RenameDepot
rename a depot
@ ForceTrainProceed
proceed a train to pass a red signal
@ TownGrowthRate
set the town growth rate
@ SetStoryPageTitle
update title of a story page
@ ChangeTimetable
change the timetable for a vehicle
@ BuildRailWaypoint
build a waypoint
@ SendVehicleToDepot
send a vehicle to a depot
@ PlaceHouseArea
place an area of houses
@ TownCargoGoal
set the goal of a cargo for a town
@ BuildObject
build an object
@ IndustrySetProduction
change industry production
@ CreateGoal
create a new goal
@ DepotMassAutoreplace
force the autoreplace to take action in a given depot
@ AutofillTimetable
autofill the timetable
@ RemoveGoal
remove a goal
@ CloneOrder
clone (and share) an order
@ BuildAirport
build an airport
@ ChangeServiceInterval
change the server interval of a vehicle
@ MoveStationName
move a station name
@ SetTimetableStart
set the date that a timetable should start
@ WantEnginePreview
confirm the preview of an engine
@ DecreaseLoan
decrease the loan from the bank
@ GoalQuestion
ask a goal related question
@ BuildRoadDepot
build a road depot
@ SetCompanyManagerFace
set the manager's face of the company
@ OrderRefit
change the refit information of an order (for "goto depot" )
@ ShowStoryPage
show a story page
@ SetGroupLivery
set the livery for a group
@ ScrollViewport
scroll main viewport of players
@ SetGoalDestination
update goal destination of a goal
@ BuildSignal
build a signal
@ IndustrySetText
change additional text for the industry
@ ChangeTimetableBulk
change the timetable for all orders of a vehicle
@ IndustrySetFlags
change industry control flags
@ UpdateLeagueTableElementData
update the data fields of a league table element
@ ConvertRoad
convert a road type
@ UpdateLeagueTableElementScore
update the score of a league table element
@ RenameStation
rename a station
@ RemoveRoadLong
remove a complete road (not a "half" one)
@ MoneyCheat
do the money cheat
@ ConvertRail
convert a rail type
@ ClearOrderBackup
clear the order backup of a given user/tile
@ ChangeSetting
change a setting
@ SellVehicle
sell a vehicle
@ GoalQuestionAnswer
answer(s) to Commands::GoalQuestion
@ CompanyControl
used in multiplayer to create a new companies etc.
@ ExpandTown
expand a town
@ AlterGroup
alter a group
@ EngineControl
control availability of the engine for companies
@ BuildIndustry
build a new industry
@ BuildCanal
build a canal
@ DeleteTown
delete a town
@ SetStoryPageDate
update date of a story page
@ BuildTunnel
build a tunnel
@ SetCompanyColour
set the colour of the company
@ BuildRoadWaypoint
build a road waypoint
@ ReverseTrainDirection
turn a train around
@ IncreaseLoan
increase the loan from the bank
@ BuildBridge
build a bridge
@ SetVehicleVisibility
hide or unhide a vehicle in the build vehicle and autoreplace GUIs
@ AutoreplaceVehicle
replace/renew a vehicle while it is in a depot
@ BuildObjectArea
build an area of objects
@ CreateCustomNewsItem
create a custom news message
@ CreateLeagueTable
create a new league table
@ AddSharedVehiclesToGroup
add all other shared vehicles to a group which are missing
@ InsertOrder
insert a new order
@ PlaceHouse
place a house
@ RenameCompany
change the company name
@ SetGoalText
update goal text of a goal
@ BuildShipDepot
build a ship depot
@ TownAction
do a action from the town detail window (like advertises or bribe)
@ BuildVehicle
build a vehicle
@ UpdateStoryPageElement
update a story page element
@ BuyCompany
buy a company which is bankrupt
@ CloneVehicle
clone a vehicle
@ BuildRailStation
build a rail station
@ BuildRailDepot
build a train depot
@ TownSetText
set the custom text of a town
@ RemoveFromRailStation
remove a (rectangle of) tiles from a rail station
@ SetGoalProgress
update goal progress text of a goal
@ MassStartStop
start/stop all vehicles (in a depot)
@ CreateLeagueTableElement
create a new element in a league table
@ RefitVehicle
refit the cargo space of a vehicle
@ DepotMassSell
sell all vehicles which are in a given depot
@ RenameEngine
rename a engine (in the engine list)
@ IndustrySetExclusivity
change industry exclusive consumer/supplier
@ OpenCloseAirport
open/close an airport to incoming aircraft
@ StoryPageButton
selection via story page button
@ TerraformLand
terraform a tile
@ MoveRailVehicle
move a rail vehicle (in the depot)
@ BuildRail
build a single rail track
@ RemoveLeagueTableElement
remove a league table element
@ RemoveFromRoadWaypoint
remove a (rectangle of) tiles from a road waypoint
@ RenamePresident
change the president name
@ RemoveAllVehiclesGroup
remove all vehicles from a group
@ SetGroupFlag
set/clear a flag for a group
@ ChangeBankBalance
change bank balance to charge costs or give money from a GS
@ TurnRoadVehicle
turn a road vehicle around
@ SetVehicleOnTime
set the vehicle on time feature (timetable)
@ BuildRailLong
build a rail track
@ RemoveStoryPage
remove a story page
@ SetCompanyMaxLoan
sets the max loan for the company
@ RemoveRoadStop
remove a road stop
@ AddVehicleToGroup
add a vehicle to a group
@ BuildRoad
build a "half" road
@ TownRating
set rating of a company in a town
@ RemoveSignal
remove a signal
@ MoveWaypointNAme
move a waypoint name
@ RemoveSignalLong
remove signals along a track (by dragging)
@ SetGoalCompleted
update goal completed status of a goal
@ CreateSubsidy
create a new subsidy
@ RemoveRail
remove a single rail track
@ BuildSignalLong
add signals along a track (by dragging)
@ StartStopVehicle
start or stop a vehicle
@ RemoveRailLong
remove a rail track
@ CreateStoryPageElement
create a new story page element
@ CreateGroup
create a new group
@ SetAutoreplace
set an autoreplace entry
@ CreateStoryPage
create a new story page
@ DeleteOrder
delete an order
@ RenameTown
rename a town
@ RenameVehicle
rename a whole vehicle
@ DeleteGroup
delete a group
@ RemoveFromRailWaypoint
remove a (rectangle of) tiles from a rail waypoint
@ GiveMoney
give money to another company
@ ModifyOrder
modify an order (like set full-load)
@ ChangeCompanySetting
change a company setting
@ RenameSign
rename a sign
@ RemoveStoryPageElement
remove a story page element
@ BuildRoadLong
build a complete road (not a "half" one)
@ LandscapeClear
demolish a tile
@ BuildRoadStop
build a road stop
@ RenameWaypoint
rename a waypoint
@ SkipToOrder
skip an order to the next of specific one
@ CompanyAllowListControl
Used in multiplayer to add/remove a client's public key to/from the company's allow list.
Types related to companies.
A type is considered 'convertible through base()' when it has a 'base()' function that returns someth...
Types related to the economy.
ExpensesType
Types of expenses.
@ INVALID_EXPENSES
Invalid expense type.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Defines the traits of a command.
Dynamic data of a loaded NewGRF.