39 #include "table/strings.h" 80 #define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[]) 81 #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo) 95 if (echo)
IConsoleError(
"You cannot use this command because there is no network available.");
110 if (echo)
IConsoleError(
"This command is only available to a network server.");
125 if (echo)
IConsoleError(
"This command is not available to a network server.");
140 if (echo)
IConsoleError(
"Not connected. This command is only available in multiplayer.");
153 if (echo)
IConsoleError(
"This command is forbidden in multiplayer.");
162 if (_game_mode == GM_MENU) {
163 if (echo)
IConsoleError(
"This command is only available in game and editor.");
166 return ConHookNoNetwork(echo);
187 IConsoleHelp(
"Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'");
203 IConsoleHelp(
"Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again.");
207 if (_game_mode == GM_MENU) {
208 IConsoleError(
"This command is only available in game and editor.");
213 IConsoleError(
"This can only be done when there are no vehicles in the game.");
229 IConsoleHelp(
"Reset a tile to bare land. Usage: 'resettile <tile>'");
230 IConsoleHelp(
"Tile can be either decimal (34161) or hexadecimal (0x4a5B)");
260 IConsoleHelp(
"Usage: 'scrollto <tile>' or 'scrollto <x> <y>'");
261 IConsoleHelp(
"Numbers can be either decimal (34161) or hexadecimal (0x4a5B).");
302 IConsoleHelp(
"Save the current game. Usage: 'save <filename>'");
307 char *filename =
str_fmt(
"%s.sav", argv[1]);
329 IConsoleHelp(
"Saves the configuration for new games to the configuration file, typically 'openttd.cfg'.");
330 IConsoleHelp(
"It does not save the configuration of the current game to the configuration file.");
342 IConsoleHelp(
"Load a game by name or index. Usage: 'load <file | number>'");
346 if (argc != 2)
return false;
348 const char *file = argv[1];
351 if (item !=
nullptr) {
371 IConsoleHelp(
"Remove a savegame by name or index. Usage: 'rm <file | number>'");
375 if (argc != 2)
return false;
377 const char *file = argv[1];
380 if (item !=
nullptr) {
397 IConsoleHelp(
"List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'");
402 for (uint i = 0; i < _console_file_list.
Length(); i++) {
413 IConsoleHelp(
"Change the dir via console. Usage: 'cd <directory | number>'");
417 if (argc != 2)
return false;
419 const char *file = argv[1];
422 if (item !=
nullptr) {
423 switch (item->type) {
424 case FIOS_TYPE_DIR:
case FIOS_TYPE_DRIVE:
case FIOS_TYPE_PARENT:
442 IConsoleHelp(
"Print out the current working directory. Usage: 'pwd'");
458 IConsoleHelp(
"Clear the console buffer. Usage: 'clear'");
462 IConsoleClearBuffer();
472 static bool ConKickOrBan(
const char *argv,
bool ban)
476 if (strchr(argv,
'.') ==
nullptr && strchr(argv,
':') ==
nullptr) {
518 IConsoleHelp(
"Kick a client from a network game. Usage: 'kick <ip | client-id>'");
519 IConsoleHelp(
"For client-id's, see the command 'clients'");
523 if (argc != 2)
return false;
525 return ConKickOrBan(argv[1],
false);
531 IConsoleHelp(
"Ban a client from a network game. Usage: 'ban <ip | client-id>'");
532 IConsoleHelp(
"For client-id's, see the command 'clients'");
533 IConsoleHelp(
"If the client is no longer online, you can still ban his/her IP");
537 if (argc != 2)
return false;
539 return ConKickOrBan(argv[1],
true);
545 IConsoleHelp(
"Unban a client from a network game. Usage: 'unban <ip | banlist-index>'");
546 IConsoleHelp(
"For a list of banned IP's, see the command 'banlist'");
550 if (argc != 2)
return false;
560 index = atoi(argv[1]) - 1U;
579 IConsoleHelp(
"List the IP's of banned clients: Usage 'banlist'");
613 IConsoleHelp(
"Unpause a network game. Usage: 'unpause'");
634 IConsoleHelp(
"Remote control the server from another client. Usage: 'rcon <password> <command>'");
635 IConsoleHelp(
"Remember to enclose the command in quotes, otherwise only the first parameter is sent");
639 if (argc < 3)
return false;
652 IConsoleHelp(
"List the status of all clients connected to the server. Usage 'status'");
663 IConsoleHelp(
"List current and maximum client/company limits. Usage 'server_info'");
664 IConsoleHelp(
"You can change these values by modifying settings 'network.max_clients', 'network.max_companies' and 'network.max_spectators'");
678 IConsoleHelp(
"Change the nickname of a connected client. Usage: 'client_name <client-id> <new-name>'");
679 IConsoleHelp(
"For client-id's, see the command 'clients'");
686 IConsoleError(
"Please use the command 'name' to change your own name!");
705 IConsoleHelp(
"Request joining another company. Usage: join <company-id> [<password>]");
706 IConsoleHelp(
"For valid company-id see company list, use 255 for spectator");
724 IConsoleError(
"Cannot join spectators, maximum number of spectators reached.");
752 IConsoleHelp(
"Move a client to another company. Usage: move <client-id> <company-id>");
753 IConsoleHelp(
"For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators");
762 IConsoleError(
"Invalid client-id, check the command 'clients' for valid client-id's.");
782 IConsoleError(
"You cannot move someone to where he/she already is!");
795 IConsoleHelp(
"Remove an idle company from the game. Usage: 'reset_company <company-id>'");
796 IConsoleHelp(
"For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
800 if (argc != 2)
return false;
816 IConsoleError(
"Cannot remove company: a client is connected to that company.");
821 IConsoleError(
"Cannot remove company: the server is connected to that company.");
835 IConsoleHelp(
"Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'");
847 IConsoleHelp(
"Reconnect to server to which you were connected last time. Usage: 'reconnect [<company>]'");
848 IConsoleHelp(
"Company 255 is spectator (default, if not specified), 0 means creating new company.");
849 IConsoleHelp(
"All others are a certain company with Company 1 being #1");
860 if (playas < COMPANY_FIRST + 1 || playas >
MAX_COMPANIES + 1)
return false;
879 IConsoleHelp(
"Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'");
880 IConsoleHelp(
"IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'");
881 IConsoleHelp(
"Company #255 is spectator all others are a certain company with Company 1 being #1");
885 if (argc < 2)
return false;
888 const char *port =
nullptr;
889 const char *company =
nullptr;
898 if (company !=
nullptr) {
909 if (port !=
nullptr) {
926 IConsoleHelp(
"Execute a local script file. Usage: 'exec <script> <?>'");
930 if (argc < 2)
return false;
934 if (script_file ==
nullptr) {
935 if (argc == 2 || atoi(argv[2]) != 0)
IConsoleError(
"script file not found");
942 while (
_script_running && fgets(cmdline,
sizeof(cmdline), script_file) !=
nullptr) {
944 for (
char *cmdptr = cmdline; *cmdptr !=
'\0'; cmdptr++) {
945 if (*cmdptr ==
'\n' || *cmdptr ==
'\r') {
953 if (ferror(script_file)) {
954 IConsoleError(
"Encountered error while trying to read from script file");
965 IConsoleHelp(
"Stop executing a running script. Usage: 'return'");
976 extern bool CloseConsoleLogIfActive();
980 extern FILE *_iconsole_output_file;
983 IConsoleHelp(
"Start or stop logging console output to a file. Usage: 'script <filename>'");
984 IConsoleHelp(
"If filename is omitted, a running log is stopped if it is active");
988 if (!CloseConsoleLogIfActive()) {
989 if (argc < 2)
return false;
992 _iconsole_output_file = fopen(argv[1],
"ab");
993 if (_iconsole_output_file ==
nullptr)
IConsoleError(
"could not open file");
1003 IConsoleHelp(
"Print back the first argument to the console. Usage: 'echo <arg>'");
1007 if (argc < 2)
return false;
1015 IConsoleHelp(
"Print back the first argument to the console in a given colour. Usage: 'echoc <colour> <arg2>'");
1019 if (argc < 3)
return false;
1027 IConsoleHelp(
"Start a new game. Usage: 'newgame [seed]'");
1028 IConsoleHelp(
"The server can force a new game using 'newgame'; any client joined will rejoin after the server is done generating the new game.");
1040 IConsoleHelp(
"Restarts a game. It tries to reproduce the exact same map as the game started with.");
1042 IConsoleHelp(
" * restarting games started in another version might create another map due to difference in map generation");
1043 IConsoleHelp(
" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame");
1063 for (
char *p2 = buf; *p2 !=
'\0'; p2++) {
1114 if (argc == 0 || argc > 3) {
1115 IConsoleHelp(
"Start a new AI. Usage: 'start_ai [<AI>] [<settings>]'");
1116 IConsoleHelp(
"Start a new AI. If <AI> is given, it starts that specific AI (if found).");
1117 IConsoleHelp(
"If <settings> is given, it is parsed and the AI settings are set to that.");
1121 if (_game_mode != GM_NORMAL) {
1135 IConsoleWarning(
"AIs are not allowed in multiplayer by configuration.");
1147 if (c->index != n)
break;
1153 config->
Change(argv[1], -1,
true);
1172 IConsoleHelp(
"Reload an AI. Usage: 'reload_ai <company-id>'");
1173 IConsoleHelp(
"Reload the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
1177 if (_game_mode != GM_NORMAL) {
1209 IConsoleHelp(
"Stop an AI. Usage: 'stop_ai <company-id>'");
1210 IConsoleHelp(
"Stop the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
1214 if (_game_mode != GM_NORMAL) {
1245 IConsoleHelp(
"Rescan the AI dir for scripts. Usage: 'rescan_ai'");
1250 IConsoleWarning(
"Only the server can rescan the AI dir for scripts.");
1262 IConsoleHelp(
"Rescan the Game Script dir for scripts. Usage: 'rescan_game'");
1267 IConsoleWarning(
"Only the server can rescan the Game Script dir for scripts.");
1279 IConsoleHelp(
"Rescan the data dir for NewGRFs. Usage: 'rescan_newgrf'");
1291 IConsoleHelp(
"Returns the seed used to create this game. Usage: 'getseed'");
1292 IConsoleHelp(
"The seed can be used to reproduce the exact same map as the game started with.");
1303 IConsoleHelp(
"Returns the current date (year-month-day) of the game. Usage: 'getdate'");
1316 IConsoleHelp(
"Returns the current date (year-month-day) of your system. Usage: 'getsysdate'");
1322 auto timeinfo = localtime(&t);
1323 IConsolePrintF(
CC_DEFAULT,
"System Date: %04d-%02d-%02d %02d:%02d:%02d", timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
1333 IConsoleHelp(
"Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'");
1337 if (argc < 3)
return false;
1340 if (alias ==
nullptr) {
1352 IConsoleHelp(
"Create a screenshot of the game. Usage: 'screenshot [big | giant | no_con] [file name]'");
1353 IConsoleHelp(
"'big' makes a zoomed-in screenshot of the visible area, 'giant' makes a screenshot of the " 1354 "whole map, 'no_con' hides the console to create the screenshot. 'big' or 'giant' " 1355 "screenshots are always drawn without console");
1359 if (argc > 3)
return false;
1362 const char *name =
nullptr;
1365 if (strcmp(argv[1],
"big") == 0) {
1368 if (argc > 2) name = argv[2];
1369 }
else if (strcmp(argv[1],
"giant") == 0) {
1372 if (argc > 2) name = argv[2];
1373 }
else if (strcmp(argv[1],
"no_con") == 0) {
1376 if (argc > 2) name = argv[2];
1377 }
else if (argc == 2) {
1393 IConsoleHelp(
"Print out debugging information about a command. Usage: 'info_cmd <cmd>'");
1397 if (argc < 2)
return false;
1400 if (cmd ==
nullptr) {
1416 IConsoleHelp(
"Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'");
1417 IConsoleHelp(
"Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'s");
1421 if (argc > 2)
return false;
1448 IConsoleHelp(
"Leave the currently joined/running game (only ingame). Usage: 'part'");
1452 if (_game_mode != GM_NORMAL)
return false;
1466 if (cmd !=
nullptr) {
1467 cmd->
proc(0,
nullptr);
1472 if (alias !=
nullptr) {
1474 if (cmd !=
nullptr) {
1475 cmd->
proc(0,
nullptr);
1501 IConsoleHelp(
"List all registered commands. Usage: 'list_cmds [<pre-filter>]'");
1506 if (argv[1] ==
nullptr || strstr(cmd->name, argv[1]) !=
nullptr) {
1517 IConsoleHelp(
"List all registered aliases. Usage: 'list_aliases [<pre-filter>]'");
1522 if (argv[1] ==
nullptr || strstr(alias->name, argv[1]) !=
nullptr) {
1533 IConsoleHelp(
"List the details of all companies in the game. Usage 'companies'");
1539 char company_name[512];
1541 GetString(company_name, STR_COMPANY_NAME,
lastof(company_name));
1543 const char *password_state =
"";
1545 password_state =
"AI";
1552 IConsolePrintF(
CC_INFO,
"#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64
" Loan: " OTTD_PRINTF64
" Value: " OTTD_PRINTF64
" (T:%d, R:%d, P:%d, S:%d) %s",
1553 c->index + 1, colour, company_name,
1556 c->group_all[
VEH_ROAD].num_vehicle,
1558 c->group_all[
VEH_SHIP].num_vehicle,
1568 IConsoleHelp(
"Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
1572 if (argc != 2)
return false;
1587 IConsoleHelp(
"Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
1588 IConsoleHelp(
"CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
1592 if (argc != 3)
return false;
1613 IConsoleHelp(
"Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
1614 IConsoleHelp(
"For client-id's, see the command 'clients'");
1618 if (argc != 3)
return false;
1633 const char *helpmsg;
1636 helpmsg =
"Change the password of a company. Usage: 'company_pw <company-no> \"<password>\"";
1638 helpmsg =
"Change the password of your or any other company. Usage: 'company_pw [<company-no>] \"<password>\"'";
1640 helpmsg =
"Change the password of your company. Usage: 'company_pw \"<password>\"'";
1649 const char *password;
1650 const char *errormsg;
1655 errormsg =
"You have to own a company to make use of this command.";
1657 company_id = (
CompanyID)(atoi(argv[1]) - 1);
1659 errormsg =
"You have to specify the ID of a valid human controlled company.";
1681 #if defined(WITH_ZLIB) 1687 static const char *
const inv_lookup[] = {
"",
"base",
"newgrf",
"ai",
"ailib",
"scenario",
"heightmap" };
1688 for (uint i = 1 ; i <
lengthof(inv_lookup); i++) {
1689 if (strcasecmp(str, inv_lookup[i]) == 0)
return (
ContentType)i;
1718 static const char *
const types[] = {
"Base graphics",
"NewGRF",
"AI",
"AI library",
"Scenario",
"Heightmap",
"Base sound",
"Base music",
"Game script",
"GS library" };
1720 static const char *
const states[] = {
"Not selected",
"Selected",
"Dep Selected",
"Installed",
"Unknown" };
1723 char buf[
sizeof(ci->
md5sum) * 2 + 1];
1725 IConsolePrintF(state_to_colour[ci->
state],
"%d, %s, %s, %s, %08X, %s", ci->
id, types[ci->
type - 1], states[ci->
state], ci->
name, ci->
unique_id, buf);
1731 if (cb ==
nullptr) {
1737 IConsoleHelp(
"Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state [filter]|download'");
1738 IConsoleHelp(
" update: get a new list of downloadable content; must be run first");
1739 IConsoleHelp(
" upgrade: select all items that are upgrades");
1740 IConsoleHelp(
" select: select a specific item given by its id or 'all' to select all. If no parameter is given, all selected content will be listed");
1741 IConsoleHelp(
" unselect: unselect a specific item given by its id or 'all' to unselect all");
1742 IConsoleHelp(
" state: show the download/select state of all downloadable content. Optionally give a filter string");
1743 IConsoleHelp(
" download: download all content you've selected");
1747 if (strcasecmp(argv[1],
"update") == 0) {
1752 if (strcasecmp(argv[1],
"upgrade") == 0) {
1757 if (strcasecmp(argv[1],
"select") == 0) {
1765 }
else if (strcasecmp(argv[2],
"all") == 0) {
1773 if (strcasecmp(argv[1],
"unselect") == 0) {
1778 if (strcasecmp(argv[2],
"all") == 0) {
1786 if (strcasecmp(argv[1],
"state") == 0) {
1789 if (argc > 2 && strcasestr((*iter)->name, argv[2]) ==
nullptr)
continue;
1795 if (strcasecmp(argv[1],
"download") == 0) {
1810 IConsoleHelp(
"Change setting for all clients. Usage: 'setting <name> [<value>]'");
1811 IConsoleHelp(
"Omitting <value> will print out the current value of the setting.");
1815 if (argc == 1 || argc > 3)
return false;
1820 IConsoleSetSetting(argv[1], argv[2]);
1829 IConsoleHelp(
"Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'");
1830 IConsoleHelp(
"Omitting <value> will print out the current value of the setting.");
1834 if (argc == 1 || argc > 3)
return false;
1839 IConsoleSetSetting(argv[1], argv[2],
true);
1848 IConsoleHelp(
"List settings. Usage: 'list_settings [<pre-filter>]'");
1852 if (argc > 2)
return false;
1867 IConsoleHelp(
"Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
1880 static void IConsoleDebugLibRegister()
1893 IConsoleHelp(
"Show frame rate and game speed information");
1911 IConsoleError(
"Can not open frame rate window on a dedicated server");
1923 void IConsoleStdLibRegister()
1988 #if defined(WITH_ZLIB) 2047 IConsoleDebugLibRegister();
AISettings ai
what may the AI do?
Functions related to OTTD's strings.
Helper to mark the end of the types.
Owner
Enum for all companies/owners.
static void OutputContentState(const ContentInfo *const ci)
Outputs content state information to console.
Send message/notice to all clients (All)
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban)
Ban, or kick, everyone joined from the given client's IP.
const ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
static uint MapSizeX()
Get the size of the map along the X.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
used in multiplayer to create a new companies etc.
void IConsoleGetSetting(const char *name, bool force_newgame)
Output value of a specific setting to the console.
IConsoleCmd * next
next command in list
void IConsoleWarning(const char *string)
It is possible to print warnings to the console.
void ParseConnectionString(const char **company, const char **port, char *connection_string)
Converts a string to ip/port/company Format: IP:port::company.
bool _networking
are we in networking mode?
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
char *CDECL str_fmt(const char *str,...)
Format, "printf", into a newly allocated string.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
static void PrintLineByLine(char *buf)
Print a text buffer line by line to the console.
static uint MapSizeY()
Get the size of the map along the Y.
Container for all information known about a client.
IConsoleCmd * _iconsole_cmds
list of registered commands
uint32 unique_id
Unique ID; either GRF ID or shortname.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
uint16 last_port
port of the last joined server
void FioFCloseFile(FILE *f)
Close a file in a safe way.
void NetworkServerShowStatusToConsole()
Show the status message of all clients on the console.
void Clear()
Remove all items from the list.
Switch to game intro menu.
void SetName(const char *name)
Set the name of the file.
Functions related to dates.
std::vector< FiosItem > files
The list of files.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Load game, Play Scenario.
static uint MapLogX()
Logarithm of the map size along the X side.
Functions related to debugging.
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
Callbacks for notifying others about incoming data.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for AIScanner::GetAIConsoleList.
Functions to be called to log possibly unsafe game events.
ClientID client_id
Client identifier (same as ClientState->client_id)
size_t Length() const
Get the number of files in the list.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
The company is manually removed.
The client wants a new company.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
void IConsoleListSettings(const char *prefilter)
List all settings and their value to the console.
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
Client part of the network protocol.
void Change(const char *name, int version=-1, bool force_exact_match=false, bool is_random=false)
Set another Script to be loaded in this slot.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
ClientID _redirect_console_to_client
If not invalid, redirect the console output to a client.
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
void OnConnect(bool success)
Callback for when the connection has finished.
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Functions for Standard In/Out file operations.
Send message/notice to only a certain client (Private)
The content has been selected as dependency.
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
IConsoleCmdProc * proc
process executed when command is typed
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data)
Send a chat message.
#define lastof(x)
Get the last element of an fixed size array.
char * name
name of command
static ContentType StringToContentType(const char *str)
Resolve a string to a content type.
static const TextColour CC_DEFAULT
Default colour of the console.
IConsoleAlias * _iconsole_aliases
list of registered aliases
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Functions related to world/map generation.
Functions to make screenshots.
Base core network types and some helper functions to access them.
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
ClientID
'Unique' identifier to be given to clients
static bool _script_running
Script is running (used to abort execution when #ConReturn is encountered).
void SaveToConfig()
Save the values to the configuration file.
uint8 map_x
X size of map.
ContentID
Unique identifier for the content.
Fully zoomed in screenshot of the visible area.
Deals with finding savegames.
Hide the existence of the command.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
StringID FiosGetDescText(const char **path, uint64 *total_free)
Get descriptive texts.
void OnDisconnect()
Callback for when the connection got disconnected.
static bool IsValidHumanID(size_t index)
Is this company a valid company, not controlled by a NoAI program?
bool _network_available
is network mode available?
void Unselect(ContentID cid)
Unselect a specific content id.
bool _network_dedicated
are we a dedicated server?
const FiosItem * FindItem(const char *file)
Find file information of a file by its name from the file list.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
Functions related to (drawing on) viewports.
uint8 map_y
Y size of map.
void UnselectAll()
Unselect everything that we've not downloaded so far.
Save game or scenario file.
static const size_t MAX_SIZE
Make template parameter accessible from outside.
static ConsoleFileList _console_file_list
File storage cache for the console.
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
char password[NETWORK_PASSWORD_LENGTH]
The password for the company.
static bool IsConnected()
Check whether the client is actually connected (and in the game).
char name[32]
Name of the content.
NetworkSettings network
settings related to the network
void AddCallback(ContentCallback *cb)
Add a callback to this class.
Internally used functions for the console.
void SetTitle(const char *title)
Set the title of the file.
Functions/types related to saving and loading games.
CompanyID client_playas
As which company is this client playing (CompanyID)
ConstContentIterator End() const
Get the end of the content inf iterator.
void GamelogPrintConsole()
Print the gamelog data to the console.
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for GameScanner::GetConsoleLibraryList.
IConsoleAlias * next
next alias in list
void NetworkServerKickClient(ClientID client_id)
Kick a single client.
The client is spectating.
void SelectUpgrade()
Select everything that's an update for something we've got.
Functions related to engines.
uint8 max_spectators
maximum amount of spectators
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
void IConsolePrint(TextColour colour_code, const char *string)
Handle the printing of text entered into the console or redirected there by any other means...
IConsoleCmd * IConsoleCmdGet(const char *name)
Find the command pointed to by its string.
File list storage for the console, for caching the last 'ls' command.
void IConsoleCmdExec(const char *cmdstr)
Execute a given command passed to us.
Functions related to setting/changing the settings.
ClientID _network_own_client_id
Our client identifier.
ClientSettings _settings_client
The current settings for this game.
FILE * FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
void CDECL IConsolePrintF(TextColour colour_code, const char *format,...)
Handle the printing of text entered into the console or redirected there by any other means...
Definition of base types and functions in a cross-platform compatible way.
Data structure to convert between Date and triplet (year, month, and day).
A number of safeguards to prevent using unsafe methods.
ContentID id
Unique (server side) ID for the content.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
NetworkCompanyState * _network_company_states
Statistics about some companies.
void ShowFramerateWindow()
Open the general framerate window.
Base directory for all savegames.
Base directory for all subdirectories.
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Construct a file list with the given kind of files, for the stated purpose.
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
void NetworkPrintClients()
Print all the clients to the console.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Console functions used outside of the console code.
void RequestContentList(ContentType type)
Request the content list for the given type.
State state
Whether the content info is selected (for download)
void ConPrintFramerate()
Print performance statistics to game console.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
static void IConsoleHelp(const char *str)
Show help for the console.
byte clients_on
Current count of clients on server.
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?"
void InvalidateFileList()
Declare the file storage cache as being invalid, also clears all stored files.
const char * GetDebugString()
Print out the current debug-level.
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
NetworkServerGameInfo _network_game_info
Information about our game.
PauseMode _pause_mode
The current pause mode.
byte md5sum[16]
The MD5 checksum.
static const TextColour CC_COMMAND
Colour for the console's commands.
IConsoleAlias * IConsoleAliasGet(const char *name)
Find the alias pointed to by its string.
uint8 max_companies
maximum amount of companies
char * RemoveUnderscores(char *name)
Remove underscores from a string; the string will be modified!
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool MakeScreenshot(ScreenshotType t, const char *name)
Make an actual screenshot.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
ContentType
The values in the enum are important; they are used as database 'keys'.
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
Change the client name of the given client.
bool FiosDelete(const char *name)
Delete a file.
void StartupEngines()
Start/initialise all our engines.
void Select(ContentID cid)
Select a specific content id.
Functions related to companies.
static uint MapSize()
Get the size of the map.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
static const uint16 NETWORK_DEFAULT_PORT
The default port of the game server (TCP & UDP)
void SelectAll()
Select everything we can select.
uint32 generation_seed
noise seed for world generation
GUISettings gui
settings related to the GUI
–Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Declarations for savegames operations.
uint32 TileIndex
The index/ID of a Tile.
void IConsoleAliasRegister(const char *name, const char *cmd)
Register a an alias for an already existing command in the console.
static size_t GetNumItems()
Returns number of valid items in the pool.
List of file information.
ContentType type
Type of content.
const char * FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
uint8 max_clients
maximum amount of clients
Restart –> 'Random game' with current settings.
void NetworkClientSendRcon(const char *password, const char *command)
Send a remote console command.
char * cmdline
command(s) that is/are being aliased
static void Rescan()
Rescans all searchpaths for available AIs.
IConsoleHook * hook
any special trigger action that needs executing
void IConsoleError(const char *string)
It is possible to print error information to the console.
DEF_CONSOLE_CMD(ConResetEngines)
Reset status of all engines.
Helper to mark the begin of the types.
Maximum number of companies.
StringList _network_ban_list
The banned clients.
void ValidateFileList(bool force_reload=false)
(Re-)validate the file storage cache.
SwitchMode _switch_mode
The next mainloop command.
Functions related to OTTD's landscape.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
Base functions for all Games.
Functions related to commands.
Network functions used by other parts of OpenTTD.
bool _network_server
network-server is active
static const uint ICON_CMDLN_SIZE
maximum length of a typed in command
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for AIScanner::GetAIConsoleLibraryList.
static const TextColour CC_ERROR
Colour for error lines.
void NetworkDisconnect(bool blocking, bool close_admins)
We want to disconnect from the host/clients.
bool ai_in_multiplayer
so we allow AIs in multiplayer
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
The content has been manually selected.
char last_host[NETWORK_HOSTNAME_LENGTH]
IP address of the last joined server.
static bool CanStartNew()
Is it possible to start a new AI company?
Base functions for all AIs.
Servers always have this ID.
GameCreationSettings game_creation
settings used during the creation of a game (map)
void SetMode(FiosType ft)
Set the mode and file type of the file to save or load based on the type of file entry at the file sy...
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
bool file_list_valid
If set, the file list is valid.
AIConfig stores the configuration settings of every AI.
Window functions not directly related to making/drawing windows.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
void StringToSettings(const char *value)
Convert a string which is stored in the config file or savegames to custom settings of this Script...
const char * NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
Change the company password of a given company.
Disallow command execution.
Date _date
Current date in days (day counter)
static bool NetworkAvailable(bool echo)
Check network availability and inform in console about failure of detection.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
static const TextColour CC_WARNING
Colour for warning lines.
Send message/notice to everyone playing the same company (Team)
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Container for all important information about a piece of content.
bool GetArgumentInteger(uint32 *value, const char *arg)
Change a string into its number representation.
static const TextColour CC_WHITE
White console lines for various things such as the welcome.
A game paused because a (critical) error.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook)
Register a new command to be used in the console.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
static const TextColour CC_INFO
Colour for information lines.
DEF_CONSOLE_HOOK(ConHookServerOnly)
Check whether we are a server.
Server part of the admin network protocol.
void IConsoleClose()
Close the in-game console.
ScreenshotType
Type of requested screenshot.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Base for the NewGRF implementation.