OpenTTD Source 20260206-master-g4d4e37dbf1
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 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 2053 of file console_cmds.cpp.

Function Documentation

◆ CloseConsoleLogIfActive()

bool CloseConsoleLogIfActive ( )
extern

Definition at line 64 of file console.cpp.

◆ ConAlias()

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

Definition at line 1688 of file console_cmds.cpp.

◆ ConBan()

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

Definition at line 746 of file console_cmds.cpp.

◆ ConBanList()

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

Definition at line 802 of file console_cmds.cpp.

◆ ConChangeDirectory()

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

Definition at line 615 of file console_cmds.cpp.

◆ ConClearBuffer()

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

Definition at line 659 of file console_cmds.cpp.

◆ ConClientNickChange()

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

Definition at line 914 of file console_cmds.cpp.

◆ ConCompanies()

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

Definition at line 1945 of file console_cmds.cpp.

◆ ConContent()

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

Definition at line 2233 of file console_cmds.cpp.

◆ ConDebugLevel()

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

Definition at line 1822 of file console_cmds.cpp.

◆ ConDumpCargoTypes()

void ConDumpCargoTypes ( )
static

Definition at line 2783 of file console_cmds.cpp.

◆ ConDumpInfo()

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

Definition at line 2841 of file console_cmds.cpp.

◆ ConDumpRailTypes()

void ConDumpRailTypes ( )
static

Definition at line 2745 of file console_cmds.cpp.

◆ ConDumpRoadTypes()

void ConDumpRoadTypes ( )
static

Definition at line 2708 of file console_cmds.cpp.

◆ ConEcho()

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

Definition at line 1288 of file console_cmds.cpp.

◆ ConEchoC()

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

Definition at line 1300 of file console_cmds.cpp.

◆ ConExec()

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

Definition at line 1168 of file console_cmds.cpp.

◆ ConExit()

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

Definition at line 1841 of file console_cmds.cpp.

◆ ConFont()

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

Definition at line 2322 of file console_cmds.cpp.

◆ ConFramerate()

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

Definition at line 2665 of file console_cmds.cpp.

◆ ConFramerateWindow()

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

Definition at line 2676 of file console_cmds.cpp.

◆ ConGamelogPrint()

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

Definition at line 2437 of file console_cmds.cpp.

◆ ConGetDate()

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

Definition at line 1665 of file console_cmds.cpp.

◆ ConGetSeed()

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

Definition at line 1653 of file console_cmds.cpp.

◆ ConGetSysDate()

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

Definition at line 1677 of file console_cmds.cpp.

◆ ConHelp()

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

Definition at line 1872 of file console_cmds.cpp.

◆ ConHookClientOnly()

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()

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()

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()

ConsoleHookResult ConHookNewGRFDeveloperTool ( bool echo)
static

Definition at line 230 of file console_cmds.cpp.

◆ ConHookNoNetwork()

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()

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()

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()

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

Definition at line 1800 of file console_cmds.cpp.

◆ ConJoinCompany()

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

Definition at line 958 of file console_cmds.cpp.

◆ ConKick()

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

Definition at line 723 of file console_cmds.cpp.

◆ ConKickOrBan()

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

Definition at line 676 of file console_cmds.cpp.

◆ ConListAI()

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

Definition at line 1416 of file console_cmds.cpp.

◆ ConListAILibs()

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

Definition at line 1406 of file console_cmds.cpp.

◆ ConListAliases()

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

Definition at line 1928 of file console_cmds.cpp.

◆ ConListCommands()

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

Definition at line 1911 of file console_cmds.cpp.

◆ ConListDirs()

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

< UI name for the directory

< Index of subdirectory type

< 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()

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

Definition at line 567 of file console_cmds.cpp.

◆ ConListGame()

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

Definition at line 1436 of file console_cmds.cpp.

◆ ConListGameLibs()

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

Definition at line 1426 of file console_cmds.cpp.

◆ ConListHeightmaps()

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

Definition at line 599 of file console_cmds.cpp.

◆ ConListScenarios()

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

Definition at line 583 of file console_cmds.cpp.

◆ ConListSettings()

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

Definition at line 2424 of file console_cmds.cpp.

◆ ConLoad()

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

Definition at line 459 of file console_cmds.cpp.

◆ ConLoadHeightmap()

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

Definition at line 511 of file console_cmds.cpp.

◆ ConLoadScenario()

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

Definition at line 485 of file console_cmds.cpp.

