OpenTTD Source 20241224-master-gf74b0cf984
console_cmds.cpp File Reference

Implementation of the console hooks. More...

#include "stdafx.h"
#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 "table/strings.h"
#include "3rdparty/fmt/chrono.h"
#include "company_cmd.h"
#include "misc_cmd.h"
#include <sstream>
#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...
 

Macros

#define DEF_CONSOLE_CMD(function)   static bool function([[maybe_unused]] uint8_t argc, [[maybe_unused]] char *argv[])
 
#define DEF_CONSOLE_HOOK(function)   static ConsoleHookResult function(bool echo)
 

Enumerations

enum  ConNetworkAuthorizedKeyAction { CNAKA_LIST , CNAKA_ADD , CNAKA_REMOVE }
 

Functions

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

Macro Definition Documentation

◆ DEF_CONSOLE_CMD

#define DEF_CONSOLE_CMD (   function)    static bool function([[maybe_unused]] uint8_t argc, [[maybe_unused]] char *argv[])

Definition at line 110 of file console_cmds.cpp.

◆ DEF_CONSOLE_HOOK

#define DEF_CONSOLE_HOOK (   function)    static ConsoleHookResult function(bool echo)

Definition at line 111 of file console_cmds.cpp.

Enumeration Type Documentation

◆ ConNetworkAuthorizedKeyAction

enum ConNetworkAuthorizedKeyAction

Definition at line 1962 of file console_cmds.cpp.

Function Documentation

◆ CloseConsoleLogIfActive()

bool CloseConsoleLogIfActive ( )
extern

Definition at line 63 of file console.cpp.

◆ ConDumpCargoTypes()

static void ConDumpCargoTypes ( )
static

Definition at line 2682 of file console_cmds.cpp.

◆ ConDumpRailTypes()

static void ConDumpRailTypes ( )
static

Definition at line 2644 of file console_cmds.cpp.

◆ ConDumpRoadTypes()

static void ConDumpRoadTypes ( )
static

Definition at line 2607 of file console_cmds.cpp.

◆ ConKickOrBan()

static bool ConKickOrBan ( const char *  argv,
bool  ban,
const std::string &  reason 
)
static

Definition at line 664 of file console_cmds.cpp.

◆ ConPrintFramerate()

void ConPrintFramerate ( )
extern

◆ DEF_CONSOLE_CMD() [1/80]

DEF_CONSOLE_CMD ( ConAlias  )

Definition at line 1618 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [2/80]

DEF_CONSOLE_CMD ( ConBan  )

Definition at line 730 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [3/80]

DEF_CONSOLE_CMD ( ConBanList  )

Definition at line 786 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [4/80]

DEF_CONSOLE_CMD ( ConChangeDirectory  )

Definition at line 605 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [5/80]

DEF_CONSOLE_CMD ( ConClearBuffer  )

Definition at line 647 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [6/80]

DEF_CONSOLE_CMD ( ConClientNickChange  )

Definition at line 898 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [7/80]

DEF_CONSOLE_CMD ( ConCompanies  )

Definition at line 1864 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [8/80]

DEF_CONSOLE_CMD ( ConContent  )

Definition at line 2143 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [9/80]

DEF_CONSOLE_CMD ( ConDebugLevel  )

Definition at line 1741 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [10/80]

DEF_CONSOLE_CMD ( ConDumpInfo  )

Definition at line 2742 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [11/80]

DEF_CONSOLE_CMD ( ConEcho  )

Definition at line 1246 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [12/80]

DEF_CONSOLE_CMD ( ConEchoC  )

Definition at line 1258 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [13/80]

DEF_CONSOLE_CMD ( ConExec  )

Definition at line 1124 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [14/80]

DEF_CONSOLE_CMD ( ConExit  )

Definition at line 1760 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [15/80]

DEF_CONSOLE_CMD ( ConFont  )

Definition at line 2228 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [16/80]

DEF_CONSOLE_CMD ( ConFramerate  )

Definition at line 2564 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [17/80]

DEF_CONSOLE_CMD ( ConFramerateWindow  )

Definition at line 2575 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [18/80]

DEF_CONSOLE_CMD ( ConGamelogPrint  )

Definition at line 2343 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [19/80]

DEF_CONSOLE_CMD ( ConGetDate  )

Definition at line 1594 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [20/80]

DEF_CONSOLE_CMD ( ConGetSeed  )

Definition at line 1582 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [21/80]

DEF_CONSOLE_CMD ( ConGetSysDate  )

Definition at line 1606 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [22/80]

DEF_CONSOLE_CMD ( ConHelp  )

Definition at line 1791 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [23/80]

DEF_CONSOLE_CMD ( ConInfoCmd  )

Definition at line 1719 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [24/80]

DEF_CONSOLE_CMD ( ConJoinCompany  )

