OpenTTD Source 20260218-master-g2123fca5ea
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)
 Check whether NewGRF developer tools are enabled.
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)
 Load a savegame.
static bool ConLoadScenario (std::span< std::string_view > argv)
 Load a scenario.
static bool ConLoadHeightmap (std::span< std::string_view > argv)
 Load a heightmap.
static bool ConRemove (std::span< std::string_view > argv)
 Remove a savegame file from disk.
static bool ConListFiles (std::span< std::string_view > argv)
 List all the files in the current dir via console.
static bool ConListScenarios (std::span< std::string_view > argv)
 List all the scenarios.
static bool ConListHeightmaps (std::span< std::string_view > argv)
 List all the heightmaps.
static bool ConChangeDirectory (std::span< std::string_view > argv)
 Change the dir via console.
static bool ConPrintWorkingDirectory (std::span< std::string_view > argv)
 Print the current working directory.
static bool ConClearBuffer (std::span< std::string_view > argv)
 Clear the console's buffer.
static bool ConKickOrBan (std::string_view arg, bool ban, std::string_view reason)
 Helper to kick or ban a user.
static bool ConKick (std::span< std::string_view > argv)
 Kick a user from a network game.
static bool ConBan (std::span< std::string_view > argv)
 Ban a user from a network game.
static bool ConUnBan (std::span< std::string_view > argv)
 Unban a user from a network game.
static bool ConBanList (std::span< std::string_view > argv)
 Show the list of banned clients.
static bool ConPauseGame (std::span< std::string_view > argv)
 Manually pause the game.
static bool ConUnpauseGame (std::span< std::string_view > argv)
 Manually unpause the game.
static bool ConRcon (std::span< std::string_view > argv)
 Run a console command on the server.
static bool ConStatus (std::span< std::string_view > argv)
 Get the status of connected clients.
static bool ConServerInfo (std::span< std::string_view > argv)
 Get information like client/company count/limits for the server.
static bool ConClientNickChange (std::span< std::string_view > argv)
 Change the name of a client.
static std::optional< CompanyID > ParseCompanyID (std::string_view arg)
 Helper to parse a company ID.
static bool ConJoinCompany (std::span< std::string_view > argv)
 As client, join a company.
static bool ConMoveClient (std::span< std::string_view > argv)
 Move a client to a specific company.
static bool ConResetCompany (std::span< std::string_view > argv)
 Remove a company from the game.
static bool ConNetworkClients (std::span< std::string_view > argv)
 List the clients.
static bool ConNetworkReconnect (std::span< std::string_view > argv)
 Connect to the last client you were connected to.
static bool ConNetworkConnect (std::span< std::string_view > argv)
 Connect to a specific server.
static bool ConExec (std::span< std::string_view > argv)
 Run a local script file.
static bool ConSchedule (std::span< std::string_view > argv)
 Schedule the execution of a script.
static bool ConReturn (std::span< std::string_view > argv)
 End the execution of the current script.
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)
 Enable or disable logging of console output.
static bool ConEcho (std::span< std::string_view > argv)
 Simply print the arguments.
static bool ConEchoC (std::span< std::string_view > argv)
 Print the arguments in a particular colour.
static bool ConNewGame (std::span< std::string_view > argv)
 Start/create a new game.
static bool ConRestart (std::span< std::string_view > argv)
 Restart the game.
static bool ConReload (std::span< std::string_view > argv)
 Reload a game from the loaded savegame/scenario/heightmap.
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)
 Helper to print a list to the console.
static bool ConListAILibs (std::span< std::string_view > argv)
 List all AI libraries.
static bool ConListAI (std::span< std::string_view > argv)
 List all AI scripts.
static bool ConListGameLibs (std::span< std::string_view > argv)
 List all game script libraries.
static bool ConListGame (std::span< std::string_view > argv)
 List all game scripts.
static bool ConStartAI (std::span< std::string_view > argv)
 Start a new AI.
static bool ConReloadAI (std::span< std::string_view > argv)
 Reload/restart an AI.
static bool ConStopAI (std::span< std::string_view > argv)
 Stop a currently running AI.
static bool ConRescanAI (std::span< std::string_view > argv)
 Rescan the folder structure for new/changed AIs and libraries.
static bool ConRescanGame (std::span< std::string_view > argv)
 Rescan the folder structure for new/changed game scripts and libraries.