◆ ConMoveClient()

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

Definition at line 1009 of file console_cmds.cpp.

◆ ConNetworkAuthorizedKey()

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

Definition at line 2099 of file console_cmds.cpp.

◆ ConNetworkClients()

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

Definition at line 1107 of file console_cmds.cpp.

◆ ConNetworkConnect()

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

Definition at line 1150 of file console_cmds.cpp.

◆ ConNetworkReconnect()

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

Definition at line 1119 of file console_cmds.cpp.

◆ ConNewGame()

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

Definition at line 1319 of file console_cmds.cpp.

◆ ConNewGRFProfile()

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

Definition at line 2528 of file console_cmds.cpp.

◆ ConNewGRFReload()

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

Definition at line 2448 of file console_cmds.cpp.

◆ ConPart()

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

Definition at line 1854 of file console_cmds.cpp.

◆ ConPauseGame()

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

Definition at line 820 of file console_cmds.cpp.

◆ ConPrintFramerate()

void ConPrintFramerate ( )
extern

◆ ConPrintWorkingDirectory()

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

Definition at line 644 of file console_cmds.cpp.

◆ ConRcon()

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

Definition at line 868 of file console_cmds.cpp.

◆ ConReload()

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

Definition at line 1362 of file console_cmds.cpp.

◆ ConReloadAI()

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

Definition at line 1520 of file console_cmds.cpp.

◆ ConRemove()

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

Definition at line 537 of file console_cmds.cpp.

◆ ConRescanAI()

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

Definition at line 1605 of file console_cmds.cpp.

◆ ConRescanGame()

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

Definition at line 1622 of file console_cmds.cpp.

◆ ConRescanNewGRF()

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

Definition at line 1639 of file console_cmds.cpp.

◆ ConResetCompany()

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

Definition at line 1062 of file console_cmds.cpp.

◆ ConResetEnginePool()

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()

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()

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

Definition at line 1341 of file console_cmds.cpp.

◆ ConReturn()

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

Definition at line 1245 of file console_cmds.cpp.

◆ ConSave()

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()

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()

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

Definition at line 1970 of file console_cmds.cpp.

◆ ConSayClient()

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

Definition at line 2020 of file console_cmds.cpp.

◆ ConSayCompany()

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

Definition at line 1989 of file console_cmds.cpp.

◆ ConSchedule()

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

Definition at line 1216 of file console_cmds.cpp.

◆ ConScreenShot()

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

Definition at line 1708 of file console_cmds.cpp.

◆ ConScript()

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

Definition at line 1264 of file console_cmds.cpp.

◆ ConScrollToTile()

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()

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

Definition at line 898 of file console_cmds.cpp.

◆ ConSetting()

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

Definition at line 2386 of file console_cmds.cpp.

◆ ConSettingNewgame()

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

Definition at line 2405 of file console_cmds.cpp.

◆ ConStartAI()

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

Definition at line 1446 of file console_cmds.cpp.

◆ ConStatus()

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

Definition at line 887 of file console_cmds.cpp.

◆ ConStopAI()

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

Definition at line 1563 of file console_cmds.cpp.

◆ ConUnBan()

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

Definition at line 770 of file console_cmds.cpp.

◆ ConUnpauseGame()

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

Definition at line 842 of file console_cmds.cpp.

◆ ConZoomToLevel()

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(), IConsolePrint(), IsInsideMM(), Max, Min, ParseInteger(), Window::viewport, Viewport::zoom, ZOOM_IN, and ZOOM_OUT.

◆ FormatLabel()

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 2699 of file console_cmds.cpp.

References GB().

◆ GetAllGRFFiles()

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

Definition at line 66 of file newgrf.cpp.

◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister ( )

Definition at line 2872 of file console_cmds.cpp.

◆ NetworkAvailable()

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()

void OutputContentState ( const ContentInfo & ci)
static

◆ ParseCompanyID()

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

Definition at line 951 of file console_cmds.cpp.

◆ ParseType()

template<typename T>
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 85 of file console_cmds.cpp.

References ParseInteger().

◆ PerformNetworkAuthorizedKeyAction()

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()

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 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.

References AllocateWindowDescFront().

Referenced by MenuClickHelp().

◆ StringToContentType()

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:
{
{ "admin", &_settings_client.network.admin_authorized_keys },
{ "rcon", &_settings_client.network.rcon_authorized_keys },
}
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
NetworkSettings network
settings related to the network
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 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::Trigger::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:271
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 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.