Definition at line 932 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [25/80]

DEF_CONSOLE_CMD ( ConKick  )

Definition at line 707 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [26/80]

DEF_CONSOLE_CMD ( ConListAI  )

Definition at line 1357 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [27/80]

DEF_CONSOLE_CMD ( ConListAILibs  )

Definition at line 1347 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [28/80]

DEF_CONSOLE_CMD ( ConListAliases  )

Definition at line 1847 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [29/80]

DEF_CONSOLE_CMD ( ConListCommands  )

Definition at line 1830 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [30/80]

DEF_CONSOLE_CMD ( ConListDirs  )

< Index of subdirectory type

< UI name for the directory

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

Definition at line 2365 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().

◆ DEF_CONSOLE_CMD() [31/80]

DEF_CONSOLE_CMD ( ConListFiles  )

Definition at line 557 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [32/80]

DEF_CONSOLE_CMD ( ConListGame  )

Definition at line 1377 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [33/80]

DEF_CONSOLE_CMD ( ConListGameLibs  )

Definition at line 1367 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [34/80]

DEF_CONSOLE_CMD ( ConListHeightmaps  )

Definition at line 589 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [35/80]

DEF_CONSOLE_CMD ( ConListScenarios  )

Definition at line 573 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [36/80]

DEF_CONSOLE_CMD ( ConListSettings  )

Definition at line 2330 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [37/80]

DEF_CONSOLE_CMD ( ConLoad  )

Definition at line 453 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [38/80]

DEF_CONSOLE_CMD ( ConLoadHeightmap  )

Definition at line 505 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [39/80]

DEF_CONSOLE_CMD ( ConLoadScenario  )

Definition at line 479 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [40/80]

DEF_CONSOLE_CMD ( ConMoveClient  )

Definition at line 979 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [41/80]

DEF_CONSOLE_CMD ( ConNetworkAuthorizedKey  )

Definition at line 2008 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [42/80]

DEF_CONSOLE_CMD ( ConNetworkClients  )

Definition at line 1063 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [43/80]

DEF_CONSOLE_CMD ( ConNetworkConnect  )

Definition at line 1106 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [44/80]

DEF_CONSOLE_CMD ( ConNetworkReconnect  )

Definition at line 1075 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [45/80]

DEF_CONSOLE_CMD ( ConNewGame  )

Definition at line 1270 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [46/80]

DEF_CONSOLE_CMD ( ConNewGRFProfile  )

Definition at line 2431 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [47/80]

DEF_CONSOLE_CMD ( ConNewGRFReload  )

Definition at line 2354 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [48/80]

DEF_CONSOLE_CMD ( ConPart  )

Definition at line 1773 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [49/80]

DEF_CONSOLE_CMD ( ConPauseGame  )

Definition at line 804 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [50/80]

DEF_CONSOLE_CMD ( ConPrintWorkingDirectory  )

Definition at line 632 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [51/80]

DEF_CONSOLE_CMD ( ConRcon  )

Definition at line 852 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [52/80]

DEF_CONSOLE_CMD ( ConReload  )

Definition at line 1303 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [53/80]

DEF_CONSOLE_CMD ( ConReloadAI  )

Definition at line 1459 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [54/80]

DEF_CONSOLE_CMD ( ConRemove  )

Definition at line 531 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [55/80]

DEF_CONSOLE_CMD ( ConRescanAI  )

Definition at line 1534 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [56/80]

DEF_CONSOLE_CMD ( ConRescanGame  )

Definition at line 1551 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [57/80]

DEF_CONSOLE_CMD ( ConRescanNewGRF  )

Definition at line 1568 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [58/80]

DEF_CONSOLE_CMD ( ConResetCompany  )

Definition at line 1022 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [59/80]

DEF_CONSOLE_CMD ( ConResetEnginePool  )

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

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

◆ DEF_CONSOLE_CMD() [60/80]

DEF_CONSOLE_CMD ( ConResetEngines  )

Reset status of all engines.

Returns
Will always succeed.

Definition at line 233 of file console_cmds.cpp.

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

◆ DEF_CONSOLE_CMD() [61/80]

DEF_CONSOLE_CMD ( ConRestart  )

Definition at line 1282 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [62/80]

DEF_CONSOLE_CMD ( ConReturn  )

Definition at line 1202 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [63/80]

DEF_CONSOLE_CMD ( ConSave  )

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

◆ DEF_CONSOLE_CMD() [64/80]

DEF_CONSOLE_CMD ( ConSaveConfig  )

Explicitly save the configuration.

Returns
True.

Definition at line 440 of file console_cmds.cpp.

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

◆ DEF_CONSOLE_CMD() [65/80]

DEF_CONSOLE_CMD ( ConSay  )

Definition at line 1890 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [66/80]

