MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsCommandAllowedWhilePaused

Function IsCommandAllowedWhilePaused

src/command.cpp:144–162  ·  view source on GitHub ↗

* Returns whether the command is allowed while the game is paused. * @param cmd The command to check. * @return True if the command is allowed while paused, false otherwise. */

Source from the content-addressed store, hash-verified

142 * @return True if the command is allowed while paused, false otherwise.
143 */
144bool 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
164/**
165 * Prepare for calling a command proc.

Callers 2

InternalPostBeforeMethod · 0.85
DistributeQueueFunction · 0.85

Calls 3

to_underlyingFunction · 0.85
IsValidCommandFunction · 0.85
sizeFunction · 0.50

Tested by

no test coverage detected