OpenTTD Source 20250517-master-g617169c1c9
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 "table/strings.h"
#include "safeguards.h"
#include "network/network_content.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< CompanyIDParseCompanyID (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 GRFFileGetAllGRFFiles ()
 
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 2045 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 1680 of file console_cmds.cpp.

◆ ConBan()

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

Definition at line 738 of file console_cmds.cpp.

◆ ConBanList()

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

Definition at line 794 of file console_cmds.cpp.

◆ ConChangeDirectory()

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

Definition at line 607 of file console_cmds.cpp.

◆ ConClearBuffer()

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

Definition at line 651 of file console_cmds.cpp.

◆ ConClientNickChange()

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

Definition at line 906 of file console_cmds.cpp.

◆ ConCompanies()

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

Definition at line 1937 of file console_cmds.cpp.

◆ ConContent()

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

Definition at line 2226 of file console_cmds.cpp.

◆ ConDebugLevel()

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

Definition at line 1814 of file console_cmds.cpp.

◆ ConDumpCargoTypes()

static void ConDumpCargoTypes ( )
static

Definition at line 2776 of file console_cmds.cpp.

◆ ConDumpInfo()

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

Definition at line 2834 of file console_cmds.cpp.

◆ ConDumpRailTypes()

static void ConDumpRailTypes ( )
static

Definition at line 2738 of file console_cmds.cpp.

◆ ConDumpRoadTypes()

static void ConDumpRoadTypes ( )
static

Definition at line 2701 of file console_cmds.cpp.

◆ ConEcho()

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

Definition at line 1280 of file console_cmds.cpp.

◆ ConEchoC()

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

Definition at line 1292 of file console_cmds.cpp.

◆ ConExec()

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

Definition at line 1160 of file console_cmds.cpp.

◆ ConExit()

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

Definition at line 1833 of file console_cmds.cpp.

◆ ConFont()

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

Definition at line 2315 of file console_cmds.cpp.

◆ ConFramerate()

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

Definition at line 2658 of file console_cmds.cpp.

◆ ConFramerateWindow()

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

Definition at line 2669 of file console_cmds.cpp.

◆ ConGamelogPrint()

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

Definition at line 2430 of file console_cmds.cpp.

◆ ConGetDate()

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

Definition at line 1657 of file console_cmds.cpp.

◆ ConGetSeed()

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

Definition at line 1645 of file console_cmds.cpp.

◆ ConGetSysDate()

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

Definition at line 1669 of file console_cmds.cpp.

◆ ConHelp()

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

Definition at line 1864 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 159 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 174 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 189 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 226 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 204 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 144 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 217 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 1792 of file console_cmds.cpp.

◆ ConJoinCompany()

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

Definition at line 950 of file console_cmds.cpp.

◆ ConKick()

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

Definition at line 715 of file console_cmds.cpp.

◆ ConKickOrBan()

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

Definition at line 668 of file console_cmds.cpp.

◆ ConListAI()

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

Definition at line 1408 of file console_cmds.cpp.

◆ ConListAILibs()

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

Definition at line 1398 of file console_cmds.cpp.

◆ ConListAliases()

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

Definition at line 1920 of file console_cmds.cpp.

◆ ConListCommands()

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

Definition at line 1903 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 2452 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 559 of file console_cmds.cpp.

◆ ConListGame()

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

Definition at line 1428 of file console_cmds.cpp.

◆ ConListGameLibs()

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

Definition at line 1418 of file console_cmds.cpp.

◆ ConListHeightmaps()

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

Definition at line 591 of file console_cmds.cpp.

◆ ConListScenarios()

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

Definition at line 575 of file console_cmds.cpp.

◆ ConListSettings()

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

Definition at line 2417 of file console_cmds.cpp.

◆ ConLoad()

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

Definition at line 455 of file console_cmds.cpp.

◆ ConLoadHeightmap()

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

Definition at line 507 of file console_cmds.cpp.

◆ ConLoadScenario()

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

Definition at line 481 of file console_cmds.cpp.

◆ ConMoveClient()

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

Definition at line 1001 of file console_cmds.cpp.

◆ ConNetworkAuthorizedKey()

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

Definition at line 2091 of file console_cmds.cpp.

◆ ConNetworkClients()

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

Definition at line 1099 of file console_cmds.cpp.

◆ ConNetworkConnect()

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

Definition at line 1142 of file console_cmds.cpp.

◆ ConNetworkReconnect()

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

Definition at line 1111 of file console_cmds.cpp.

◆ ConNewGame()

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

Definition at line 1311 of file console_cmds.cpp.

◆ ConNewGRFProfile()

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

Definition at line 2521 of file console_cmds.cpp.

◆ ConNewGRFReload()

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

