OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
43 #include "table/strings.h"
84 #define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
85 #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
99 if (echo)
IConsolePrint(
CC_ERROR,
"You cannot use this command because there is no network available.");
179 if (_game_mode == GM_MENU) {
183 return ConHookNoNetwork(echo);
195 IConsolePrint(
CC_HELP,
"Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'.");
211 IConsolePrint(
CC_HELP,
"Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again.");
215 if (_game_mode == GM_MENU) {
315 char *filename =
str_fmt(
"%s.sav", argv[1]);
337 IConsolePrint(
CC_HELP,
"Saves the configuration for new games to the configuration file, typically 'openttd.cfg'.");
338 IConsolePrint(
CC_HELP,
"It does not save the configuration of the current game to the configuration file.");
354 if (argc != 2)
return false;
356 const char *file = argv[1];
359 if (item !=
nullptr) {
383 if (argc != 2)
return false;
385 const char *file = argv[1];
388 if (item !=
nullptr) {
405 IConsolePrint(
CC_HELP,
"List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'.");
425 if (argc != 2)
return false;
427 const char *file = argv[1];
430 if (item !=
nullptr) {
431 switch (item->type) {
432 case FIOS_TYPE_DIR:
case FIOS_TYPE_DRIVE:
case FIOS_TYPE_PARENT:
470 IConsoleClearBuffer();
480 static bool ConKickOrBan(
const char *argv,
bool ban,
const std::string &reason)
484 if (strchr(argv,
'.') ==
nullptr && strchr(argv,
':') ==
nullptr) {
526 IConsolePrint(
CC_HELP,
"Kick a client from a network game. Usage: 'kick <ip | client-id> [<kick-reason>]'.");
531 if (argc != 2 && argc != 3)
return false;
534 if (argc == 2)
return ConKickOrBan(argv[1],
false, {});
537 size_t kick_message_length = strlen(argv[2]);
538 if (kick_message_length >= 255) {
539 IConsolePrint(
CC_ERROR,
"Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length);
542 return ConKickOrBan(argv[1],
false, argv[2]);
549 IConsolePrint(
CC_HELP,
"Ban a client from a network game. Usage: 'ban <ip | client-id> [<ban-reason>]'.");
555 if (argc != 2 && argc != 3)
return false;
558 if (argc == 2)
return ConKickOrBan(argv[1],
true, {});
561 size_t kick_message_length = strlen(argv[2]);
562 if (kick_message_length >= 255) {
563 IConsolePrint(
CC_ERROR,
"Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length);
566 return ConKickOrBan(argv[1],
true, argv[2]);
573 IConsolePrint(
CC_HELP,
"Unban a client from a network game. Usage: 'unban <ip | banlist-index>'.");
578 if (argc != 2)
return false;
588 index = atoi(argv[1]) - 1U;
627 if (_game_mode == GM_MENU) {
649 if (_game_mode == GM_MENU) {
671 IConsolePrint(
CC_HELP,
"Remote control the server from another client. Usage: 'rcon <password> <command>'.");
672 IConsolePrint(
CC_HELP,
"Remember to enclose the command in quotes, otherwise only the first parameter is sent.");
676 if (argc < 3)
return false;
689 IConsolePrint(
CC_HELP,
"List the status of all clients connected to the server. Usage 'status'.");
701 IConsolePrint(
CC_HELP,
"You can change these values by modifying settings 'network.max_clients' and 'network.max_companies'.");
716 IConsolePrint(
CC_HELP,
"Change the nickname of a connected client. Usage: 'client_name <client-id> <new-name>'.");
733 std::string client_name(argv[2]);
750 IConsolePrint(
CC_HELP,
"Request joining another company. Usage: 'join <company-id> [<password>]'.");
792 IConsolePrint(
CC_HELP,
"Move a client to another company. Usage: 'move <client-id> <company-id>'.");
793 IConsolePrint(
CC_HELP,
"For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators.");
835 IConsolePrint(
CC_HELP,
"Remove an idle company from the game. Usage: 'reset_company <company-id>'.");
836 IConsolePrint(
CC_HELP,
"For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
840 if (argc != 2)
return false;
875 IConsolePrint(
CC_HELP,
"Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'.");
887 IConsolePrint(
CC_HELP,
"Reconnect to server to which you were connected last time. Usage: 'reconnect [<company>]'.");
888 IConsolePrint(
CC_HELP,
"Company 255 is spectator (default, if not specified), 0 means creating new company.");
900 if (playas < COMPANY_FIRST + 1 || playas >
MAX_COMPANIES + 1)
return false;
918 IConsolePrint(
CC_HELP,
"Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'.");
919 IConsolePrint(
CC_HELP,
"IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'.");
920 IConsolePrint(
CC_HELP,
"Company #255 is spectator all others are a certain company with Company 1 being #1.");
924 if (argc < 2)
return false;
940 if (argc < 2)
return false;
944 if (script_file ==
nullptr) {
945 if (argc == 2 || atoi(argv[2]) != 0)
IConsolePrint(
CC_ERROR,
"Script file '{}' not found.", argv[1]);
951 IConsolePrint(
CC_ERROR,
"Maximum 'exec' depth reached; script A is calling script B is calling script C ... more than 10 times.");
959 while (fgets(cmdline,
sizeof(cmdline), script_file) !=
nullptr) {
961 for (
char *cmdptr = cmdline; *cmdptr !=
'\0'; cmdptr++) {
962 if (*cmdptr ==
'\n' || *cmdptr ==
'\r') {
975 if (ferror(script_file)) {
998 extern bool CloseConsoleLogIfActive();
1002 extern FILE *_iconsole_output_file;
1005 IConsolePrint(
CC_HELP,
"Start or stop logging console output to a file. Usage: 'script <filename>'.");
1010 if (!CloseConsoleLogIfActive()) {
1011 if (argc < 2)
return false;
1013 _iconsole_output_file = fopen(argv[1],
"ab");
1014 if (_iconsole_output_file ==
nullptr) {
1032 if (argc < 2)
return false;
1040 IConsolePrint(
CC_HELP,
"Print back the first argument to the console in a given colour. Usage: 'echoc <colour> <arg2>'.");
1044 if (argc < 3)
return false;
1053 IConsolePrint(
CC_HELP,
"The server can force a new game using 'newgame'; any client joined will rejoin after the server is done generating the new game.");
1065 IConsolePrint(
CC_HELP,
"Restarts a game. It tries to reproduce the exact same map as the game started with.");
1067 IConsolePrint(
CC_HELP,
" * restarting games started in another version might create another map due to difference in map generation.");
1068 IConsolePrint(
CC_HELP,
" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame.");
1084 IConsolePrint(
CC_HELP,
" * if you started from a savegame / scenario / heightmap, that exact same savegame / scenario / heightmap will be loaded.");
1105 for (
char *p2 = buf; *p2 !=
'\0'; p2++) {
1156 if (argc == 0 || argc > 3) {
1158 IConsolePrint(
CC_HELP,
"Start a new AI. If <AI> is given, it starts that specific AI (if found).");
1159 IConsolePrint(
CC_HELP,
"If <settings> is given, it is parsed and the AI settings are set to that.");
1163 if (_game_mode != GM_NORMAL) {
1189 if (c->index != n)
break;
1195 config->
Change(argv[1], -1,
false);
1201 char *name =
stredup(argv[1]);
1202 char *e = strrchr(name,
'.');
1207 int version = atoi(e);
1208 config->
Change(name, version,
true);
1232 IConsolePrint(
CC_HELP,
"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.");
1236 if (_game_mode != GM_NORMAL) {
1270 IConsolePrint(
CC_HELP,
"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.");
1274 if (_game_mode != GM_NORMAL) {
1345 IConsolePrint(
CC_ERROR,
"NewGRF scanning is already running. Please wait until completed to run again.");
1355 IConsolePrint(
CC_HELP,
"The seed can be used to reproduce the exact same map as the game started with.");
1366 IConsolePrint(
CC_HELP,
"Returns the current date (year-month-day) of the game. Usage: 'getdate'.");
1379 IConsolePrint(
CC_HELP,
"Returns the current date (year-month-day) of your system. Usage: 'getsysdate'.");
1383 char buffer[
lengthof(
"2000-01-02 03:04:05")];
1395 IConsolePrint(
CC_HELP,
"Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'.");
1399 if (argc < 3)
return false;
1402 if (alias ==
nullptr) {
1413 IConsolePrint(
CC_HELP,
"Create a screenshot of the game. Usage: 'screenshot [viewport | normal | big | giant | heightmap | minimap] [no_con] [size <width> <height>] [<filename>]'.");
1414 IConsolePrint(
CC_HELP,
" 'viewport' (default) makes a screenshot of the current viewport (including menus, windows).");
1418 IConsolePrint(
CC_HELP,
" 'heightmap' makes a heightmap screenshot of the map that can be loaded in as heightmap.");
1419 IConsolePrint(
CC_HELP,
" 'minimap' makes a top-viewed minimap screenshot of the whole world which represents one tile by one pixel.");
1420 IConsolePrint(
CC_HELP,
" 'no_con' hides the console to create the screenshot (only useful in combination with 'viewport').");
1421 IConsolePrint(
CC_HELP,
" 'size' sets the width and height of the viewport to make a screenshot of (only useful in combination with 'normal' or 'big').");
1425 if (argc > 7)
return false;
1431 uint32 arg_index = 1;
1433 if (argc > arg_index) {
1434 if (strcmp(argv[arg_index],
"viewport") == 0) {
1437 }
else if (strcmp(argv[arg_index],
"normal") == 0) {
1440 }
else if (strcmp(argv[arg_index],
"big") == 0) {
1443 }
else if (strcmp(argv[arg_index],
"giant") == 0) {
1446 }
else if (strcmp(argv[arg_index],
"heightmap") == 0) {
1449 }
else if (strcmp(argv[arg_index],
"minimap") == 0) {
1455 if (argc > arg_index && strcmp(argv[arg_index],
"no_con") == 0) {
1464 if (argc > arg_index + 2 && strcmp(argv[arg_index],
"size") == 0) {
1475 if (argc > arg_index) {
1477 name = argv[arg_index];
1481 if (argc > arg_index) {
1493 IConsolePrint(
CC_HELP,
"Print out debugging information about a command. Usage: 'info_cmd <cmd>'.");
1497 if (argc < 2)
return false;
1500 if (cmd ==
nullptr) {
1515 IConsolePrint(
CC_HELP,
"Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'.");
1516 IConsolePrint(
CC_HELP,
"Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'\"s.");
1520 if (argc > 2)
return false;
1547 IConsolePrint(
CC_HELP,
"Leave the currently joined/running game (only ingame). Usage: 'part'.");
1551 if (_game_mode != GM_NORMAL)
return false;
1564 if (cmd !=
nullptr) {
1565 cmd->
proc(0,
nullptr);
1570 if (alias !=
nullptr) {
1572 if (cmd !=
nullptr) {
1573 cmd->
proc(0,
nullptr);
1584 IConsolePrint(TC_LIGHT_BLUE,
" ---- OpenTTD Console Help ---- ");
1603 for (
auto &it : IConsole::Commands()) {
1605 if (argv[1] ==
nullptr || cmd->
name.find(argv[1]) != std::string::npos) {
1620 for (
auto &it : IConsole::Aliases()) {
1622 if (argv[1] ==
nullptr || alias->
name.find(argv[1]) != std::string::npos) {
1639 char company_name[512];
1641 GetString(company_name, STR_COMPANY_NAME,
lastof(company_name));
1643 const char *password_state =
"";
1645 password_state =
"AI";
1652 IConsolePrint(
CC_INFO,
"#:{}({}) Company Name: '{}' Year Founded: {} Money: {} Loan: {} Value: {} (T:{}, R:{}, P:{}, S:{}) {}",
1653 c->index + 1, colour, company_name,
1656 c->group_all[
VEH_ROAD].num_vehicle,
1658 c->group_all[
VEH_SHIP].num_vehicle,
1668 IConsolePrint(
CC_HELP,
"Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'.");
1672 if (argc != 2)
return false;
1687 IConsolePrint(
CC_HELP,
"Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'.");
1688 IConsolePrint(
CC_HELP,
"CompanyNo is the company that plays as company <companyno>, 1 through max_companies.");
1692 if (argc != 3)
return false;
1713 IConsolePrint(
CC_HELP,
"Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'.");
1718 if (argc != 3)
return false;
1734 IConsolePrint(
CC_HELP,
"Change the password of a company. Usage: 'company_pw <company-no> \"<password>\".");
1736 IConsolePrint(
CC_HELP,
"Change the password of your or any other company. Usage: 'company_pw [<company-no>] \"<password>\"'.");
1738 IConsolePrint(
CC_HELP,
"Change the password of your company. Usage: 'company_pw \"<password>\"'.");
1746 std::string password;
1747 const char *errormsg;
1752 errormsg =
"You have to own a company to make use of this command.";
1754 company_id = (
CompanyID)(atoi(argv[1]) - 1);
1756 errormsg =
"You have to specify the ID of a valid human controlled company.";
1768 if (password.empty()) {
1778 #if defined(WITH_ZLIB)
1784 static const char *
const inv_lookup[] = {
"",
"base",
"newgrf",
"ai",
"ailib",
"scenario",
"heightmap" };
1785 for (uint i = 1 ; i <
lengthof(inv_lookup); i++) {
1786 if (strcasecmp(str, inv_lookup[i]) == 0)
return (
ContentType)i;
1815 static const char *
const types[] = {
"Base graphics",
"NewGRF",
"AI",
"AI library",
"Scenario",
"Heightmap",
"Base sound",
"Base music",
"Game script",
"GS library" };
1817 static const char *
const states[] = {
"Not selected",
"Selected",
"Dep Selected",
"Installed",
"Unknown" };
1820 char buf[
sizeof(ci->
md5sum) * 2 + 1];
1822 IConsolePrint(state_to_colour[ci->
state],
"{}, {}, {}, {}, {:08X}, {}", ci->
id, types[ci->
type - 1], states[ci->
state], ci->
name, ci->
unique_id, buf);
1828 if (cb ==
nullptr) {
1834 IConsolePrint(
CC_HELP,
"Query, select and download content. Usage: 'content update|upgrade|select [id]|unselect [all|id]|state [filter]|download'.");
1837 IConsolePrint(
CC_HELP,
" select: select a specific item given by its id. If no parameter is given, all selected content will be listed.");
1838 IConsolePrint(
CC_HELP,
" unselect: unselect a specific item given by its id or 'all' to unselect all.");
1839 IConsolePrint(
CC_HELP,
" state: show the download/select state of all downloadable content. Optionally give a filter string.");
1844 if (strcasecmp(argv[1],
"update") == 0) {
1849 if (strcasecmp(argv[1],
"upgrade") == 0) {
1854 if (strcasecmp(argv[1],
"select") == 0) {
1862 }
else if (strcasecmp(argv[2],
"all") == 0) {
1876 if (strcasecmp(argv[1],
"unselect") == 0) {
1881 if (strcasecmp(argv[2],
"all") == 0) {
1889 if (strcasecmp(argv[1],
"state") == 0) {
1892 if (argc > 2 && strcasestr((*iter)->name.c_str(), argv[2]) ==
nullptr)
continue;
1898 if (strcasecmp(argv[1],
"download") == 0) {
1918 if (argc == 1 || argc > 3)
return false;
1923 IConsoleSetSetting(argv[1], argv[2]);
1932 IConsolePrint(
CC_HELP,
"Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'.");
1937 if (argc == 1 || argc > 3)
return false;
1942 IConsoleSetSetting(argv[1], argv[2],
true);
1955 if (argc > 2)
return false;
1970 IConsolePrint(
CC_HELP,
"Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
1981 IConsolePrint(
CC_HELP,
"Collect performance data about NewGRF sprite requests and callbacks. Sub-commands can be abbreviated.");
1987 IConsolePrint(
CC_HELP,
" Unselect one or more GRFs from profiling. Use the keyword \"all\" instead of a GRF number to unselect all. Removing an active profiler aborts data collection.");
1989 IConsolePrint(
CC_HELP,
" Begin profiling all selected GRFs. If a number of days is provided, profiling stops after that many in-game days.");
1997 extern const std::vector<GRFFile *> &GetAllGRFFiles();
1998 const std::vector<GRFFile *> &files = GetAllGRFFiles();
2001 if (argc == 1 || strncasecmp(argv[1],
"lis", 3) == 0) {
2005 auto profiler = std::find_if(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](
NewGRFProfiler &pr) { return pr.grffile == grf; });
2006 bool selected = profiler != _newgrf_profilers.end();
2007 bool active = selected && profiler->active;
2009 const char *statustext = active ?
" (active)" : selected ?
" (selected)" :
"";
2017 if (strncasecmp(argv[1],
"sel", 3) == 0 && argc >= 3) {
2018 for (
size_t argnum = 2; argnum < argc; ++argnum) {
2019 int grfnum = atoi(argv[argnum]);
2020 if (grfnum < 1 || grfnum > (
int)files.size()) {
2024 GRFFile *grf = files[grfnum - 1];
2025 if (std::any_of(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](
NewGRFProfiler &pr) { return pr.grffile == grf; })) {
2029 _newgrf_profilers.emplace_back(grf);
2035 if (strncasecmp(argv[1],
"uns", 3) == 0 && argc >= 3) {
2036 for (
size_t argnum = 2; argnum < argc; ++argnum) {
2037 if (strcasecmp(argv[argnum],
"all") == 0) {
2038 _newgrf_profilers.clear();
2041 int grfnum = atoi(argv[argnum]);
2042 if (grfnum < 1 || grfnum > (
int)files.size()) {
2046 GRFFile *grf = files[grfnum - 1];
2047 auto pos = std::find_if(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](
NewGRFProfiler &pr) { return pr.grffile == grf; });
2048 if (pos != _newgrf_profilers.end()) _newgrf_profilers.erase(pos);
2054 if (strncasecmp(argv[1],
"sta", 3) == 0) {
2062 if (!grfids.empty()) grfids +=
", ";
2063 char grfidstr[12]{ 0 };
2071 int days = std::max(atoi(argv[2]), 1);
2072 _newgrf_profile_end_date =
_date + days;
2074 char datestrbuf[32]{ 0 };
2076 GetString(datestrbuf, STR_JUST_DATE_ISO,
lastof(datestrbuf));
2079 _newgrf_profile_end_date =
MAX_DAY;
2081 }
else if (_newgrf_profilers.empty()) {
2084 IConsolePrint(
CC_ERROR,
"Did not start profiling for any GRFs, all selected GRFs are already profiling.");
2090 if (strncasecmp(argv[1],
"sto", 3) == 0) {
2091 NewGRFProfiler::FinishAll();
2096 if (strncasecmp(argv[1],
"abo", 3) == 0) {
2100 _newgrf_profile_end_date =
MAX_DAY;
2112 static void IConsoleDebugLibRegister()
2151 static void ConDumpRoadTypes()
2160 std::map<uint32, const GRFFile *> grfs;
2163 if (rti->
label == 0)
continue;
2166 if (grf !=
nullptr) {
2168 grfs.emplace(grfid, grf);
2172 RoadTypeIsTram(rt) ?
"Tram" :
"Road",
2183 for (
const auto &grf : grfs) {
2188 static void ConDumpRailTypes()
2198 std::map<uint32, const GRFFile *> grfs;
2201 if (rti->
label == 0)
continue;
2204 if (grf !=
nullptr) {
2206 grfs.emplace(grfid, grf);
2221 for (
const auto &grf : grfs) {
2226 static void ConDumpCargoTypes()
2241 std::map<uint32, const GRFFile *> grfs;
2244 if (!spec->
IsValid())
continue;
2247 if (grf !=
nullptr) {
2249 grfs.emplace(grfid, grf);
2251 IConsolePrint(
CC_DEFAULT,
" {:02d} Bit: {:2d}, Label: {:c}{:c}{:c}{:c}, Callback mask: 0x{:02X}, Cargo class: {}{}{}{}{}{}{}{}{}{}{}, GRF: {:08X}, {}",
2268 GetStringPtr(spec->
name)
2271 for (
const auto &grf : grfs) {
2286 if (strcasecmp(argv[1],
"roadtypes") == 0) {
2291 if (strcasecmp(argv[1],
"railtypes") == 0) {
2296 if (strcasecmp(argv[1],
"cargotypes") == 0) {
2297 ConDumpCargoTypes();
2308 void IConsoleStdLibRegister()
2374 #if defined(WITH_ZLIB)
2431 IConsoleDebugLibRegister();
@ VEH_AIRCRAFT
Aircraft vehicle type.
static uint MapLogX()
Logarithm of the map size along the X side.
RoadTypeFlags flags
Bit mask of road type flags.
void NetworkClientSendRcon(const std::string &password, const std::string &command)
Send a remote console command.
@ ROTF_NO_LEVEL_CROSSING
Bit number for disabling level crossing.
static ConsoleFileList _console_file_list
File storage cache for the console.
Callbacks for notifying others about incoming data.
uint32 TileIndex
The index/ID of a Tile.
static const TextColour CC_INFO
Colour for information lines.
@ ROTSG_GROUND
Required: Main group of ground images.
@ CC_HAZARDOUS
Hazardous cargo (Nuclear Fuel, Explosives, etc.)
uint8 callback_mask
Bitmask of cargo callbacks that have to be called.
uint32 generation_seed
noise seed for world generation
std::string name
Name of the content.
@ CC_COVERED
Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
IConsoleCmdProc * proc
process executed when command is typed
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
CargoLabel label
Unique label of the cargo type.
StringID FiosGetDescText(const char **path, uint64 *total_free)
Get descriptive texts.
@ SAVE_DIR
Base directory for all savegames.
void NetworkServerShowStatusToConsole()
Show the status message of all clients on the console.
ContentType type
Type of content.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
ConstContentIterator End() const
Get the end of the content inf iterator.
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
@ ROTF_CATENARY
Bit number for adding catenary.
ScreenshotType
Type of requested screenshot.
@ SM_LOAD_GAME
Load game, Play Scenario.
static void OutputContentState(const ContentInfo *const ci)
Outputs content state information to console.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
uint8 map_y
Y size of map.
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
uint8 max_clients
maximum amount of clients
void SetTitle(const char *title)
Set the title of the file.
@ ROTF_TOWN_BUILD
Bit number for allowing towns to build this roadtype.
CompanyID client_playas
As which company is this client playing (CompanyID)
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?...
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
static const uint ICON_CMDLN_SIZE
maximum length of a typed in command
@ SC_HEIGHTMAP
Heightmap of the world.
@ CC_EXPRESS
Express cargo (Goods, Food, Candy, but also possible for passengers)
bool _network_server
network-server is active
const GRFFile * grffile
Which GRF is being profiled.
void SaveToConfig()
Save the values to the configuration file.
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
This struct contains all the info that is needed to draw and construct tracks.
static IConsoleAlias * AliasGet(const std::string &name)
Find the alias pointed to by its string.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
@ DFT_GAME_FILE
Save game or scenario file.
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
void SetName(const char *name)
Set the name of the file.
void ConPrintFramerate()
Print performance statistics to game console.
static bool CanStartNew()
Is it possible to start a new AI company?
bool RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ ROADTYPE_END
Used for iterations.
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
ClientSettings _settings_client
The current settings for this game.
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Specification of a cargo type.
static bool IsValidHumanID(size_t index)
Is this company a valid company, not controlled by a NoAI program?
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
@ CONTENT_TYPE_END
Helper to mark the end of the types.
#define MAX_DAY
The number of days till the last day.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
NetworkServerGameInfo _network_game_info
Information about our game.
ClientID _redirect_console_to_client
If not invalid, redirect the console output to a client.
void StartupEngines()
Start/initialise all our engines.
Owner
Enum for all companies/owners.
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
List of file information.
void InvalidateFileList()
Declare the file storage cache as being invalid, also clears all stored files.
const typedef ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
std::string cmdline
command(s) that is/are being aliased
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
ContentType
The values in the enum are important; they are used as database 'keys'.
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
static const TextColour CC_DEFAULT
Default colour of the console.
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
IConsoleHook * hook
any special trigger action that needs executing
GameCreationSettings game_creation
settings used during the creation of a game (map)
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password)
Change the company password of a given company.
std::string name
name of command
@ PM_UNPAUSED
A normal unpaused game.
static uint MapSizeX()
Get the size of the map along the X.
StringID name
Name of this rail type.
void RequestContentList(ContentType type)
Request the content list for the given type.
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
@ BASE_DIR
Base directory for all subdirectories.
static void CmdRegister(const std::string &name, IConsoleCmdProc *proc, IConsoleHook *hook=nullptr)
Register a new command to be used in the console.
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for AIScanner::GetAIConsoleLibraryList.
@ COMPANY_NEW_COMPANY
The client wants a new company.
static uint MapSize()
Get the size of the map.
@ SLO_LOAD
File is being loaded.
static uint _script_current_depth
Depth of scripts running (used to abort execution when #ConReturn is encountered).
RailType
Enumeration for all possible railtypes.
@ RTF_CATENARY
Bit number for drawing a catenary.
Date _date
Current date in days (day counter)
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
std::string last_joined
Last joined server.
@ SLO_SAVE
File is being saved.
@ CCA_NEW_AI
Create a new AI company.
@ ROTF_HIDDEN
Bit number for hidden from construction.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
static const TextColour CC_HELP
Colour for help lines.
bool FiosDelete(const char *name)
Delete a file.
@ RTF_HIDDEN
Bit number for hiding from selection.
@ CMD_PAUSE
pause the game
static bool IsConnected()
Check whether the client is actually connected (and in the game).
bool IsValid() const
Tests for validity of this cargospec.
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
void StrTrimInPlace(std::string &str)
Trim the spaces from given string in place, i.e.
void UnselectAll()
Unselect everything that we've not downloaded so far.
@ CC_PIECE_GOODS
Piece goods (Livestock, Wood, Steel, Paper)
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Construct a file list with the given kind of files, for the stated purpose.
Container for all important information about a piece of content.
ClientID
'Unique' identifier to be given to clients
void OnDisconnect()
Callback for when the connection got disconnected.
@ RTF_DISALLOW_90DEG
Bit number for never allowed 90 degree turns, regardless of setting.
void ShowFramerateWindow()
Open the general framerate window.
@ CC_BULK
Bulk cargo (Coal, Grain etc., Ores, Fruit)
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
const struct GRFFile * grffile
NewGRF where #group belongs to.
Deals with finding savegames.
PauseMode _pause_mode
The current pause mode.
byte md5sum[16]
The MD5 checksum.
void Unselect(ContentID cid)
Unselect a specific content id.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ CHR_ALLOW
Allow command execution.
bool GetArgumentInteger(uint32 *value, const char *arg)
Change a string into its number representation.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
void NetworkPrintClients()
Print all the clients to the console.
@ MAX_COMPANIES
Maximum number of companies.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
const char * FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
const FiosItem * FindItem(const char *file)
Find file information of a file by its name from the file list.
@ ROTF_NO_HOUSES
Bit number for setting this roadtype as not house friendly.
std::string password
The password for the company.
bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_name)
Change the client name of the given client.
@ CLIENT_ID_SERVER
Servers always have this ID.
void StringToSettings(const std::string &value)
Convert a string which is stored in the config file or savegames to custom settings of this Script.
NetworkCompanyState * _network_company_states
Statistics about some companies.
@ SELECTED
The content has been manually selected.
static const TextColour CC_DEBUG
Colour for debug output.
bool _networking
are we in networking mode?
void GamelogPrintConsole()
Print the gamelog data to the console.
static size_t Format(char *buffer, const char *last, const char *format) NOACCESS(2) WARN_TIME_FORMAT(3)
Format the current time with the given strftime format specifiers.
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const std::string &reason)
Ban, or kick, everyone joined from the given client's IP.
@ RTSG_GROUND
Main group of ground images.
void ValidateFileList(bool force_reload=false)
(Re-)validate the file storage cache.
StringID name
Name of this rail type.
static uint MapSizeY()
Get the size of the map along the Y.
bool active
Is this profiler collecting data.
@ ROADTYPE_BEGIN
Used for iterations.
bool _network_dedicated
are we a dedicated server?
@ CRR_MANUAL
The company is manually removed.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
@ FT_SAVEGAME
old or new savegame
RoadType
The different roadtypes we support.
static const TextColour CC_COMMAND
Colour for the console's commands.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
bool file_list_valid
If set, the file list is valid.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
ClientID client_id
Client identifier (same as ClientState->client_id)
File list storage for the console, for caching the last 'ls' command.
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for AIScanner::GetAIConsoleList.
ClientID _network_own_client_id
Our client identifier.
std::string name
name of the alias
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data)
Send a chat message.
AISettings ai
what may the AI do?
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
const GRFFile * grffile[ROTSG_END]
NewGRF providing the Action3 for the roadtype.
SwitchMode _switch_mode
The next mainloop command.
void OnConnect(bool success)
Callback for when the connection has finished.
RailTypeFlags flags
Bit mask of rail type flags.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Callback profiler for NewGRF development.
void IConsoleListSettings(const char *prefilter)
List all settings and their value to the console.
@ SC_WORLD
World screenshot.
@ CC_ARMOURED
Armoured cargo (Valuables, Gold, Diamonds)
static size_t GetNumItems()
Returns number of valid items in the pool.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
RoadTypeLabel label
Unique 32 bit road type identifier.
char *CDECL str_fmt(const char *str,...)
Format, "printf", into a newly allocated string.
uint8 map_x
X size of map.
@ AUTOSELECTED
The content has been selected as dependency.
@ COMPANY_SPECTATOR
The client is spectating.
@ RAILTYPE_END
Used for iterations.
@ CC_REFRIGERATED
Refrigerated cargo (Food, Fruit)
DEF_CONSOLE_CMD(ConResetEngines)
Reset status of all engines.
@ WC_CONSOLE
Console; Window numbers:
const char * GetDebugString()
Print out the current debug-level.
static void PrintLineByLine(char *buf)
Print a text buffer line by line to the console.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
ContentID
Unique identifier for the content.
static void AliasRegister(const std::string &name, const std::string &cmd)
Register a an alias for an already existing command in the console.
@ PM_PAUSED_NORMAL
A game normally paused.
–Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc.
uint16 classes
Classes of this cargo type.
@ NUM_CARGO
Maximal number of cargo types in a game.
@ RTF_ALLOW_90DEG
Bit number for always allowed 90 degree turns, regardless of setting.
RailTypeLabel label
Unique 32 bit rail type identifier.
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
static ContentType StringToContentType(const char *str)
Resolve a string to a content type.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
void Select(ContentID cid)
Select a specific content id.
StringID name
Name of this type of cargo.
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
@ RTF_NO_SPRITE_COMBINE
Bit number for using non-combined junctions.
static const TextColour CC_ERROR
Colour for error lines.
@ SM_RELOADGAME
Reload the savegame / scenario / heightmap you started the game with.
@ SM_MENU
Switch to game intro menu.
@ CMD_COMPANY_CTRL
used in multiplayer to create a new companies etc.
bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
Schedule making a screenshot.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
static bool NetworkAvailable(bool echo)
Check network availability and inform in console about failure of detection.
@ CHR_DISALLOW
Disallow command execution.
void IConsoleGetSetting(const char *name, bool force_newgame)
Output value of a specific setting to the console.
State state
Whether the content info is selected (for download)
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password, const std::string &join_company_password)
Join a client to the server at with the given connection string.
uint32 unique_id
Unique ID; either GRF ID or shortname.
@ RTF_NO_LEVEL_CROSSING
Bit number for disallowing level crossings.
#define lengthof(x)
Return the length of an fixed size array.
Data structure to convert between Date and triplet (year, month, and day).
StringList _network_ban_list
The banned clients.
NetworkSettings network
settings related to the network
void IConsoleClose()
Close the in-game console.
@ SC_VIEWPORT
Screenshot of viewport.
byte CargoID
Cargo slots to indicate a cargo type within a game.
@ DESTTYPE_BROADCAST
Send message/notice to all clients (All)
@ CHR_HIDE
Hide the existence of the command.
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
@ INVALID_COMPANY
An invalid company.
DEF_CONSOLE_HOOK(ConHookServerOnly)
Check whether we are a server.
void IConsoleCmdExec(const char *cmdstr, const uint recurse_count)
Execute a given command passed to us.
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.
void NetworkServerKickClient(ClientID client_id, const std::string &reason)
Kick a single client.
@ CCA_DELETE
Delete a company.
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
@ SC_MINIMAP
Minimap screenshot.
byte clients_on
Current count of clients on server.
bool _network_available
is network mode available?
void SelectUpgrade()
Select everything that's an update for something we've got.
static const TextColour CC_WARNING
Colour for warning lines.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
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...
ContentID id
Unique (server side) ID for the content.
static void Rescan()
Rescans all searchpaths for available AIs.
@ VEH_SHIP
Ship vehicle type.
@ PM_PAUSED_ERROR
A game paused because a (critical) error.
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
static const TextColour CC_WHITE
White console lines for various things such as the welcome.
#define lastof(x)
Get the last element of an fixed size array.
@ SL_OK
completed successfully
static char * GetConsoleLibraryList(char *p, const char *last)
Wrapper function for GameScanner::GetConsoleLibraryList.
Container for all information known about a client.
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
bool NetworkIsValidClientName(const std::string_view client_name)
Check whether the given client name is deemed valid for use in network games.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
bool ai_in_multiplayer
so we allow AIs in multiplayer
static char * GetConsoleList(char *p, const char *last, bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
static IConsoleCmd * CmdGet(const std::string &name)
Find the command pointed to by its string.
Dynamic data of a loaded NewGRF.
GUISettings gui
settings related to the GUI
void FioFCloseFile(FILE *f)
Close a file in a safe way.
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
uint8 max_companies
maximum amount of companies
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
@ SM_RESTARTGAME
Restart --> 'Random game' with current settings.
@ RAILTYPE_BEGIN
Used for iterations.
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.