OpenTTD Source: src/command.cpp Source File

OpenTTD Source 15.3

command.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "landscape.h"
12#include "error.h"
13#include "gui.h"
14#include "command_func.h"
15#include "network/network_type.h"
16#include "network/network.h"
17#include "genworld.h"
18#include "strings_func.h"
19#include "texteff.hpp"
20#include "town.h"
21#include "timer/timer_game_economy.h"
22#include "company_func.h"
23#include "company_base.h"
24#include "signal_func.h"
25#include "core/backup_type.hpp"
26#include "object_base.h"
27#include "autoreplace_cmd.h"
28#include "company_cmd.h"
29#include "depot_cmd.h"
30#include "economy_cmd.h"
31#include "engine_cmd.h"
32#include "goal_cmd.h"
33#include "group_cmd.h"
34#include "industry_cmd.h"
35#include "league_cmd.h"
36#include "landscape_cmd.h"
37#include "misc_cmd.h"
38#include "news_cmd.h"
39#include "object_cmd.h"
40#include "order_cmd.h"
41#include "rail_cmd.h"
42#include "road_cmd.h"
43#include "roadveh_cmd.h"
44#include "settings_cmd.h"
45#include "signs_cmd.h"
46#include "station_cmd.h"
47#include "story_cmd.h"
48#include "subsidy_cmd.h"
49#include "terraform_cmd.h"
50#include "timetable_cmd.h"
51#include "town_cmd.h"
52#include "train_cmd.h"
53#include "tree_cmd.h"
54#include "tunnelbridge_cmd.h"
55#include "vehicle_cmd.h"
56#include "viewport_cmd.h"
57#include "water_cmd.h"
58#include "waypoint_cmd.h"
59#include "misc/endian_buffer.hpp"
60#include "string_func.h"
61
62#include "table/strings.h"
63
64#include "safeguards.h"
65
66
67int RecursiveCommandCounter::_counter = 0;
68
69
76 struct CommandInfo {
77 std::string_view name;
78 CommandFlags flags;
79 CommandType type;
80};
81/* Helpers to generate the master command table from the command traits. */
82template <typename T>
83inline constexpr CommandInfo CommandFromTrait() noexcept { return { T::name, T::flags, T::type }; };
84
85template <typename T, T... i>
86inline constexpr auto MakeCommandsFromTraits(std::integer_sequence<T, i...>) noexcept {
87 return std::array<CommandInfo, sizeof...(i)>{{ CommandFromTrait<CommandTraits<static_cast<Commands>(i)>>()... }};
88}
89
97 static constexpr auto _command_proc_table = MakeCommandsFromTraits(std::make_integer_sequence<std::underlying_type_t<Commands>, CMD_END>{});
98
99
106 bool IsValidCommand(Commands cmd)
107{
108 return cmd < _command_proc_table.size();
109}
110
118 CommandFlags GetCommandFlags(Commands cmd)
119{
120 assert(IsValidCommand(cmd));
121
122 return _command_proc_table[cmd].flags;
123}
124
132std::string_view GetCommandName(Commands cmd)
133{
134 assert(IsValidCommand(cmd));
135
136 return _command_proc_table[cmd].name;
137}
138
144 bool IsCommandAllowedWhilePaused(Commands cmd)
145{
146 /* Lookup table for the command types that are allowed for a given pause level setting. */
147 static constexpr CommandPauseLevel command_type_lookup[] = {
148 CommandPauseLevel::AllActions, // CommandType::LandscapeConstruction
149 CommandPauseLevel::NoLandscaping, // CommandType::VehicleConstruction
150 CommandPauseLevel::NoLandscaping, // CommandType::MoneyManagement
151 CommandPauseLevel::NoConstruction, // CommandType::VehicleManagement
152 CommandPauseLevel::NoConstruction, // CommandType::RouteManagement
153 CommandPauseLevel::NoConstruction, // CommandType::OtherManagement
154 CommandPauseLevel::NoActions, // CommandType::CompanySetting
155 CommandPauseLevel::NoActions, // CommandType::ServerSetting
156 CommandPauseLevel::NoActions, // CommandType::Cheat
157 };
158 static_assert(std::size(command_type_lookup) == to_underlying(CommandType::End));
159
160 assert(IsValidCommand(cmd));
161 return _game_mode == GM_EDITOR || command_type_lookup[to_underlying(_command_proc_table[cmd].type)] <= _settings_game.construction.command_pause_level;
162}
163
169 void CommandHelperBase::InternalDoBefore(bool top_level, bool test)
170{
171 if (top_level) _cleared_object_areas.clear();
172 if (test) SetTownRatingTestMode(true);
173}
174
182 void CommandHelperBase::InternalDoAfter(CommandCost &res, DoCommandFlags flags, bool top_level, bool test)
183{
184 if (test) {
185 SetTownRatingTestMode(false);
186
187 if (res.Succeeded() && top_level && !flags.Test(DoCommandFlag::QueryCost) && !flags.Test(DoCommandFlag::Bankrupt)) {
188 CheckCompanyHasMoney(res); // CheckCompanyHasMoney() modifies 'res' to an error if it fails.
189 }
190 } else {
191 /* If top-level, subtract the money. */
192 if (res.Succeeded() && top_level && !flags.Test(DoCommandFlag::Bankrupt)) {
193 SubtractMoneyFromCompany(res);
194 }
195 }
196}
197
207std::tuple<bool, bool, bool> CommandHelperBase::InternalPostBefore(Commands cmd, CommandFlags flags, TileIndex tile, StringID err_message, bool network_command)
208{
209 /* Cost estimation is generally only done when the
210 * local user presses shift while doing something.
211 * However, in case of incoming network commands,
212 * map generation or the pause button we do want
213 * to execute. */
214 bool estimate_only = _shift_pressed && IsLocalCompany() && !_generating_world && !network_command && !flags.Test(CommandFlag::NoEst);
215
216 /* We're only sending the command, so don't do
217 * fancy things for 'success'. */
218 bool only_sending = _networking && !network_command;
219
220 if (_pause_mode.Any() && !IsCommandAllowedWhilePaused(cmd) && !estimate_only) {
221 ShowErrorMessage(GetEncodedString(err_message), GetEncodedString(STR_ERROR_NOT_ALLOWED_WHILE_PAUSED),
222 WL_INFO, TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE);
223 return { true, estimate_only, only_sending };
224 } else {
225 return { false, estimate_only, only_sending };
226 }
227}
228
238 void CommandHelperBase::InternalPostResult(CommandCost &res, TileIndex tile, bool estimate_only, bool only_sending, StringID err_message, bool my_cmd)
239{
240 int x = TileX(tile) * TILE_SIZE;
241 int y = TileY(tile) * TILE_SIZE;
242
243 if (res.Failed()) {
244 /* Only show the error when it's for us. */
245 if (estimate_only || (IsLocalCompany() && err_message != 0 && my_cmd)) {
246 ShowErrorMessage(GetEncodedString(err_message), x, y, res);
247 }
248 } else if (estimate_only) {
249 ShowEstimatedCostOrIncome(res.GetCost(), x, y);
250 } else if (!only_sending && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
251 /* Only show the cost animation when we did actually
252 * execute the command, i.e. we're not sending it to
253 * the server, when it has cost the local company
254 * something. Furthermore in the editor there is no
255 * concept of cost, so don't show it there either. */
256 ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
257 }
258}
259
261 void CommandHelperBase::LogCommandExecution(Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed)
262{
263 Debug(desync, 1, "{}: {:08x}; {:02x}; {:02x}; {:08x}; {:08x}; {} ({})", failed ? "cmdf" : "cmd", (uint32_t)TimerGameEconomy::date.base(), TimerGameEconomy::date_fract, _current_company, cmd, err_message, FormatArrayAsHex(args), GetCommandName(cmd));
264}
265
272 bool CommandHelperBase::InternalExecutePrepTest(CommandFlags cmd_flags, TileIndex, Backup<CompanyID> &cur_company)
273{
274 /* Always execute server and spectator commands as spectator */
275 bool exec_as_spectator = cmd_flags.Any({CommandFlag::Spectator, CommandFlag::Server});
276
277 /* If the company isn't valid it may only do server command or start a new company!
278 * The server will ditch any server commands a client sends to it, so effectively
279 * this guards the server from executing functions for an invalid company. */
280 if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && cmd_flags.Test(CommandFlag::Deity))) {
281 return false;
282 }
283
284 if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
285
286 /* Enter test mode. */
287 _cleared_object_areas.clear();
288 SetTownRatingTestMode(true);
289 BasePersistentStorageArray::SwitchMode(PSM_ENTER_TESTMODE);
290 return true;
291}
292
302std::tuple<bool, bool, bool> CommandHelperBase::InternalExecuteValidateTestAndPrepExec(CommandCost &res, CommandFlags cmd_flags, bool estimate_only, bool network_command, [[maybe_unused]] Backup<CompanyID> &cur_company)
303{
304 BasePersistentStorageArray::SwitchMode(PSM_LEAVE_TESTMODE);
305 SetTownRatingTestMode(false);
306
307 /* Make sure we're not messing things up here. */
308 assert(cmd_flags.Any({CommandFlag::Spectator, CommandFlag::Server}) ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
309
310 /* If the command fails, we're doing an estimate
311 * or the player does not have enough money
312 * (unless it's a command where the test and
313 * execution phase might return different costs)
314 * we bail out here. */
315 bool test_and_exec_can_differ = cmd_flags.Test(CommandFlag::NoTest);
316 if (res.Failed() || estimate_only || (!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
317 return { true, !_networking || _generating_world || network_command, false };
318 }
319
320 bool send_net = _networking && !_generating_world && !network_command;
321
322 if (!send_net) {
323 /* Prepare for command execution. */
324 _cleared_object_areas.clear();
325 BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
326 }
327
328 return { false, _debug_desync_level >= 1, send_net };
329}
330
342 CommandCost CommandHelperBase::InternalExecuteProcessResult(Commands cmd, CommandFlags cmd_flags, [[maybe_unused]] const CommandCost &res_test, const CommandCost &res_exec, Money extra_cash, TileIndex tile, Backup<CompanyID> &cur_company)
343{
344 BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
345
346 if (cmd == CMD_COMPANY_CTRL) {
347 cur_company.Trash();
348 /* We are a new company -> Switch to new local company.
349 * We were closed down -> Switch to spectator
350 * Some other company opened/closed down -> The outside function will switch back */
351 _current_company = _local_company;
352 } else {
353 /* Make sure nothing bad happened, like changing the current company. */
354 assert(cmd_flags.Any({CommandFlag::Spectator, CommandFlag::Server}) ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
355 cur_company.Restore();
356 }
357
358 /* If the test and execution can differ we have to check the
359 * return of the command. Otherwise we can check whether the
360 * test and execution have yielded the same result,
361 * i.e. cost and error state are the same. */
362 bool test_and_exec_can_differ = cmd_flags.Test(CommandFlag::NoTest);
363 if (!test_and_exec_can_differ) {
364 assert(res_test.GetCost() == res_exec.GetCost() && res_test.Failed() == res_exec.Failed()); // sanity check
365 } else if (res_exec.Failed()) {
366 return res_exec;
367 }
368
369 /* If we're needing more money and we haven't done
370 * anything yet, ask for the money! */
371 if (extra_cash != 0 && res_exec.GetCost() == 0) {
372 /* It could happen we removed rail, thus gained money, and deleted something else.
373 * So make sure the signal buffer is empty even in this case */
374 UpdateSignalsInBuffer();
375 return CommandCostWithParam(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY, extra_cash);
376 }
377
378 /* update last build coordinate of company. */
379 if (tile != 0) {
380 Company *c = Company::GetIfValid(_current_company);
381 if (c != nullptr) c->last_build_coordinate = tile;
382 }
383
384 SubtractMoneyFromCompany(res_exec);
385
386 /* Record if there was a command issues during pause; ignore pause/other setting related changes. */
387 if (_pause_mode.Any() && _command_proc_table[cmd].type != CommandType::ServerSetting) _pause_mode.Set(PauseMode::CommandDuringPause);
388
389 /* update signals if needed */
390 UpdateSignalsInBuffer();
391
392 return res_exec;
393}
394
395
401 void CommandCost::AddCost(CommandCost &&ret)
402{
403 this->AddCost(ret.cost);
404 if (this->success && !ret.success) {
405 this->message = ret.message;
406 this->encoded_message = std::move(ret.encoded_message);
407 this->success = false;
408 }
409}
410
417 CommandCost CommandCostWithParam(StringID str, uint64_t value)
418{
419 CommandCost error = CommandCost(str);
420 if (IsLocalCompany()) {
421 error.SetEncodedMessage(GetEncodedString(str, value));
422 }
423 return error;
424}
autoreplace_cmd.h
Command definitions related to autoreplace.
backup_type.hpp
Class for backupping variables and making sure they are restored later.
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
BaseBitSet::Any
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Definition base_bitset_type.hpp:170
CommandCost
Common return value for all commands.
Definition command_type.h:24
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition command_type.h:168
CommandCost::AddCost
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Definition command_type.h:98
CommandCost::GetCost
Money GetCost() const
The costs as made up to this moment.
Definition command_type.h:118
CommandCost::SetEncodedMessage
void SetEncodedMessage(EncodedString &&message)
Set the encoded message string.
Definition command_type.h:72
CommandCost::message
StringID message
Warning message for when success is unset.
Definition command_type.h:26
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition command_type.h:177
CommandCost::success
bool success
Whether the command went fine up to this moment.
Definition command_type.h:28
CommandCost::encoded_message
EncodedString encoded_message
Encoded error message, used if the error message includes parameters.
Definition command_type.h:31
CommandHelperBase::InternalPostBefore
static std::tuple< bool, bool, bool > InternalPostBefore(Commands cmd, CommandFlags flags, TileIndex tile, StringID err_message, bool network_command)
Decide what to do with the command depending on current game state.
Definition command.cpp:207
CommandHelperBase::InternalPostResult
static void InternalPostResult(CommandCost &res, TileIndex tile, bool estimate_only, bool only_sending, StringID err_message, bool my_cmd)
Process result of executing a command, possibly displaying any error to the player.
Definition command.cpp:238
CommandHelperBase::InternalDoBefore
static void InternalDoBefore(bool top_level, bool test)
Prepare for calling a command proc.
Definition command.cpp:169
CommandHelperBase::LogCommandExecution
static void LogCommandExecution(Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed)
Helper to make a desync log for a command.
Definition command.cpp:261
CommandHelperBase::InternalExecuteProcessResult
static CommandCost InternalExecuteProcessResult(Commands cmd, CommandFlags cmd_flags, const CommandCost &res_test, const CommandCost &res_exec, Money extra_cash, TileIndex tile, Backup< CompanyID > &cur_company)
Process the result of a command test run and execution run.
Definition command.cpp:342
CommandHelperBase::InternalDoAfter
static void InternalDoAfter(CommandCost &res, DoCommandFlags flags, bool top_level, bool test)
Process result after calling a command proc.
Definition command.cpp:182
CommandHelperBase::InternalExecuteValidateTestAndPrepExec
static std::tuple< bool, bool, bool > InternalExecuteValidateTestAndPrepExec(CommandCost &res, CommandFlags cmd_flags, bool estimate_only, bool network_command, Backup< CompanyID > &cur_company)
Validate result of test run and prepare for real execution.
Definition command.cpp:302
CommandHelperBase::InternalExecutePrepTest
static bool InternalExecutePrepTest(CommandFlags cmd_flags, TileIndex tile, Backup< CompanyID > &cur_company)
Prepare for the test run of a command proc call.
Definition command.cpp:272
EnumBitSet< CommandFlag, uint16_t >
OverflowSafeInt< int64_t >
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition timer_game_economy.h:38
TimerGameEconomy::date_fract
static DateFract date_fract
Fractional part of the day.
Definition timer_game_economy.h:39
GetCommandFlags
CommandFlags GetCommandFlags(Commands cmd)
This function mask the parameter with CMD_ID_MASK and returns the flags which belongs to the given co...
Definition command.cpp:118
CommandCostWithParam
CommandCost CommandCostWithParam(StringID str, uint64_t value)
Return an error status, with string and parameter.
Definition command.cpp:417
IsCommandAllowedWhilePaused
bool IsCommandAllowedWhilePaused(Commands cmd)
Returns whether the command is allowed while the game is paused.
Definition command.cpp:144
GetCommandName
std::string_view GetCommandName(Commands cmd)
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given com...
Definition command.cpp:132
IsValidCommand
bool IsValidCommand(Commands cmd)
This function range-checks a cmd.
Definition command.cpp:106
_command_proc_table
static constexpr auto _command_proc_table
The master command table.
Definition command.cpp:97
command_func.h
Functions related to commands.
IsCommandAllowedWhilePaused
bool IsCommandAllowedWhilePaused(Commands cmd)
Returns whether the command is allowed while the game is paused.
Definition command.cpp:144
GetCommandName
std::string_view GetCommandName(Commands cmd)
This function mask the parameter with CMD_ID_MASK and returns the name which belongs to the given com...
Definition command.cpp:132
CommandType
CommandType
Types of commands we have.
Definition command_type.h:423
CommandType::End
@ End
End marker.
CommandType::ServerSetting
@ ServerSetting
Pausing/removing companies/server settings.
DoCommandFlag::QueryCost
@ QueryCost
query cost only, don't build.
DoCommandFlag::Bankrupt
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
CommandFlag::NoEst
@ NoEst
the command is never estimated.
CommandFlag::Deity
@ Deity
the command may be executed by COMPANY_DEITY
CommandFlag::Spectator
@ Spectator
the command may be initiated by a spectator
CommandFlag::Server
@ Server
the command can only be initiated by the server
CommandFlag::NoTest
@ NoTest
the command's output may differ between test and execute due to town rating changes etc.
CommandPauseLevel
CommandPauseLevel
Different command pause levels.
Definition command_type.h:439
CommandPauseLevel::NoLandscaping
@ NoLandscaping
No landscaping actions may be executed.
CommandPauseLevel::NoConstruction
@ NoConstruction
No construction actions may be executed.
CommandPauseLevel::NoActions
@ NoActions
No user actions may be executed.
CommandPauseLevel::AllActions
@ AllActions
All actions may be executed.
CommandDataBuffer
std::vector< uint8_t > CommandDataBuffer
Storage buffer for serialized command data.
Definition command_type.h:481
Commands
Commands
List of commands.
Definition command_type.h:196
CMD_COMPANY_CTRL
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
Definition command_type.h:312
CMD_END
@ CMD_END
Must ALWAYS be on the end of this list!! (period)
Definition command_type.h:378
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
CheckCompanyHasMoney
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
Definition company_cmd.cpp:263
SubtractMoneyFromCompany
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
Definition company_cmd.cpp:313
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
_current_company
CompanyID _current_company
Company currently doing an action.
Definition company_cmd.cpp:56
company_cmd.h
Command definitions related to companies.
company_func.h
Functions related to companies.
IsLocalCompany
bool IsLocalCompany()
Is the current company the local company?
Definition company_func.h:47
OWNER_DEITY
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
Definition company_type.h:28
COMPANY_SPECTATOR
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
Definition company_type.h:21
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
depot_cmd.h
Command definitions related to depots.
economy_cmd.h
Command definitions related to the economy.
endian_buffer.hpp
Endian-aware buffer.
engine_cmd.h
Command definitions related to engines.
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
error.h
Functions related to errors.
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition error.h:24
ShowErrorMessage
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Definition error_gui.cpp:296
_generating_world
bool _generating_world
Whether we are generating the map or not.
Definition genworld.cpp:74
genworld.h
Functions related to world/map generation.
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition gfx.cpp:39
_pause_mode
PauseModes _pause_mode
The current pause mode.
Definition gfx.cpp:50
goal_cmd.h
Command definitions related to goals.
group_cmd.h
Command definitions related to engine groups.
gui.h
GUI functions that shouldn't be here.
ShowEstimatedCostOrIncome
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
Display estimated costs.
Definition misc_gui.cpp:495
industry_cmd.h
Command definitions related to industries.
GetSlopePixelZ
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
Definition landscape.cpp:307
landscape.h
Functions related to OTTD's landscape.
landscape_cmd.h
Command definitions related to landscape (slopes etc.).
league_cmd.h
Command definitions related to league tables.
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:438
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:428
misc_cmd.h
Miscellaneous command definitions.
ShowCostOrIncomeAnimation
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
Definition misc_gui.cpp:513
_networking
bool _networking
are we in networking mode?
Definition network.cpp:67
network.h
Basic functions/variables used all over the place.
network_type.h
Types used for networking.
PSM_LEAVE_TESTMODE
@ PSM_LEAVE_TESTMODE
Leave command test mode, revert to previous mode.
Definition newgrf_storage.h:26
PSM_LEAVE_COMMAND
@ PSM_LEAVE_COMMAND
Leave command scope, revert to previous mode.
Definition newgrf_storage.h:24
PSM_ENTER_COMMAND
@ PSM_ENTER_COMMAND
Enter command scope, changes will be permanent.
Definition newgrf_storage.h:23
PSM_ENTER_TESTMODE
@ PSM_ENTER_TESTMODE
Enter command test mode, changes will be temporary.
Definition newgrf_storage.h:25
news_cmd.h
Command definitions related to news messages.
object_base.h
Base for all objects.
object_cmd.h
Command definitions related to objects.
PauseMode::CommandDuringPause
@ CommandDuringPause
A game paused, and a command executed during the pause; resets on autosave.
order_cmd.h
Command definitions related to orders.
rail_cmd.h
Command definitions for rail.
road_cmd.h
Road related functions.
roadveh_cmd.h
Command definitions related to road vehicles.
safeguards.h
A number of safeguards to prevent using unsafe methods.
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
settings_cmd.h
Command definitions related to settings.
UpdateSignalsInBuffer
void UpdateSignalsInBuffer()
Update signals in buffer Called from 'outside'.
Definition signal.cpp:573
signal_func.h
Functions related to signals.
signs_cmd.h
Command definitions related to signs.
station_cmd.h
Command definitions related to stations.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
story_cmd.h
Command definitions related to stories.
FormatArrayAsHex
std::string FormatArrayAsHex(std::span< const uint8_t > data)
Format a byte array into a continuous hex string.
Definition string.cpp:77
string_func.h
Functions related to low-level strings.
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
Backup
Class to backup a specific variable and restore it later.
Definition backup_type.hpp:21
Backup::Trash
void Trash()
Trash the backup.
Definition backup_type.hpp:101
Backup::Verify
bool Verify() const
Check whether the variable is currently equals the backup.
Definition backup_type.hpp:130
Backup::Change
void Change(const U &new_value)
Change the value of the variable.
Definition backup_type.hpp:82
Backup::Restore
void Restore()
Restore the variable.
Definition backup_type.hpp:110
BasePersistentStorageArray::SwitchMode
static void SwitchMode(PersistentStorageMode mode, bool ignore_prev_mode=false)
Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes sh...
Definition newgrf_storage.cpp:53
CommandInfo
Define a command with the flags which belongs to it.
Definition command.cpp:76
CommandInfo::type
CommandType type
The type of command.
Definition command.cpp:79
CommandInfo::name
std::string_view name
A human readable name for the procedure.
Definition command.cpp:77
CommandInfo::flags
CommandFlags flags
The (command) flags to that apply to this command.
Definition command.cpp:78
CompanyProperties::last_build_coordinate
TileIndex last_build_coordinate
Coordinate of the last build thing by this company.
Definition company_base.h:94
Company
Definition company_base.h:127
ConstructionSettings::command_pause_level
CommandPauseLevel command_pause_level
level/amount of commands that can't be executed while paused
Definition settings_type.h:425
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition settings_type.h:635
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(auto index)
Returns Titem with given index.
Definition pool_type.hpp:398
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
subsidy_cmd.h
Command definitions related to subsidies.
terraform_cmd.h
Command definitions related to terraforming.
texteff.hpp
Functions related to text effects.
TILE_SIZE
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
timer_game_economy.h
Definition of the game-economy-timer.
timetable_cmd.h
Command definitions related to timetables.
town.h
Base of the town class.
SetTownRatingTestMode
void SetTownRatingTestMode(bool mode)
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings...
Definition town_cmd.cpp:4002
town_cmd.h
Command definitions related to towns.
train_cmd.h
Command definitions related to trains.
tree_cmd.h
Command definitions related to tree tiles.
tunnelbridge_cmd.h
Command definitions related to tunnels and bridges.
vehicle_cmd.h
Command definitions for vehicles.
viewport_cmd.h
Command definitions related to viewports.
water_cmd.h
Command definitions related to water tiles.
waypoint_cmd.h
Command definitions related to waypoints.