OpenTTD Source: src/console_cmds.cpp File Reference

OpenTTD Source 15.3

Data Structures | Enumerations | Functions | Variables
console_cmds.cpp File Reference

Implementation of the console hooks. More...

`#include "stdafx.h"`
`#include "core/string_consumer.hpp"`
`#include "console_internal.h"`
`#include "debug.h"`
`#include "engine_func.h"`
`#include "landscape.h"`
`#include "saveload/saveload.h"`
`#include "network/core/network_game_info.h"`
`#include "network/network.h"`
`#include "network/network_func.h"`
`#include "network/network_base.h"`
`#include "network/network_admin.h"`
`#include "network/network_client.h"`
`#include "command_func.h"`
`#include "settings_func.h"`
`#include "fios.h"`
`#include "fileio_func.h"`
`#include "fontcache.h"`
`#include "screenshot.h"`
`#include "genworld.h"`
`#include "strings_func.h"`
`#include "viewport_func.h"`
`#include "window_func.h"`
`#include "timer/timer.h"`
`#include "company_func.h"`
`#include "gamelog.h"`
`#include "ai/ai.hpp"`
`#include "ai/ai_config.hpp"`
`#include "newgrf.h"`
`#include "newgrf_profiling.h"`
`#include "console_func.h"`
`#include "engine_base.h"`
`#include "road.h"`
`#include "rail.h"`
`#include "game/game.hpp"`
`#include "3rdparty/fmt/chrono.h"`
`#include "company_cmd.h"`
`#include "misc_cmd.h"`
`#include "network/network_content.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
class | ConsoleFileList
| File list storage for the console, for caching the last 'ls' command. More...
struct | ConsoleContentCallback
| Asynchronous callback. More...

## Enumerations
enum | ConNetworkAuthorizedKeyAction : uint8_t { CNAKA_LIST , CNAKA_ADD , CNAKA_REMOVE }

## Functions
template<typename T >
static std::optional< T > | ParseType (std::string_view arg)
| Parse an integer using ParseInteger and convert it to the requested type.
static bool | NetworkAvailable (bool echo)
| Check network availability and inform in console about failure of detection.
static ConsoleHookResult | ConHookServerOnly (bool echo)
| Check whether we are a server.
static ConsoleHookResult | ConHookClientOnly (bool echo)
| Check whether we are a client in a network game.
static ConsoleHookResult | ConHookNeedNetwork (bool echo)
| Check whether we are in a multiplayer game.
static ConsoleHookResult | ConHookNeedNonDedicatedNetwork (bool echo)
| Check whether we are in a multiplayer game and are playing, i.e.
static ConsoleHookResult | ConHookNoNetwork (bool echo)
| Check whether we are in singleplayer mode.
static ConsoleHookResult | ConHookServerOrNoNetwork (bool echo)
| Check if are either in singleplayer or a server.
static ConsoleHookResult | ConHookNewGRFDeveloperTool (bool echo)
static bool | ConResetEngines (std::span< std::string_view > argv)
| Reset status of all engines.
static bool | ConResetEnginePool (std::span< std::string_view > argv)
| Reset status of the engine pool.
static bool | ConZoomToLevel (std::span< std::string_view > argv)
| Zoom map to given level.
static bool | ConScrollToTile (std::span< std::string_view > argv)
| Scroll to a tile on the map.
static bool | ConSave (std::span< std::string_view > argv)
| Save the map to a file.
static bool | ConSaveConfig (std::span< std::string_view > argv)
| Explicitly save the configuration.
static bool | ConLoad (std::span< std::string_view > argv)
static bool | ConLoadScenario (std::span< std::string_view > argv)
static bool | ConLoadHeightmap (std::span< std::string_view > argv)
static bool | ConRemove (std::span< std::string_view > argv)
static bool | ConListFiles (std::span< std::string_view > argv)
static bool | ConListScenarios (std::span< std::string_view > argv)
static bool | ConListHeightmaps (std::span< std::string_view > argv)
static bool | ConChangeDirectory (std::span< std::string_view > argv)
static bool | ConPrintWorkingDirectory (std::span< std::string_view > argv)
static bool | ConClearBuffer (std::span< std::string_view > argv)
static bool | ConKickOrBan (std::string_view arg, bool ban, std::string_view reason)
static bool | ConKick (std::span< std::string_view > argv)
static bool | ConBan (std::span< std::string_view > argv)
static bool | ConUnBan (std::span< std::string_view > argv)
static bool | ConBanList (std::span< std::string_view > argv)
static bool | ConPauseGame (std::span< std::string_view > argv)
static bool | ConUnpauseGame (std::span< std::string_view > argv)
static bool | ConRcon (std::span< std::string_view > argv)
static bool | ConStatus (std::span< std::string_view > argv)
static bool | ConServerInfo (std::span< std::string_view > argv)
static bool | ConClientNickChange (std::span< std::string_view > argv)
static std::optional< CompanyID > | ParseCompanyID (std::string_view arg)
static bool | ConJoinCompany (std::span< std::string_view > argv)
static bool | ConMoveClient (std::span< std::string_view > argv)
static bool | ConResetCompany (std::span< std::string_view > argv)
static bool | ConNetworkClients (std::span< std::string_view > argv)
static bool | ConNetworkReconnect (std::span< std::string_view > argv)
static bool | ConNetworkConnect (std::span< std::string_view > argv)
static bool | ConExec (std::span< std::string_view > argv)
static bool | ConSchedule (std::span< std::string_view > argv)
static bool | ConReturn (std::span< std::string_view > argv)
bool | CloseConsoleLogIfActive ()
std::span< const GRFFile > | GetAllGRFFiles ()
void | ConPrintFramerate ()
| Print performance statistics to game console.
void | ShowFramerateWindow ()
| Open the general framerate window.
static bool | ConScript (std::span< std::string_view > argv)
static bool | ConEcho (std::span< std::string_view > argv)
static bool | ConEchoC (std::span< std::string_view > argv)
static bool | ConNewGame (std::span< std::string_view > argv)
static bool | ConRestart (std::span< std::string_view > argv)
static bool | ConReload (std::span< std::string_view > argv)
static void | PrintLineByLine (const std::string &full_string)
| Print a text buffer line by line to the console.
template<typename F , typename ... Args>
bool | PrintList (F list_function, Args... args)
static bool | ConListAILibs (std::span< std::string_view > argv)
static bool | ConListAI (std::span< std::string_view > argv)
static bool | ConListGameLibs (std::span< std::string_view > argv)
static bool | ConListGame (std::span< std::string_view > argv)
static bool | ConStartAI (std::span< std::string_view > argv)
static bool | ConReloadAI (std::span< std::string_view > argv)
static bool | ConStopAI (std::span< std::string_view > argv)
static bool | ConRescanAI (std::span< std::string_view > argv)
static bool | ConRescanGame (std::span< std::string_view > argv)
static bool | ConRescanNewGRF (std::span< std::string_view > argv)
static bool | ConGetSeed (std::span< std::string_view > argv)
static bool | ConGetDate (std::span< std::string_view > argv)
static bool | ConGetSysDate (std::span< std::string_view > argv)
static bool | ConAlias (std::span< std::string_view > argv)
static bool | ConScreenShot (std::span< std::string_view > argv)
static bool | ConInfoCmd (std::span< std::string_view > argv)
static bool | ConDebugLevel (std::span< std::string_view > argv)
static bool | ConExit (std::span< std::string_view > argv)
static bool | ConPart (std::span< std::string_view > argv)
static bool | ConHelp (std::span< std::string_view > argv)
static bool | ConListCommands (std::span< std::string_view > argv)
static bool | ConListAliases (std::span< std::string_view > argv)
static bool | ConCompanies (std::span< std::string_view > argv)
static bool | ConSay (std::span< std::string_view > argv)
static bool | ConSayCompany (std::span< std::string_view > argv)
static bool | ConSayClient (std::span< std::string_view > argv)
static void | PerformNetworkAuthorizedKeyAction (std::string_view name, NetworkAuthorizedKeys *authorized_keys, ConNetworkAuthorizedKeyAction action, const std::string &authorized_key, CompanyID company=CompanyID::Invalid())
static bool | ConNetworkAuthorizedKey (std::span< std::string_view > argv)
static ContentType | StringToContentType (std::string_view str)
| Resolve a string to a content type.
static void | OutputContentState (const ContentInfo &ci)
| Outputs content state information to console.
static bool | ConContent (std::span< std::string_view > argv)
static bool | ConFont (std::span< std::string_view > argv)
static bool | ConSetting (std::span< std::string_view > argv)
static bool | ConSettingNewgame (std::span< std::string_view > argv)
static bool | ConListSettings (std::span< std::string_view > argv)
static bool | ConGamelogPrint (std::span< std::string_view > argv)
static bool | ConNewGRFReload (std::span< std::string_view > argv)
static bool | ConListDirs (std::span< std::string_view > argv)
static bool | ConNewGRFProfile (std::span< std::string_view > argv)
static bool | ConFramerate (std::span< std::string_view > argv)
static bool | ConFramerateWindow (std::span< std::string_view > argv)
static std::string | FormatLabel (uint32_t label)
| Format a label as a string.
static void | ConDumpRoadTypes ()
static void | ConDumpRailTypes ()
static void | ConDumpCargoTypes ()
static bool | ConDumpInfo (std::span< std::string_view > argv)
void | IConsoleStdLibRegister ()

## Variables
static uint | _script_current_depth
| Depth of scripts running (used to abort execution when ConReturn is encountered).
static std::string | _scheduled_monthly_script
| Script scheduled to execute by the 'schedule' console command (empty if no script is scheduled).
static const IntervalTimer< TimerGameCalendar > | _scheduled_monthly_timer
| Timer that runs every month of game time for the 'schedule' console command.
static ConsoleFileList | _console_file_list_savegame {FT_SAVEGAME, true}
| File storage cache for savegames.
static ConsoleFileList | _console_file_list_scenario {FT_SCENARIO, false}
| File storage cache for scenarios.
static ConsoleFileList | _console_file_list_heightmap {FT_HEIGHTMAP, false}
| File storage cache for heightmaps.
static const std::initializer_list< std::pair< std::string_view, NetworkAuthorizedKeys * > > | _console_cmd_authorized_keys
| All the known authorized keys with their name.

## Detailed Description

Implementation of the console hooks.

Definition in file console_cmds.cpp.

## Enumeration Type Documentation

## ◆ ConNetworkAuthorizedKeyAction

enum ConNetworkAuthorizedKeyAction : uint8_t

Definition at line 2053 of file console_cmds.cpp.

## Function Documentation

## ◆ CloseConsoleLogIfActive()

bool CloseConsoleLogIfActive | ( |  | ) |
| extern

Definition at line 64 of file console.cpp.

## ◆ ConAlias()

static bool ConAlias | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1688 of file console_cmds.cpp.

## ◆ ConBan()

static bool ConBan | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 746 of file console_cmds.cpp.

## ◆ ConBanList()

static bool ConBanList | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 802 of file console_cmds.cpp.

## ◆ ConChangeDirectory()

static bool ConChangeDirectory | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 615 of file console_cmds.cpp.

## ◆ ConClearBuffer()

static bool ConClearBuffer | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 659 of file console_cmds.cpp.

## ◆ ConClientNickChange()

static bool ConClientNickChange | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 914 of file console_cmds.cpp.

## ◆ ConCompanies()

static bool ConCompanies | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1945 of file console_cmds.cpp.

## ◆ ConContent()

static bool ConContent | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2233 of file console_cmds.cpp.

## ◆ ConDebugLevel()

static bool ConDebugLevel | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1822 of file console_cmds.cpp.

## ◆ ConDumpCargoTypes()

static void ConDumpCargoTypes | ( |  | ) |
| static

Definition at line 2783 of file console_cmds.cpp.

## ◆ ConDumpInfo()

static bool ConDumpInfo | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2841 of file console_cmds.cpp.

## ◆ ConDumpRailTypes()

static void ConDumpRailTypes | ( |  | ) |
| static

Definition at line 2745 of file console_cmds.cpp.

## ◆ ConDumpRoadTypes()

static void ConDumpRoadTypes | ( |  | ) |
| static

Definition at line 2708 of file console_cmds.cpp.

## ◆ ConEcho()

static bool ConEcho | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1288 of file console_cmds.cpp.

## ◆ ConEchoC()

static bool ConEchoC | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1300 of file console_cmds.cpp.

## ◆ ConExec()

static bool ConExec | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1168 of file console_cmds.cpp.

## ◆ ConExit()

static bool ConExit | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1841 of file console_cmds.cpp.

## ◆ ConFont()

static bool ConFont | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2322 of file console_cmds.cpp.

## ◆ ConFramerate()

static bool ConFramerate | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2665 of file console_cmds.cpp.

## ◆ ConFramerateWindow()

static bool ConFramerateWindow | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2676 of file console_cmds.cpp.

## ◆ ConGamelogPrint()

static bool ConGamelogPrint | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2437 of file console_cmds.cpp.

## ◆ ConGetDate()

static bool ConGetDate | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1665 of file console_cmds.cpp.

## ◆ ConGetSeed()

static bool ConGetSeed | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1653 of file console_cmds.cpp.

## ◆ ConGetSysDate()

static bool ConGetSysDate | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1677 of file console_cmds.cpp.

## ◆ ConHelp()

static bool ConHelp | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1872 of file console_cmds.cpp.

## ◆ ConHookClientOnly()

static ConsoleHookResult ConHookClientOnly | ( | bool | echo | ) |
| static

Check whether we are a client in a network game.

Returns
  Are we a client in a network game? True when yes, false otherwise.

Definition at line 163 of file console_cmds.cpp.

References _network_server, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, IConsolePrint(), and NetworkAvailable().

## ◆ ConHookNeedNetwork()

static ConsoleHookResult ConHookNeedNetwork | ( | bool | echo | ) |
| static

Check whether we are in a multiplayer game.

Returns
  True when we are client or server in a network game.

Definition at line 178 of file console_cmds.cpp.

References _network_server, _networking, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, IConsolePrint(), ClientNetworkGameSocketHandler::IsConnected(), and NetworkAvailable().

## ◆ ConHookNeedNonDedicatedNetwork()

static ConsoleHookResult ConHookNeedNonDedicatedNetwork | ( | bool | echo | ) |
| static

Check whether we are in a multiplayer game and are playing, i.e.

we are not the dedicated server.

Returns
  Are we a client or non-dedicated server in a network game? True when yes, false otherwise.

Definition at line 193 of file console_cmds.cpp.

References _network_dedicated, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, IConsolePrint(), and NetworkAvailable().

## ◆ ConHookNewGRFDeveloperTool()

static ConsoleHookResult ConHookNewGRFDeveloperTool | ( | bool | echo | ) |
| static

Definition at line 230 of file console_cmds.cpp.

## ◆ ConHookNoNetwork()

static ConsoleHookResult ConHookNoNetwork | ( | bool | echo | ) |
| static

Check whether we are in singleplayer mode.

Returns
  True when no network is active.

Definition at line 208 of file console_cmds.cpp.

References _networking, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, and IConsolePrint().

## ◆ ConHookServerOnly()

static ConsoleHookResult ConHookServerOnly | ( | bool | echo | ) |
| static

Check whether we are a server.

Returns
  Are we a server? True when yes, false otherwise.

Definition at line 148 of file console_cmds.cpp.

References _network_server, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, IConsolePrint(), and NetworkAvailable().

## ◆ ConHookServerOrNoNetwork()

static ConsoleHookResult ConHookServerOrNoNetwork | ( | bool | echo | ) |
| static

Check if are either in singleplayer or a server.

Returns
  True iff we are either in singleplayer or a server.

Definition at line 221 of file console_cmds.cpp.

References _network_server, _networking, CC_ERROR, CHR_ALLOW, CHR_DISALLOW, and IConsolePrint().

## ◆ ConInfoCmd()

static bool ConInfoCmd | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1800 of file console_cmds.cpp.

## ◆ ConJoinCompany()

static bool ConJoinCompany | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 958 of file console_cmds.cpp.

## ◆ ConKick()

static bool ConKick | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 723 of file console_cmds.cpp.

## ◆ ConKickOrBan()

static bool ConKickOrBan | ( | std::string_view | arg,
|  | bool | ban,
|  | std::string_view | reason
| ) |  |
| static

Definition at line 676 of file console_cmds.cpp.

## ◆ ConListAI()

static bool ConListAI | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1416 of file console_cmds.cpp.

## ◆ ConListAILibs()

static bool ConListAILibs | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1406 of file console_cmds.cpp.

## ◆ ConListAliases()

static bool ConListAliases | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1928 of file console_cmds.cpp.

## ◆ ConListCommands()

static bool ConListCommands | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1911 of file console_cmds.cpp.

## ◆ ConListDirs()

static bool ConListDirs | ( | std::span< std::string_view > | argv | ) |
| static

< Index of subdirectory type

< UI name for the directory

< Whether only the default (first existing) directory for this is interesting

Definition at line 2459 of file console_cmds.cpp.

References AI_DIR, AI_LIBRARY_DIR, AUTOSAVE_DIR, BASESET_DIR, CC_DEFAULT, CC_ERROR, CC_HELP, CC_INFO, FileExists(), GAME_DIR, GAME_LIBRARY_DIR, HEIGHTMAP_DIR, IConsolePrint(), NEWGRF_DIR, SAVE_DIR, SCENARIO_DIR, SCREENSHOT_DIR, SOCIAL_INTEGRATION_DIR, and StrEqualsIgnoreCase().

## ◆ ConListFiles()

static bool ConListFiles | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 567 of file console_cmds.cpp.

## ◆ ConListGame()

static bool ConListGame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1436 of file console_cmds.cpp.

## ◆ ConListGameLibs()

static bool ConListGameLibs | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1426 of file console_cmds.cpp.

## ◆ ConListHeightmaps()

static bool ConListHeightmaps | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 599 of file console_cmds.cpp.

## ◆ ConListScenarios()

static bool ConListScenarios | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 583 of file console_cmds.cpp.

## ◆ ConListSettings()

static bool ConListSettings | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2424 of file console_cmds.cpp.

## ◆ ConLoad()

static bool ConLoad | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 459 of file console_cmds.cpp.

## ◆ ConLoadHeightmap()

static bool ConLoadHeightmap | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 511 of file console_cmds.cpp.

## ◆ ConLoadScenario()

static bool ConLoadScenario | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 485 of file console_cmds.cpp.

## ◆ ConMoveClient()

static bool ConMoveClient | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1009 of file console_cmds.cpp.

## ◆ ConNetworkAuthorizedKey()

static bool ConNetworkAuthorizedKey | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2099 of file console_cmds.cpp.

## ◆ ConNetworkClients()

static bool ConNetworkClients | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1107 of file console_cmds.cpp.

## ◆ ConNetworkConnect()

static bool ConNetworkConnect | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1150 of file console_cmds.cpp.

## ◆ ConNetworkReconnect()

static bool ConNetworkReconnect | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1119 of file console_cmds.cpp.

## ◆ ConNewGame()

static bool ConNewGame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1319 of file console_cmds.cpp.

## ◆ ConNewGRFProfile()

static bool ConNewGRFProfile | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2528 of file console_cmds.cpp.

## ◆ ConNewGRFReload()

static bool ConNewGRFReload | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2448 of file console_cmds.cpp.

## ◆ ConPart()

static bool ConPart | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1854 of file console_cmds.cpp.

## ◆ ConPauseGame()

static bool ConPauseGame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 820 of file console_cmds.cpp.

## ◆ ConPrintFramerate()

void ConPrintFramerate | ( |  | ) |
| extern

Print performance statistics to game console.

Definition at line 999 of file framerate_gui.cpp.

References anonymous_namespace{framerate_gui.cpp}::_pf_data, CC_ERROR, IConsolePrint(), anonymous_namespace{framerate_gui.cpp}::NUM_FRAMERATE_POINTS, PFE_AI0, PFE_DRAWING, PFE_GAMELOOP, PFE_MAX, and PFE_VIDEO.

## ◆ ConPrintWorkingDirectory()

static bool ConPrintWorkingDirectory | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 644 of file console_cmds.cpp.

## ◆ ConRcon()

static bool ConRcon | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 868 of file console_cmds.cpp.

## ◆ ConReload()

static bool ConReload | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1362 of file console_cmds.cpp.

## ◆ ConReloadAI()

static bool ConReloadAI | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1520 of file console_cmds.cpp.

## ◆ ConRemove()

static bool ConRemove | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 537 of file console_cmds.cpp.

## ◆ ConRescanAI()

static bool ConRescanAI | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1605 of file console_cmds.cpp.

## ◆ ConRescanGame()

static bool ConRescanGame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1622 of file console_cmds.cpp.

## ◆ ConRescanNewGRF()

static bool ConRescanNewGRF | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1639 of file console_cmds.cpp.

## ◆ ConResetCompany()

static bool ConResetCompany | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1062 of file console_cmds.cpp.

## ◆ ConResetEnginePool()

static bool ConResetEnginePool | ( | std::span< std::string_view > | argv | ) |
| static

Reset status of the engine pool.

Returns
  Will always return true.

Note
  Resetting the pool only succeeds when there are no vehicles ingame.

Definition at line 262 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, IConsolePrint(), and EngineOverrideManager::ResetToCurrentNewGRFConfig().

## ◆ ConResetEngines()

static bool ConResetEngines | ( | std::span< std::string_view > | argv | ) |
| static

Reset status of all engines.

Returns
  Will always succeed.

Definition at line 246 of file console_cmds.cpp.

References CC_HELP, IConsolePrint(), and StartupEngines().

## ◆ ConRestart()

static bool ConRestart | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1341 of file console_cmds.cpp.

## ◆ ConReturn()

static bool ConReturn | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1245 of file console_cmds.cpp.

## ◆ ConSave()

static bool ConSave | ( | std::span< std::string_view > | argv | ) |
| static

Save the map to a file.

param filename the filename to save the map to.

Returns
  True when help was displayed or the file attempted to be saved.

Definition at line 420 of file console_cmds.cpp.

References CC_DEFAULT, CC_ERROR, CC_HELP, CC_INFO, DFT_GAME_FILE, IConsolePrint(), SAVE_DIR, SaveOrLoad(), SL_OK, and SLO_SAVE.

## ◆ ConSaveConfig()

static bool ConSaveConfig | ( | std::span< std::string_view > | argv | ) |
| static

Explicitly save the configuration.

Returns
  True.

Definition at line 446 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, IConsolePrint(), and SaveToConfig().

## ◆ ConSay()

static bool ConSay | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1970 of file console_cmds.cpp.

## ◆ ConSayClient()

static bool ConSayClient | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2020 of file console_cmds.cpp.

## ◆ ConSayCompany()

static bool ConSayCompany | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1989 of file console_cmds.cpp.

## ◆ ConSchedule()

static bool ConSchedule | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1216 of file console_cmds.cpp.

## ◆ ConScreenShot()

static bool ConScreenShot | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1708 of file console_cmds.cpp.

## ◆ ConScript()

static bool ConScript | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1264 of file console_cmds.cpp.

## ◆ ConScrollToTile()

static bool ConScrollToTile | ( | std::span< std::string_view > | argv | ) |
| static

Scroll to a tile on the map.

param x tile number or tile x coordinate. param y optional y coordinate.

Note
  When only one argument is given it is interpreted as the tile number. When two arguments are given, they are interpreted as the tile's x and y coordinates.

Returns
  True when either console help was shown or a proper amount of parameters given.

Definition at line 365 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, IConsolePrint(), ParseInteger(), ScrollMainWindowToTile(), Map::Size(), Map::SizeX(), Map::SizeY(), and TileXY().

## ◆ ConServerInfo()

static bool ConServerInfo | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 898 of file console_cmds.cpp.

## ◆ ConSetting()

static bool ConSetting | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2386 of file console_cmds.cpp.

## ◆ ConSettingNewgame()

static bool ConSettingNewgame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 2405 of file console_cmds.cpp.

## ◆ ConStartAI()

static bool ConStartAI | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1446 of file console_cmds.cpp.

## ◆ ConStatus()

static bool ConStatus | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 887 of file console_cmds.cpp.

## ◆ ConStopAI()

static bool ConStopAI | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 1563 of file console_cmds.cpp.

## ◆ ConUnBan()

static bool ConUnBan | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 770 of file console_cmds.cpp.

## ◆ ConUnpauseGame()

static bool ConUnpauseGame | ( | std::span< std::string_view > | argv | ) |
| static

Definition at line 842 of file console_cmds.cpp.

## ◆ ConZoomToLevel()

static bool ConZoomToLevel | ( | std::span< std::string_view > | argv | ) |
| static

Zoom map to given level.

param level As defined by ZoomLevel and as limited by zoom_min/zoom_max from GUISettings.

Returns
  True when either console help was shown or a proper amount of parameters given.

Definition at line 313 of file console_cmds.cpp.

References _settings_client, Begin, CC_ERROR, CC_HELP, DoZoomInOutWindow(), End, GetMainWindow(), ClientSettings::gui, IConsolePrint(), IsInsideMM(), Max, Min, Window::viewport, Viewport::zoom, ZOOM_IN, GUISettings::zoom_max, GUISettings::zoom_min, and ZOOM_OUT.

## ◆ FormatLabel()

static std::string FormatLabel | ( | uint32_t | label | ) |
| static

Format a label as a string.

If all elements are visible ASCII (excluding space) then the label will be formatted as a string of 4 characters, otherwise it will be output as an 8-digit hexadecimal value.

Parameters

  label | Label to format.

Returns
  string representation of label.

Definition at line 2699 of file console_cmds.cpp.

References GB().

## ◆ GetAllGRFFiles()

std::span< const GRFFile > GetAllGRFFiles | ( |  | ) |
| extern

Definition at line 65 of file newgrf.cpp.

## ◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister | ( |  | ) |

Definition at line 2872 of file console_cmds.cpp.

## ◆ NetworkAvailable()

static bool NetworkAvailable | ( | bool | echo | ) |
| inlinestatic

Check network availability and inform in console about failure of detection.

Returns
  Network availability.

Definition at line 135 of file console_cmds.cpp.

References _network_available, CC_ERROR, and IConsolePrint().

Referenced by ConHookClientOnly(), ConHookNeedNetwork(), ConHookNeedNonDedicatedNetwork(), and ConHookServerOnly().

## ◆ OutputContentState()

static void OutputContentState | ( | const ContentInfo & | ci | ) |
| static

Outputs content state information to console.

Parameters

  ci | the content info

Definition at line 2223 of file console_cmds.cpp.

References CC_COMMAND, CC_ERROR, CC_INFO, CC_WHITE, CONTENT_TYPE_BEGIN, CONTENT_TYPE_END, FormatArrayAsHex(), IConsolePrint(), ContentInfo::id, lengthof, ContentInfo::md5sum, ContentInfo::name, ContentInfo::state, to_underlying(), ContentInfo::type, and ContentInfo::unique_id.

## ◆ ParseCompanyID()

static std::optional< CompanyID > ParseCompanyID | ( | std::string_view | arg | ) |
| static

Definition at line 951 of file console_cmds.cpp.

## ◆ ParseType()

template<typename T >

static std::optional< T > ParseType | ( | std::string_view | arg | ) |
| static

Parse an integer using ParseInteger and convert it to the requested type.

Parameters

  arg | The string to be converted.

Template Parameters

  T | The type to return.

Returns
  The number in the given type, or std::nullopt when it could not be parsed.

Definition at line 85 of file console_cmds.cpp.

References ParseInteger().

## ◆ PerformNetworkAuthorizedKeyAction()

static void PerformNetworkAuthorizedKeyAction | ( | std::string_view | name,
|  | NetworkAuthorizedKeys * | authorized_keys,
|  | ConNetworkAuthorizedKeyAction | action,
|  | const std::string & | authorized_key,
|  | CompanyID | company = `CompanyID::Invalid()`
| ) |  |
| static

Definition at line 2059 of file console_cmds.cpp.

## ◆ PrintLineByLine()

static void PrintLineByLine | ( | const std::string & | full_string | ) |
| static

Print a text buffer line by line to the console.

Lines are separated by '
'.

Parameters

  full_string | The multi-line string to print.

Definition at line 1386 of file console_cmds.cpp.

References CC_DEFAULT, and IConsolePrint().

## ◆ PrintList()

template<typename F , typename ... Args>

bool PrintList | ( | F | list_function,
|  | Args... | args
| ) |  |

Definition at line 1396 of file console_cmds.cpp.

## ◆ ShowFramerateWindow()

void ShowFramerateWindow | ( |  | ) |
| extern

Open the general framerate window.

Definition at line 986 of file framerate_gui.cpp.

Referenced by MenuClickHelp().

## ◆ StringToContentType()

static ContentType StringToContentType | ( | std::string_view | str | ) |
| static

Resolve a string to a content type.

Definition at line 2185 of file console_cmds.cpp.

References CONTENT_TYPE_AI, CONTENT_TYPE_AI_LIBRARY, CONTENT_TYPE_BASE_GRAPHICS, CONTENT_TYPE_END, CONTENT_TYPE_HEIGHTMAP, CONTENT_TYPE_NEWGRF, CONTENT_TYPE_SCENARIO, and StrEqualsIgnoreCase().

## Variable Documentation

## ◆ _console_cmd_authorized_keys

const std::initializer_list<std::pair<std::string_view, NetworkAuthorizedKeys *> > _console_cmd_authorized_keys
| static

Initial value:
{
{ "admin", &_settings_client.network.admin_authorized_keys },
{ "rcon", &_settings_client.network.rcon_authorized_keys },
{ "server", &_settings_client.network.server_authorized_keys },
}
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
ClientSettings::network
NetworkSettings network
settings related to the network
Definition settings_type.h:651
NetworkSettings::admin_authorized_keys
NetworkAuthorizedKeys admin_authorized_keys
Public keys of clients that are authorized to use the admin network.
Definition settings_type.h:356
NetworkSettings::rcon_authorized_keys
NetworkAuthorizedKeys rcon_authorized_keys
Public keys of clients that are authorized to use the rconsole (server side).
Definition settings_type.h:353
NetworkSettings::server_authorized_keys
NetworkAuthorizedKeys server_authorized_keys
Public keys of clients that are authorized to connect to the game.
Definition settings_type.h:351

All the known authorized keys with their name.

Definition at line 2047 of file console_cmds.cpp.

## ◆ _console_file_list_heightmap

ConsoleFileList _console_file_list_heightmap {FT_HEIGHTMAP, false}
| static

File storage cache for heightmaps.

Definition at line 125 of file console_cmds.cpp.

## ◆ _console_file_list_savegame

ConsoleFileList _console_file_list_savegame {FT_SAVEGAME, true}
| static

File storage cache for savegames.

Definition at line 123 of file console_cmds.cpp.

## ◆ _console_file_list_scenario

ConsoleFileList _console_file_list_scenario {FT_SCENARIO, false}
| static

File storage cache for scenarios.

Definition at line 124 of file console_cmds.cpp.

## ◆ _scheduled_monthly_script

std::string _scheduled_monthly_script
| static

Script scheduled to execute by the 'schedule' console command (empty if no script is scheduled).

Definition at line 61 of file console_cmds.cpp.

## ◆ _scheduled_monthly_timer

const IntervalTimer<TimerGameCalendar> _scheduled_monthly_timer
| static

Initial value:
= {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [](auto) {
if (_scheduled_monthly_script.empty()) {
return;
}
const std::string filename = _scheduled_monthly_script;
_scheduled_monthly_script.clear();
IConsolePrint(CC_DEFAULT, "Executing scheduled script file '{}'...", filename);
IConsoleCmdExec(fmt::format("exec {}", filename));
}}
IConsoleCmdExec
void IConsoleCmdExec(std::string_view command_string, const uint recurse_count)
Execute a given command passed to us.
Definition console.cpp:269
IConsolePrint
void IConsolePrint(TextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.
Definition console.cpp:90
_scheduled_monthly_script
static std::string _scheduled_monthly_script
Script scheduled to execute by the 'schedule' console command (empty if no script is scheduled).
Definition console_cmds.cpp:61
CC_DEFAULT
static const TextColour CC_DEFAULT
Default colour of the console.
Definition console_type.h:23

Timer that runs every month of game time for the 'schedule' console command.

Definition at line 64 of file console_cmds.cpp.

## ◆ _script_current_depth

uint _script_current_depth
| static

Depth of scripts running (used to abort execution when ConReturn is encountered).

Definition at line 58 of file console_cmds.cpp.