static bool ConRescanNewGRF (std::span< std::string_view > argv)
 Rescan the folder structure for new/changed NewGRFs.
static bool ConGetSeed (std::span< std::string_view > argv)
 Get the seed that was used to create this game.
static bool ConGetDate (std::span< std::string_view > argv)
 Get the current game date.
static bool ConGetSysDate (std::span< std::string_view > argv)
 Get the current system date.
static bool ConAlias (std::span< std::string_view > argv)
 Create an alias for a command.
static bool ConScreenShot (std::span< std::string_view > argv)
 Make a screenshot.
static bool ConInfoCmd (std::span< std::string_view > argv)
 Get debug information about a command.
static bool ConDebugLevel (std::span< std::string_view > argv)
 Change the debug levels of the game.
static bool ConExit (std::span< std::string_view > argv)
 Exit the game, i.e.
static bool ConPart (std::span< std::string_view > argv)
 Part the game, i.e.
static bool ConHelp (std::span< std::string_view > argv)
 Show generic help and specific help for commands.
static bool ConListCommands (std::span< std::string_view > argv)
 List all registered commands that are not hidden.
static bool ConListAliases (std::span< std::string_view > argv)
 List all registered aliases.
static bool ConCompanies (std::span< std::string_view > argv)
 List all companies.
static bool ConSay (std::span< std::string_view > argv)
 Say something to all clients in a network game.
static bool ConSayCompany (std::span< std::string_view > argv)
 Say something to all clients in your company in a network game.
static bool ConSayClient (std::span< std::string_view > argv)
 Say something to a specific client in a network game.
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)
 Management of authorized keys.
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)
 Downloading of content from the server.
static bool ConFont (std::span< std::string_view > argv)
 Managing the font configuration.
static bool ConSetting (std::span< std::string_view > argv)
 Change settings of the current game.
static bool ConSettingNewgame (std::span< std::string_view > argv)
 Change settings of for a new game.
static bool ConListSettings (std::span< std::string_view > argv)
 List all settings.
static bool ConGamelogPrint (std::span< std::string_view > argv)
 Print the gamelog.
static bool ConNewGRFReload (std::span< std::string_view > argv)
 Reload all active NewGRFs.
static bool ConListDirs (std::span< std::string_view > argv)
 List the locations of all of the game's different sub directories.
static bool ConNewGRFProfile (std::span< std::string_view > argv)
 Management of NewGRF profiling.
static bool ConFramerate (std::span< std::string_view > argv)
 Show the current framerate statistics.
static bool ConFramerateWindow (std::span< std::string_view > argv)
 Show the framerate statistics window.
static std::string FormatLabel (uint32_t label)
 Format a label as a string.
static void ConDumpRoadTypes ()
 List all road types and their configuration.
static void ConDumpRailTypes ()
 List all rail types and their configuration.
static void ConDumpCargoTypes ()
 List all cargo types and their configuration.
static bool ConDumpInfo (std::span< std::string_view > argv)
 Dump information about some NewGRF types.
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 2125 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

Create an alias for a command.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1748 of file console_cmds.cpp.

References IConsole::AliasGet(), IConsole::AliasRegister(), CC_HELP, IConsoleAlias::cmdline, and IConsolePrint().

◆ ConBan()

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

Ban a user from a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 758 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, ConKickOrBan(), and IConsolePrint().

◆ ConBanList()

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

Show the list of banned clients.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 816 of file console_cmds.cpp.

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

◆ ConChangeDirectory()

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

Change the dir via console.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 616 of file console_cmds.cpp.

References _console_file_list_savegame, CC_ERROR, CC_HELP, FiosType::detailed, DFT_FIOS_DIR, DFT_FIOS_DRIVE, DFT_FIOS_PARENT, FiosBrowseTo(), and IConsolePrint().

◆ ConClearBuffer()

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

Clear the console's buffer.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 662 of file console_cmds.cpp.

References CC_HELP, IConsolePrint(), SetWindowDirty(), and WC_CONSOLE.

◆ ConClientNickChange()

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

Change the name of a client.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 934 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, CLIENT_ID_SERVER, NetworkClientInfo::GetByClientID(), IConsolePrint(), NetworkIsValidClientName(), NetworkServerChangeClientName(), ParseType(), and StringConsumer::WHITESPACE_NO_NEWLINE.