Definition at line 2441 of file console_cmds.cpp.

◆ ConPart()

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

Definition at line 1846 of file console_cmds.cpp.

◆ ConPauseGame()

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

Definition at line 812 of file console_cmds.cpp.

◆ ConPrintFramerate()

void ConPrintFramerate ( )
extern

◆ ConPrintWorkingDirectory()

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

Definition at line 636 of file console_cmds.cpp.

◆ ConRcon()

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

Definition at line 860 of file console_cmds.cpp.

◆ ConReload()

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

Definition at line 1354 of file console_cmds.cpp.

◆ ConReloadAI()

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

Definition at line 1512 of file console_cmds.cpp.

◆ ConRemove()

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

Definition at line 533 of file console_cmds.cpp.

◆ ConRescanAI()

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

Definition at line 1597 of file console_cmds.cpp.

◆ ConRescanGame()

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

Definition at line 1614 of file console_cmds.cpp.

◆ ConRescanNewGRF()

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

Definition at line 1631 of file console_cmds.cpp.

◆ ConResetCompany()

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

Definition at line 1054 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 258 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 242 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 1333 of file console_cmds.cpp.

◆ ConReturn()

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

Definition at line 1237 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 416 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 442 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 1962 of file console_cmds.cpp.

◆ ConSayClient()

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

Definition at line 2012 of file console_cmds.cpp.

◆ ConSayCompany()

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

Definition at line 1981 of file console_cmds.cpp.

◆ ConSchedule()

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

Definition at line 1208 of file console_cmds.cpp.

◆ ConScreenShot()

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

Definition at line 1700 of file console_cmds.cpp.

◆ ConScript()

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

Definition at line 1256 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 361 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 890 of file console_cmds.cpp.

◆ ConSetting()

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

Definition at line 2379 of file console_cmds.cpp.

◆ ConSettingNewgame()

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

Definition at line 2398 of file console_cmds.cpp.

◆ ConStartAI()

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

Definition at line 1438 of file console_cmds.cpp.

◆ ConStatus()

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

Definition at line 879 of file console_cmds.cpp.

◆ ConStopAI()

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

Definition at line 1555 of file console_cmds.cpp.

◆ ConUnBan()

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

Definition at line 762 of file console_cmds.cpp.

◆ ConUnpauseGame()

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

Definition at line 834 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 309 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
labelLabel to format.
Returns
string representation of label.

Definition at line 2692 of file console_cmds.cpp.

References GB().

◆ GetAllGRFFiles()

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

Definition at line 63 of file newgrf.cpp.

◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister ( )

Definition at line 2865 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 131 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

◆ ParseCompanyID()

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

Definition at line 943 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
argThe string to be converted.
Template Parameters
TThe type to return.
Returns
The number in the given type, or std::nullopt when it could not be parsed.

Definition at line 81 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 2051 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_stringThe multi-line string to print.

Definition at line 1378 of file console_cmds.cpp.

References CC_DEFAULT, and IConsolePrint().

◆ PrintList()

template<typename F , typename ... Args>
bool PrintList ( list_function,
Args...  args 
)

Definition at line 1388 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

Variable Documentation

◆ _console_cmd_authorized_keys

const std::initializer_list<std::pair<std::string_view, NetworkAuthorizedKeys *> > _console_cmd_authorized_keys
static
Initial value:
{
}
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:59
NetworkSettings network
settings related to the network
NetworkAuthorizedKeys admin_authorized_keys
Public keys of clients that are authorized to use the admin network.
NetworkAuthorizedKeys rcon_authorized_keys
Public keys of clients that are authorized to use the rconsole (server side).
NetworkAuthorizedKeys server_authorized_keys
Public keys of clients that are authorized to connect to the game.

All the known authorized keys with their name.

Definition at line 2039 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 121 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 119 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 120 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 57 of file console_cmds.cpp.

◆ _scheduled_monthly_timer

const IntervalTimer<TimerGameCalendar> _scheduled_monthly_timer
static
Initial value:
= {{TimerGameCalendar::MONTH, TimerGameCalendar::Priority::NONE}, [](auto) {
return;
}
const std::string filename = _scheduled_monthly_script;
IConsolePrint(CC_DEFAULT, "Executing scheduled script file '{}'...", filename);
IConsoleCmdExec(fmt::format("exec {}", filename));
}}
void IConsoleCmdExec(std::string_view command_string, const uint recurse_count)
Execute a given command passed to us.
Definition console.cpp:269
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
static std::string _scheduled_monthly_script
Script scheduled to execute by the 'schedule' console command (empty if no script is scheduled).
static const TextColour CC_DEFAULT
Default colour of the console.

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

Definition at line 60 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 54 of file console_cmds.cpp.