DEF_CONSOLE_CMD ( ConSayClient  )

Definition at line 1935 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [67/80]

DEF_CONSOLE_CMD ( ConSayCompany  )

Definition at line 1909 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [68/80]

DEF_CONSOLE_CMD ( ConSchedule  )

Definition at line 1173 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [69/80]

DEF_CONSOLE_CMD ( ConScreenShot  )

Definition at line 1638 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [70/80]

DEF_CONSOLE_CMD ( ConScript  )

Definition at line 1221 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [71/80]

DEF_CONSOLE_CMD ( ConScrollToTile  )

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

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

◆ DEF_CONSOLE_CMD() [72/80]

DEF_CONSOLE_CMD ( ConServerInfo  )

Definition at line 882 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [73/80]

DEF_CONSOLE_CMD ( ConSetting  )

Definition at line 2292 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [74/80]

DEF_CONSOLE_CMD ( ConSettingNewgame  )

Definition at line 2311 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [75/80]

DEF_CONSOLE_CMD ( ConStartAI  )

Definition at line 1387 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [76/80]

DEF_CONSOLE_CMD ( ConStatus  )

Definition at line 871 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [77/80]

DEF_CONSOLE_CMD ( ConStopAI  )

Definition at line 1497 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [78/80]

DEF_CONSOLE_CMD ( ConUnBan  )

Definition at line 754 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [79/80]

DEF_CONSOLE_CMD ( ConUnpauseGame  )

Definition at line 826 of file console_cmds.cpp.

◆ DEF_CONSOLE_CMD() [80/80]

DEF_CONSOLE_CMD ( ConZoomToLevel  )

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

References _settings_client, CC_ERROR, CC_HELP, DoZoomInOutWindow(), GetArgumentInteger(), GetMainWindow(), ClientSettings::gui, IConsolePrint(), Window::viewport, Viewport::zoom, ZOOM_IN, ZOOM_LVL_MAX, ZOOM_LVL_MIN, GUISettings::zoom_max, GUISettings::zoom_min, and ZOOM_OUT.

◆ DEF_CONSOLE_HOOK() [1/7]

DEF_CONSOLE_HOOK ( ConHookClientOnly  )

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

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

◆ DEF_CONSOLE_HOOK() [2/7]

DEF_CONSOLE_HOOK ( ConHookNeedNetwork  )

Check whether we are in a multiplayer game.

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

Definition at line 165 of file console_cmds.cpp.

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

◆ DEF_CONSOLE_HOOK() [3/7]

DEF_CONSOLE_HOOK ( ConHookNeedNonDedicatedNetwork  )

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

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

◆ DEF_CONSOLE_HOOK() [4/7]

DEF_CONSOLE_HOOK ( ConHookNewGRFDeveloperTool  )

Definition at line 217 of file console_cmds.cpp.

◆ DEF_CONSOLE_HOOK() [5/7]

DEF_CONSOLE_HOOK ( ConHookNoNetwork  )

Check whether we are in singleplayer mode.

Returns
True when no network is active.

Definition at line 195 of file console_cmds.cpp.

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

◆ DEF_CONSOLE_HOOK() [6/7]

DEF_CONSOLE_HOOK ( ConHookServerOnly  )

Check whether we are a server.

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

Definition at line 135 of file console_cmds.cpp.

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

◆ DEF_CONSOLE_HOOK() [7/7]

DEF_CONSOLE_HOOK ( ConHookServerOrNoNetwork  )

Check if are either in singleplayer or a server.

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

Definition at line 208 of file console_cmds.cpp.

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

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

References BSWAP32(), and GB().

◆ GetAllGRFFiles()

const std::vector< GRFFile * > & GetAllGRFFiles ( )
extern

Definition at line 72 of file newgrf.cpp.

◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister ( )

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

References _network_available, CC_ERROR, and IConsolePrint().

Referenced by DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), DEF_CONSOLE_HOOK(), and DEF_CONSOLE_HOOK().

◆ OutputContentState()

static void OutputContentState ( const ContentInfo *const  ci)
static

◆ PerformNetworkAuthorizedKeyAction()

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

Definition at line 1968 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 1327 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 1337 of file console_cmds.cpp.

◆ ShowFramerateWindow()

void ShowFramerateWindow ( )
extern

Open the general framerate window.

Definition at line 1024 of file framerate_gui.cpp.

Referenced by MenuClickHelp().

◆ StringToContentType()

static ContentType StringToContentType ( const char *  str)
static

Variable Documentation

◆ _console_cmd_authorized_keys

std::vector<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:56
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 1956 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 107 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 105 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 106 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

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(std::string("exec") + " " + filename);
}}
void IConsoleCmdExec(const std::string &command_string, const uint recurse_count)
Execute a given command passed to us.
Definition console.cpp:291
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:89
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.