◆ ConCompanies()

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

List all companies.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2014 of file console_cmds.cpp.

References _company_colours, CalculateCompanyValue(), CC_HELP, CC_INFO, GetString(), IConsolePrint(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

◆ ConContent()

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

Downloading of content from the server.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2311 of file console_cmds.cpp.

References _network_content_client, ContentInfo::Autoselected, CC_DEFAULT, CC_ERROR, CC_HELP, CC_WHITE, CONTENT_TYPE_END, IConsolePrint(), OutputContentState(), ParseType(), ContentInfo::Selected, StrContainsIgnoreCase(), StrEqualsIgnoreCase(), and StringToContentType().

◆ ConDebugLevel()

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

Change the debug levels of the game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1885 of file console_cmds.cpp.

References CC_DEFAULT, CC_ERROR, CC_HELP, GetDebugString(), IConsolePrint(), and SetDebugString().

◆ ConDumpCargoTypes()

void ConDumpCargoTypes ( )
static

List all cargo types and their configuration.

Definition at line 2874 of file console_cmds.cpp.

References Armoured, Bulk, CC_DEFAULT, Covered, Express, FormatLabel(), Hazardous, IConsolePrint(), CargoSpec::Iterate(), Liquid, Mail, NonPotable, NotPourable, Oversized, Passengers, PieceGoods, Potable, Powderized, Refrigerated, and Special.

Referenced by ConDumpInfo().

◆ ConDumpInfo()

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

Dump information about some NewGRF types.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2933 of file console_cmds.cpp.

References CC_HELP, ConDumpCargoTypes(), ConDumpRailTypes(), ConDumpRoadTypes(), IConsolePrint(), and StrEqualsIgnoreCase().

◆ ConDumpRailTypes()

◆ ConDumpRoadTypes()

◆ ConEcho()

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

Simply print the arguments.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1324 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, and IConsolePrint().

◆ ConEchoC()

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

Print the arguments in a particular colour.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1337 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, IConsolePrint(), IsInsideMM(), and ParseInteger().

◆ ConExec()

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

Run a local script file.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1200 of file console_cmds.cpp.

References _script_current_depth, BASE_DIR, CC_ERROR, CC_HELP, FioFOpenFile(), ICON_CMDLN_SIZE, IConsoleCmdExec(), and IConsolePrint().

◆ ConExit()

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

Exit the game, i.e.

exit the complete application. Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1905 of file console_cmds.cpp.

References _settings_client, CC_HELP, DoExitSave(), and IConsolePrint().

◆ ConFont()

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

Managing the font configuration.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2401 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, FontCacheSubSetting::font, FS_BEGIN, FontCache::Get(), GetFontCacheSubSetting(), FontCache::GetFontName(), FontCache::GetFontSize(), FontCache::HasParent(), IConsolePrint(), FontCache::LoadFontCaches(), ParseInteger(), FontCacheSubSetting::size, and StrEqualsIgnoreCase().

◆ ConFramerate()

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

Show the current framerate statistics.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2752 of file console_cmds.cpp.

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

◆ ConFramerateWindow()

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

Show the framerate statistics window.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2764 of file console_cmds.cpp.

References _network_dedicated, CC_ERROR, CC_HELP, IConsolePrint(), and ShowFramerateWindow().

◆ ConGamelogPrint()

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

Print the gamelog.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2520 of file console_cmds.cpp.

References _gamelog, CC_HELP, and IConsolePrint().

◆ ConGetDate()

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

Get the current game date.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1723 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::date, and IConsolePrint().

◆ ConGetSeed()

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

Get the seed that was used to create this game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1710 of file console_cmds.cpp.

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

◆ ConGetSysDate()

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

Get the current system date.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1736 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, and IConsolePrint().

◆ ConHelp()

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

Show generic help and specific help for commands.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1938 of file console_cmds.cpp.

References IConsole::AliasGet(), CC_DEFAULT, CC_ERROR, IConsole::CmdGet(), IConsoleAlias::cmdline, IConsolePrint(), and IConsoleCmd::proc.

◆ ConHookClientOnly()

ConsoleHookResult ConHookClientOnly ( bool echo)
static

Check whether we are a client in a network game.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 164 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.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 179 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. Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 194 of file console_cmds.cpp.

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

◆ ConHookNewGRFDeveloperTool()

ConsoleHookResult ConHookNewGRFDeveloperTool ( bool echo)
static

Check whether NewGRF developer tools are enabled.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 235 of file console_cmds.cpp.

References _settings_client, CC_ERROR, CHR_DISALLOW, CHR_HIDE, ConHookNoNetwork(), and IConsolePrint().

◆ ConHookNoNetwork()

ConsoleHookResult ConHookNoNetwork ( bool echo)
static

Check whether we are in singleplayer mode.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 209 of file console_cmds.cpp.

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

Referenced by ConHookNewGRFDeveloperTool().

◆ ConHookServerOnly()

ConsoleHookResult ConHookServerOnly ( bool echo)
static

Check whether we are a server.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

Definition at line 149 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.

Checks whether the command may be executed.

Parameters
echoWhether to print an error message or not.
Returns
Whether to allow the command or not.

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

Get debug information about a command.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1862 of file console_cmds.cpp.

References CC_DEFAULT, CC_ERROR, CC_HELP, IConsole::CmdGet(), IConsoleCmd::hook, IConsolePrint(), and IConsoleCmd::name.

◆ ConJoinCompany()

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

As client, join a company.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 984 of file console_cmds.cpp.

References _network_own_client_id, _network_server, NetworkClientInfo::CanJoinCompany(), CC_ERROR, CC_HELP, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, COMPANY_SPECTATOR, NetworkClientInfo::GetByClientID(), IConsolePrint(), Company::IsHumanID(), NetworkClientRequestMove(), NetworkServerDoMove(), and ParseCompanyID().

◆ ConKick()

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

Kick a user from a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 734 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, ConKickOrBan(), and IConsolePrint().

◆ ConKickOrBan()

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

Helper to kick or ban a user.

Parameters
argThe client id or IP address.
banWhether to ban, when false only a kick is performed.
reasonThe reason for this action.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 686 of file console_cmds.cpp.

References _redirect_console_to_client, CC_DEFAULT, CC_ERROR, CLIENT_ID_SERVER, NetworkClientInfo::GetByClientID(), IConsolePrint(), NetworkServerKickClient(), NetworkServerKickOrBanIP(), and ParseType().

Referenced by ConBan(), and ConKick().

◆ ConListAI()

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

List all AI scripts.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1464 of file console_cmds.cpp.

References CC_HELP, AI::GetConsoleList(), IConsolePrint(), and PrintList().

◆ ConListAILibs()

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

List all AI libraries.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1453 of file console_cmds.cpp.

References CC_HELP, AI::GetConsoleLibraryList(), IConsolePrint(), and PrintList().

◆ ConListAliases()

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

List all registered aliases.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1996 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, IConsoleAlias::cmdline, IConsolePrint(), and IConsoleAlias::name.

◆ ConListCommands()

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

List all registered commands that are not hidden.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1978 of file console_cmds.cpp.

References CC_DEFAULT, CC_HELP, CHR_HIDE, IConsoleCmd::hook, IConsolePrint(), and IConsoleCmd::name.

◆ ConListDirs()

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

List the locations of all of the game's different sub directories.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

< UI name for the directory

< Index of subdirectory type

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

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

List all the files in the current dir via console.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 568 of file console_cmds.cpp.

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

◆ ConListGame()

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

List all game scripts.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1486 of file console_cmds.cpp.

References CC_HELP, Game::GetConsoleList(), IConsolePrint(), and PrintList().

◆ ConListGameLibs()

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

List all game script libraries.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1475 of file console_cmds.cpp.

References CC_HELP, Game::GetConsoleLibraryList(), IConsolePrint(), and PrintList().

◆ ConListHeightmaps()

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

List all the heightmaps.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 600 of file console_cmds.cpp.

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

◆ ConListScenarios()

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

List all the scenarios.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 584 of file console_cmds.cpp.

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

◆ ConListSettings()

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

List all settings.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2506 of file console_cmds.cpp.

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

◆ ConLoad()

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

Load a savegame.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 457 of file console_cmds.cpp.

References _console_file_list_savegame, _file_to_saveload, _switch_mode, FiosType::abstract, CC_ERROR, CC_HELP, FT_SAVEGAME, IConsolePrint(), and SM_LOAD_GAME.

◆ ConLoadHeightmap()

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

Load a heightmap.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 511 of file console_cmds.cpp.

References _console_file_list_heightmap, _file_to_saveload, _switch_mode, FiosType::abstract, CC_ERROR, CC_HELP, FT_HEIGHTMAP, IConsolePrint(), and SM_START_HEIGHTMAP.

◆ ConLoadScenario()

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

Load a scenario.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 484 of file console_cmds.cpp.

References _console_file_list_scenario, _file_to_saveload, _switch_mode, FiosType::abstract, CC_ERROR, CC_HELP, FT_SCENARIO, IConsolePrint(), and SM_LOAD_GAME.

◆ ConMoveClient()

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

Move a client to a specific company.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1036 of file console_cmds.cpp.

References _network_dedicated, CC_ERROR, CC_HELP, NetworkClientInfo::client_id, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, COMPANY_SPECTATOR, NetworkClientInfo::GetByClientID(), IConsolePrint(), Company::IsHumanID(), NetworkServerDoMove(), ParseCompanyID(), and ParseType().

◆ ConNetworkAuthorizedKey()

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

Management of authorized keys.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2172 of file console_cmds.cpp.

References _console_cmd_authorized_keys, CompanyProperties::allow_list, CC_ERROR, CC_HELP, CC_WARNING, IConsolePrint(), NETWORK_PUBLIC_KEY_LENGTH, NetworkGetPublicKeyOfClient(), ParseInteger(), StrEqualsIgnoreCase(), and StrStartsWithIgnoreCase().

◆ ConNetworkClients()

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

List the clients.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1136 of file console_cmds.cpp.

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

◆ ConNetworkConnect()

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

Connect to a specific server.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1181 of file console_cmds.cpp.

References CC_HELP, COMPANY_NEW_COMPANY, IConsolePrint(), and NetworkClientConnectGame().

◆ ConNetworkReconnect()

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

Connect to the last client you were connected to.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1149 of file console_cmds.cpp.

References _settings_client, CC_DEFAULT, CC_ERROR, CC_HELP, COMPANY_NEW_COMPANY, COMPANY_SPECTATOR, IConsolePrint(), NetworkClientConnectGame(), and ParseCompanyID().

◆ ConNewGame()

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

Start/create a new game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1357 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, GENERATE_NEW_SEED, IConsolePrint(), ParseInteger(), and StartNewGameWithoutGUI().

◆ ConNewGRFProfile()

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

Management of NewGRF profiling.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2614 of file console_cmds.cpp.

References NewGRFProfiler::AbortTimer(), CC_DEBUG, CC_ERROR, CC_HELP, CC_INFO, CC_WARNING, NewGRFProfiler::grffile, IConsolePrint(), ParseInteger(), NewGRFProfiler::StartTimer(), StrEqualsIgnoreCase(), StrStartsWithIgnoreCase(), and StringConsumer::TryReadIntegerBase().

◆ ConNewGRFReload()

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

Reload all active NewGRFs.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2532 of file console_cmds.cpp.

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

◆ ConPart()

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

Part the game, i.e.

go back to the main menu. Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1919 of file console_cmds.cpp.

References _network_dedicated, _switch_mode, CC_ERROR, CC_HELP, IConsolePrint(), and SM_MENU.

◆ ConPauseGame()

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

Manually pause the game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 835 of file console_cmds.cpp.

References _networking, _pause_mode, CC_DEFAULT, CC_ERROR, CC_HELP, IConsolePrint(), and Normal.

◆ ConPrintFramerate()

void ConPrintFramerate ( )
extern

◆ ConPrintWorkingDirectory()

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

Print the current working directory.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 646 of file console_cmds.cpp.

References _console_file_list_savegame, CC_DEFAULT, CC_HELP, FiosGetCurrentPath(), and IConsolePrint().

◆ ConRcon()

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

Run a console command on the server.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 885 of file console_cmds.cpp.

References _network_server, CC_HELP, IConsoleCmdExec(), IConsolePrint(), and NetworkClientSendRcon().

◆ ConReload()

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

Reload a game from the loaded savegame/scenario/heightmap.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1402 of file console_cmds.cpp.

References _file_to_saveload, _settings_game, _switch_mode, CC_ERROR, CC_HELP, FT_INVALID, FT_NONE, IConsolePrint(), Map::LogX(), Map::LogY(), and SM_RELOADGAME.

◆ ConReloadAI()

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

Reload/restart an AI.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1572 of file console_cmds.cpp.

References _local_company, _network_server, _networking, CC_DEFAULT, CC_ERROR, CC_HELP, Delete, IConsolePrint(), INVALID_CLIENT_ID, Company::IsHumanID(), Manual, NewAI, None, and ParseCompanyID().

◆ ConRemove()

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

Remove a savegame file from disk.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 538 of file console_cmds.cpp.

References _console_file_list_savegame, FiosType::abstract, CC_ERROR, CC_HELP, FioRemove(), FT_SAVEGAME, and IConsolePrint().

◆ ConRescanAI()

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

Rescan the folder structure for new/changed AIs and libraries.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1659 of file console_cmds.cpp.

References _network_server, _networking, CC_ERROR, CC_HELP, IConsolePrint(), and AI::Rescan().

◆ ConRescanGame()

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

Rescan the folder structure for new/changed game scripts and libraries.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1677 of file console_cmds.cpp.

References _network_server, _networking, CC_ERROR, CC_HELP, IConsolePrint(), and Game::Rescan().

◆ ConRescanNewGRF()

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

Rescan the folder structure for new/changed NewGRFs.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1695 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, IConsolePrint(), and RequestNewGRFScan().

◆ ConResetCompany()

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

Remove a company from the game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1090 of file console_cmds.cpp.

References CC_DEFAULT, CC_ERROR, CC_HELP, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, Delete, NetworkClientInfo::GetByClientID(), IConsolePrint(), INVALID_CLIENT_ID, Company::IsHumanID(), Manual, NetworkCompanyHasClients(), and ParseCompanyID().

◆ ConResetEnginePool()

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

Reset status of the engine pool.

Note
Resetting the pool only succeeds when there are no vehicles ingame. Entrypoint of a console command.
Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 267 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.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 251 of file console_cmds.cpp.

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

◆ ConRestart()

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

Restart the game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1380 of file console_cmds.cpp.

References _settings_game, _switch_mode, CC_HELP, IConsolePrint(), Map::LogX(), Map::LogY(), SM_RESTARTGAME, and StartNewGameWithoutGUI().

◆ ConReturn()

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

End the execution of the current script.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1279 of file console_cmds.cpp.

References _script_current_depth, CC_HELP, and IConsolePrint().

◆ ConSave()

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

Save the map to a file.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 417 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.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 443 of file console_cmds.cpp.

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

◆ ConSay()

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

Say something to all clients in a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2040 of file console_cmds.cpp.

References _network_server, _redirect_console_to_admin, CC_HELP, CLIENT_ID_SERVER, DESTTYPE_BROADCAST, IConsolePrint(), NetworkClientSendChat(), and NetworkServerSendChat().

◆ ConSayClient()

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

Say something to a specific client in a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2092 of file console_cmds.cpp.

References _network_server, _redirect_console_to_admin, CC_ERROR, CC_HELP, CLIENT_ID_SERVER, DESTTYPE_CLIENT, IConsolePrint(), NetworkClientSendChat(), NetworkServerSendChat(), and ParseType().

◆ ConSayCompany()

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

Say something to all clients in your company in a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2060 of file console_cmds.cpp.

References _network_server, _redirect_console_to_admin, CC_DEFAULT, CC_ERROR, CC_HELP, CLIENT_ID_SERVER, DESTTYPE_TEAM, IConsolePrint(), NetworkClientSendChat(), NetworkServerSendChat(), and ParseCompanyID().

◆ ConSchedule()

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

Schedule the execution of a script.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1249 of file console_cmds.cpp.

References _scheduled_monthly_script, BASE_DIR, CC_ERROR, CC_HELP, CC_INFO, FioCheckFileExists(), and IConsolePrint().

◆ ConScreenShot()

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

Make a screenshot.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1769 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, IConsoleClose(), IConsolePrint(), MakeScreenshot(), ParseInteger(), SC_DEFAULTZOOM, SC_HEIGHTMAP, SC_MINIMAP, SC_VIEWPORT, SC_WORLD, and SC_ZOOMEDIN.

◆ ConScript()

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

Enable or disable logging of console output.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1299 of file console_cmds.cpp.

References CC_ERROR, CC_HELP, CC_INFO, IConsolePrint(), and FileHandle::Open().

◆ ConScrollToTile()

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

Scroll to a tile on the map.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

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

Get information like client/company count/limits for the server.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 917 of file console_cmds.cpp.

References _network_game_info, _network_server_invite_code, _settings_client, CC_DEFAULT, CC_HELP, and IConsolePrint().

◆ ConSetting()

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

Change settings of the current game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2466 of file console_cmds.cpp.

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

◆ ConSettingNewgame()

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

Change settings of for a new game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 2486 of file console_cmds.cpp.

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

◆ ConStartAI()

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

◆ ConStatus()

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

Get the status of connected clients.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 905 of file console_cmds.cpp.

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

◆ ConStopAI()

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

Stop a currently running AI.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 1616 of file console_cmds.cpp.

References _local_company, _network_server, _networking, CC_DEFAULT, CC_ERROR, CC_HELP, Delete, IConsolePrint(), INVALID_CLIENT_ID, Company::IsHumanID(), Manual, and ParseCompanyID().

◆ ConUnBan()

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

Unban a user from a network game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 783 of file console_cmds.cpp.

References _network_ban_list, CC_DEFAULT, CC_HELP, IConsolePrint(), and ParseInteger().

◆ ConUnpauseGame()

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

Manually unpause the game.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

Definition at line 858 of file console_cmds.cpp.

References _networking, _pause_mode, CC_DEFAULT, CC_ERROR, CC_HELP, Error, IConsolePrint(), and Normal.

◆ ConZoomToLevel()

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

Zoom map to given level.

Entrypoint of a console command.

Parameters
argvThe arguments to the command.
Returns
true iff the command is handled correctly, i.e. false to show a help message.

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

References GB().

Referenced by ConDumpCargoTypes(), ConDumpRailTypes(), and ConDumpRoadTypes().

◆ GetAllGRFFiles()

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

Definition at line 66 of file newgrf.cpp.

◆ IConsoleStdLibRegister()

void IConsoleStdLibRegister ( )

Definition at line 2964 of file console_cmds.cpp.

◆ NetworkAvailable()

bool NetworkAvailable ( bool echo)
inlinestatic

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

Parameters
echoWhether to print an error message or not.
Returns
true iff the network is available.

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

Helper to parse a company ID.

Note that 'Company #1' has ID 0.

Parameters
argThe string to get the company ID from.
Returns
The company's ID, or std::nullopt when no valid ID was found.

Definition at line 976 of file console_cmds.cpp.

References ParseType().

Referenced by ConJoinCompany(), ConMoveClient(), ConNetworkReconnect(), ConReloadAI(), ConResetCompany(), ConSayCompany(), and ConStopAI().

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

Referenced by ConClientNickChange(), ConContent(), ConKickOrBan(), ConMoveClient(), ConSayClient(), and ParseCompanyID().

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

References CC_DEFAULT, and IConsolePrint().

Referenced by PrintList().

◆ PrintList()

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

Helper to print a list to the console.

Parameters
list_functionThe function that gets the list.
argsThe arguments for the list function.
Returns
true, to ease the use in
See also
IConsoleCmdProc.

Definition at line 1442 of file console_cmds.cpp.

References PrintLineByLine().

Referenced by ConListAI(), ConListAILibs(), ConListGame(), and ConListGameLibs().

◆ ShowFramerateWindow()

void ShowFramerateWindow ( )
extern

Open the general framerate window.

Definition at line 1026 of file framerate_gui.cpp.

References AllocateWindowDescFront().

Referenced by ConFramerateWindow(), and MenuClickHelp().

◆ StringToContentType()

ContentType StringToContentType ( std::string_view str)
static

Resolve a string to a content type.

Parameters
strThe string to resolve.
Returns
The content type, or CONTENT_TYPE_END when the string is not a content type.

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

Referenced by ConContent().

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

Referenced by ConNetworkAuthorizedKey().

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

Referenced by ConListHeightmaps(), and ConLoadHeightmap().

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

Referenced by ConChangeDirectory(), ConListFiles(), ConLoad(), ConPrintWorkingDirectory(), and ConRemove().

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

Referenced by ConListScenarios(), and ConLoadScenario().

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

Referenced by ConSchedule().

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

Referenced by ConExec(), and ConReturn().