console_cmds.cpp

Go to the documentation of this file.
00001 /* $Id: console_cmds.cpp 21703 2011-01-03 14:52:30Z yexo $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #include "stdafx.h"
00013 #include "console_internal.h"
00014 #include "debug.h"
00015 #include "engine_func.h"
00016 #include "landscape.h"
00017 #include "saveload/saveload.h"
00018 #include "network/network.h"
00019 #include "network/network_func.h"
00020 #include "network/network_base.h"
00021 #include "network/network_admin.h"
00022 #include "command_func.h"
00023 #include "settings_func.h"
00024 #include "fios.h"
00025 #include "fileio_func.h"
00026 #include "screenshot.h"
00027 #include "genworld.h"
00028 #include "strings_func.h"
00029 #include "viewport_func.h"
00030 #include "window_func.h"
00031 #include "date_func.h"
00032 #include "vehicle_func.h"
00033 #include "company_func.h"
00034 #include "gamelog.h"
00035 #include "ai/ai.hpp"
00036 #include "ai/ai_config.hpp"
00037 #include "newgrf.h"
00038 #include "console_func.h"
00039 
00040 #ifdef ENABLE_NETWORK
00041   #include "table/strings.h"
00042 #endif /* ENABLE_NETWORK */
00043 
00044 /* scriptfile handling */
00045 static bool _script_running; 
00046 
00047 /* console command defines */
00048 #define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
00049 #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
00050 
00051 
00052 /****************
00053  * command hooks
00054  ****************/
00055 
00056 #ifdef ENABLE_NETWORK
00057 
00058 static inline bool NetworkAvailable(bool echo)
00059 {
00060   if (!_network_available) {
00061     if (echo) IConsoleError("You cannot use this command because there is no network available.");
00062     return false;
00063   }
00064   return true;
00065 }
00066 
00067 DEF_CONSOLE_HOOK(ConHookServerOnly)
00068 {
00069   if (!NetworkAvailable(echo)) return CHR_DISALLOW;
00070 
00071   if (!_network_server) {
00072     if (echo) IConsoleError("This command is only available to a network server.");
00073     return CHR_DISALLOW;
00074   }
00075   return CHR_ALLOW;
00076 }
00077 
00078 DEF_CONSOLE_HOOK(ConHookClientOnly)
00079 {
00080   if (!NetworkAvailable(echo)) return CHR_DISALLOW;
00081 
00082   if (_network_server) {
00083     if (echo) IConsoleError("This command is not available to a network server.");
00084     return CHR_DISALLOW;
00085   }
00086   return CHR_ALLOW;
00087 }
00088 
00089 DEF_CONSOLE_HOOK(ConHookNeedNetwork)
00090 {
00091   if (!NetworkAvailable(echo)) return CHR_DISALLOW;
00092 
00093   if (!_networking) {
00094     if (echo) IConsoleError("Not connected. This command is only available in multiplayer.");
00095     return CHR_DISALLOW;
00096   }
00097   return CHR_ALLOW;
00098 }
00099 
00100 DEF_CONSOLE_HOOK(ConHookNoNetwork)
00101 {
00102   if (_networking) {
00103     if (echo) IConsoleError("This command is forbidden in multiplayer.");
00104     return CHR_DISALLOW;
00105   }
00106   return CHR_ALLOW;
00107 }
00108 
00109 #else
00110 # define ConHookNoNetwork NULL
00111 #endif /* ENABLE_NETWORK */
00112 
00113 DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
00114 {
00115   if (_settings_client.gui.newgrf_developer_tools) {
00116     if (_game_mode == GM_MENU) {
00117       if (echo) IConsoleError("This command is only available in game and editor.");
00118       return CHR_DISALLOW;
00119     }
00120 #ifdef ENABLE_NETWORK
00121     return ConHookNoNetwork(echo);
00122 #else
00123     return CHR_ALLOW;
00124 #endif
00125   }
00126   return CHR_HIDE;
00127 }
00128 
00129 static void IConsoleHelp(const char *str)
00130 {
00131   IConsolePrintF(CC_WARNING, "- %s", str);
00132 }
00133 
00134 DEF_CONSOLE_CMD(ConResetEngines)
00135 {
00136   if (argc == 0) {
00137     IConsoleHelp("Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'");
00138     return true;
00139   }
00140 
00141   StartupEngines();
00142   return true;
00143 }
00144 
00145 #ifdef _DEBUG
00146 DEF_CONSOLE_CMD(ConResetTile)
00147 {
00148   if (argc == 0) {
00149     IConsoleHelp("Reset a tile to bare land. Usage: 'resettile <tile>'");
00150     IConsoleHelp("Tile can be either decimal (34161) or hexadecimal (0x4a5B)");
00151     return true;
00152   }
00153 
00154   if (argc == 2) {
00155     uint32 result;
00156     if (GetArgumentInteger(&result, argv[1])) {
00157       DoClearSquare((TileIndex)result);
00158       return true;
00159     }
00160   }
00161 
00162   return false;
00163 }
00164 
00165 DEF_CONSOLE_CMD(ConStopAllVehicles)
00166 {
00167   if (argc == 0) {
00168     IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'");
00169     return true;
00170   }
00171 
00172   StopAllVehicles();
00173   return true;
00174 }
00175 #endif /* _DEBUG */
00176 
00177 DEF_CONSOLE_CMD(ConScrollToTile)
00178 {
00179   switch (argc) {
00180     case 0:
00181       IConsoleHelp("Center the screen on a given tile.");
00182       IConsoleHelp("Usage: 'scrollto <tile>' or 'scrollto <x> <y>'");
00183       IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B).");
00184       return true;
00185 
00186     case 2: {
00187       uint32 result;
00188       if (GetArgumentInteger(&result, argv[1])) {
00189         if (result >= MapSize()) {
00190           IConsolePrint(CC_ERROR, "Tile does not exist");
00191           return true;
00192         }
00193         ScrollMainWindowToTile((TileIndex)result);
00194         return true;
00195       }
00196       break;
00197     }
00198 
00199     case 3: {
00200       uint32 x, y;
00201       if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) {
00202         if (x >= MapSizeX() || y >= MapSizeY()) {
00203           IConsolePrint(CC_ERROR, "Tile does not exist");
00204           return true;
00205         }
00206         ScrollMainWindowToTile(TileXY(x, y));
00207         return true;
00208       }
00209       break;
00210     }
00211   }
00212 
00213   return false;
00214 }
00215 
00216 /* Save the map to a file */
00217 DEF_CONSOLE_CMD(ConSave)
00218 {
00219   if (argc == 0) {
00220     IConsoleHelp("Save the current game. Usage: 'save <filename>'");
00221     return true;
00222   }
00223 
00224   if (argc == 2) {
00225     char *filename = str_fmt("%s.sav", argv[1]);
00226     IConsolePrint(CC_DEFAULT, "Saving map...");
00227 
00228     if (SaveOrLoad(filename, SL_SAVE, SAVE_DIR) != SL_OK) {
00229       IConsolePrint(CC_ERROR, "Saving map failed");
00230     } else {
00231       IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename);
00232     }
00233     free(filename);
00234     return true;
00235   }
00236 
00237   return false;
00238 }
00239 
00240 /* Explicitly save the configuration */
00241 DEF_CONSOLE_CMD(ConSaveConfig)
00242 {
00243   if (argc == 0) {
00244     IConsoleHelp("Saves the configuration for new games to the configuration file, typically 'openttd.cfg'.");
00245     IConsoleHelp("It does not save the configuration of the current game to the configuration file.");
00246     return true;
00247   }
00248 
00249   SaveToConfig();
00250   IConsolePrint(CC_DEFAULT, "Saved config.");
00251   return true;
00252 }
00253 
00254 static const FiosItem *GetFiosItem(const char *file)
00255 {
00256   _saveload_mode = SLD_LOAD_GAME;
00257   BuildFileList();
00258 
00259   for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
00260     if (strcmp(file, item->name) == 0) return item;
00261     if (strcmp(file, item->title) == 0) return item;
00262   }
00263 
00264   /* If no name matches, try to parse it as number */
00265   char *endptr;
00266   int i = strtol(file, &endptr, 10);
00267   if (file == endptr || *endptr != '\0') i = -1;
00268 
00269   if (IsInsideMM(i, 0, _fios_items.Length())) return _fios_items.Get(i);
00270 
00271   /* As a last effort assume it is an OpenTTD savegame and
00272    * that the ".sav" part was not given. */
00273   char long_file[MAX_PATH];
00274   seprintf(long_file, lastof(long_file), "%s.sav", file);
00275   for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
00276     if (strcmp(long_file, item->name) == 0) return item;
00277     if (strcmp(long_file, item->title) == 0) return item;
00278   }
00279 
00280   return NULL;
00281 }
00282 
00283 
00284 DEF_CONSOLE_CMD(ConLoad)
00285 {
00286   if (argc == 0) {
00287     IConsoleHelp("Load a game by name or index. Usage: 'load <file | number>'");
00288     return true;
00289   }
00290 
00291   if (argc != 2) return false;
00292 
00293   const char *file = argv[1];
00294   const FiosItem *item = GetFiosItem(file);
00295   if (item != NULL) {
00296     switch (item->type) {
00297       case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: {
00298         _switch_mode = SM_LOAD;
00299         SetFiosType(item->type);
00300 
00301         strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));
00302         strecpy(_file_to_saveload.title, item->title, lastof(_file_to_saveload.title));
00303         break;
00304       }
00305       default: IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
00306     }
00307   } else {
00308     IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
00309   }
00310 
00311   FiosFreeSavegameList();
00312   return true;
00313 }
00314 
00315 
00316 DEF_CONSOLE_CMD(ConRemove)
00317 {
00318   if (argc == 0) {
00319     IConsoleHelp("Remove a savegame by name or index. Usage: 'rm <file | number>'");
00320     return true;
00321   }
00322 
00323   if (argc != 2) return false;
00324 
00325   const char *file = argv[1];
00326   const FiosItem *item = GetFiosItem(file);
00327   if (item != NULL) {
00328     if (!FiosDelete(item->name)) {
00329       IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file);
00330     }
00331   } else {
00332     IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
00333   }
00334 
00335   FiosFreeSavegameList();
00336   return true;
00337 }
00338 
00339 
00340 /* List all the files in the current dir via console */
00341 DEF_CONSOLE_CMD(ConListFiles)
00342 {
00343   if (argc == 0) {
00344     IConsoleHelp("List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'");
00345     return true;
00346   }
00347 
00348   BuildFileList();
00349 
00350   for (uint i = 0; i < _fios_items.Length(); i++) {
00351     IConsolePrintF(CC_DEFAULT, "%d) %s", i, _fios_items[i].title);
00352   }
00353 
00354   FiosFreeSavegameList();
00355   return true;
00356 }
00357 
00358 /* Change the dir via console */
00359 DEF_CONSOLE_CMD(ConChangeDirectory)
00360 {
00361   if (argc == 0) {
00362     IConsoleHelp("Change the dir via console. Usage: 'cd <directory | number>'");
00363     return true;
00364   }
00365 
00366   if (argc != 2) return false;
00367 
00368   const char *file = argv[1];
00369   const FiosItem *item = GetFiosItem(file);
00370   if (item != NULL) {
00371     switch (item->type) {
00372       case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT:
00373         FiosBrowseTo(item);
00374         break;
00375       default: IConsolePrintF(CC_ERROR, "%s: Not a directory.", file);
00376     }
00377   } else {
00378     IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
00379   }
00380 
00381   FiosFreeSavegameList();
00382   return true;
00383 }
00384 
00385 DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
00386 {
00387   const char *path;
00388 
00389   if (argc == 0) {
00390     IConsoleHelp("Print out the current working directory. Usage: 'pwd'");
00391     return true;
00392   }
00393 
00394   /* XXX - Workaround for broken file handling */
00395   FiosGetSavegameList(SLD_LOAD_GAME);
00396   FiosFreeSavegameList();
00397 
00398   FiosGetDescText(&path, NULL);
00399   IConsolePrint(CC_DEFAULT, path);
00400   return true;
00401 }
00402 
00403 DEF_CONSOLE_CMD(ConClearBuffer)
00404 {
00405   if (argc == 0) {
00406     IConsoleHelp("Clear the console buffer. Usage: 'clear'");
00407     return true;
00408   }
00409 
00410   IConsoleClearBuffer();
00411   SetWindowDirty(WC_CONSOLE, 0);
00412   return true;
00413 }
00414 
00415 
00416 /**********************************
00417  * Network Core Console Commands
00418  **********************************/
00419 #ifdef ENABLE_NETWORK
00420 
00421 static bool ConKickOrBan(const char *argv, bool ban)
00422 {
00423   const char *ip = argv;
00424 
00425   if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
00426     ClientID client_id = (ClientID)atoi(argv);
00427 
00428     if (client_id == CLIENT_ID_SERVER) {
00429       IConsolePrintF(CC_ERROR, "ERROR: Silly boy, you can not %s yourself!", ban ? "ban" : "kick");
00430       return true;
00431     }
00432 
00433     NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
00434     if (ci == NULL) {
00435       IConsoleError("Invalid client");
00436       return true;
00437     }
00438 
00439     if (!ban) {
00440       /* Kick only this client, not all clients with that IP */
00441       NetworkServerKickClient(client_id);
00442       return true;
00443     }
00444 
00445     /* When banning, kick+ban all clients with that IP */
00446     ip = GetClientIP(ci);
00447   }
00448 
00449   uint n = NetworkServerKickOrBanIP(ip, ban);
00450   if (n == 0) {
00451     IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found");
00452   } else {
00453     IConsolePrintF(CC_DEFAULT, "%sed %u client(s)", ban ? "Bann" : "Kick", n);
00454   }
00455 
00456   return true;
00457 }
00458 
00459 DEF_CONSOLE_CMD(ConKick)
00460 {
00461   if (argc == 0) {
00462     IConsoleHelp("Kick a client from a network game. Usage: 'kick <ip | client-id>'");
00463     IConsoleHelp("For client-id's, see the command 'clients'");
00464     return true;
00465   }
00466 
00467   if (argc != 2) return false;
00468 
00469   return ConKickOrBan(argv[1], false);
00470 }
00471 
00472 DEF_CONSOLE_CMD(ConBan)
00473 {
00474   if (argc == 0) {
00475     IConsoleHelp("Ban a client from a network game. Usage: 'ban <ip | client-id>'");
00476     IConsoleHelp("For client-id's, see the command 'clients'");
00477     IConsoleHelp("If the client is no longer online, you can still ban his/her IP");
00478     return true;
00479   }
00480 
00481   if (argc != 2) return false;
00482 
00483   return ConKickOrBan(argv[1], true);
00484 }
00485 
00486 DEF_CONSOLE_CMD(ConUnBan)
00487 {
00488 
00489   if (argc == 0) {
00490     IConsoleHelp("Unban a client from a network game. Usage: 'unban <ip | client-id>'");
00491     IConsoleHelp("For a list of banned IP's, see the command 'banlist'");
00492     return true;
00493   }
00494 
00495   if (argc != 2) return false;
00496 
00497   uint index = (strchr(argv[1], '.') == NULL) ? atoi(argv[1]) : 0;
00498   index--;
00499   uint i = 0;
00500 
00501   for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
00502     if (strcmp(_network_ban_list[i], argv[1]) == 0 || index == i) {
00503       free(_network_ban_list[i]);
00504       _network_ban_list.Erase(iter);
00505       IConsolePrint(CC_DEFAULT, "IP unbanned.");
00506       return true;
00507     }
00508   }
00509 
00510   IConsolePrint(CC_DEFAULT, "IP not in ban-list.");
00511   return true;
00512 }
00513 
00514 DEF_CONSOLE_CMD(ConBanList)
00515 {
00516   if (argc == 0) {
00517     IConsoleHelp("List the IP's of banned clients: Usage 'banlist'");
00518     return true;
00519   }
00520 
00521   IConsolePrint(CC_DEFAULT, "Banlist: ");
00522 
00523   uint i = 1;
00524   for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
00525     IConsolePrintF(CC_DEFAULT, "  %d) %s", i, *iter);
00526   }
00527 
00528   return true;
00529 }
00530 
00531 DEF_CONSOLE_CMD(ConPauseGame)
00532 {
00533   if (argc == 0) {
00534     IConsoleHelp("Pause a network game. Usage: 'pause'");
00535     return true;
00536   }
00537 
00538   if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
00539     DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
00540     if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused.");
00541   } else {
00542     IConsolePrint(CC_DEFAULT, "Game is already paused.");
00543   }
00544 
00545   return true;
00546 }
00547 
00548 DEF_CONSOLE_CMD(ConUnPauseGame)
00549 {
00550   if (argc == 0) {
00551     IConsoleHelp("Unpause a network game. Usage: 'unpause'");
00552     return true;
00553   }
00554 
00555   if ((_pause_mode & PM_PAUSED_NORMAL) != PM_UNPAUSED) {
00556     DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
00557     if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused.");
00558   } else if ((_pause_mode & PM_PAUSED_ERROR) != PM_UNPAUSED) {
00559     IConsolePrint(CC_DEFAULT, "Game is in error state and cannot be unpaused via console.");
00560   } else if (_pause_mode != PM_UNPAUSED) {
00561     IConsolePrint(CC_DEFAULT, "Game cannot be unpaused manually; disable pause_on_join/min_active_clients.");
00562   } else {
00563     IConsolePrint(CC_DEFAULT, "Game is already unpaused.");
00564   }
00565 
00566   return true;
00567 }
00568 
00569 DEF_CONSOLE_CMD(ConRcon)
00570 {
00571   if (argc == 0) {
00572     IConsoleHelp("Remote control the server from another client. Usage: 'rcon <password> <command>'");
00573     IConsoleHelp("Remember to enclose the command in quotes, otherwise only the first parameter is sent");
00574     return true;
00575   }
00576 
00577   if (argc < 3) return false;
00578 
00579   if (_network_server) {
00580     IConsoleCmdExec(argv[2]);
00581   } else {
00582     NetworkClientSendRcon(argv[1], argv[2]);
00583   }
00584   return true;
00585 }
00586 
00587 DEF_CONSOLE_CMD(ConStatus)
00588 {
00589   if (argc == 0) {
00590     IConsoleHelp("List the status of all clients connected to the server. Usage 'status'");
00591     return true;
00592   }
00593 
00594   NetworkServerShowStatusToConsole();
00595   return true;
00596 }
00597 
00598 DEF_CONSOLE_CMD(ConServerInfo)
00599 {
00600   if (argc == 0) {
00601     IConsoleHelp("List current and maximum client/company limits. Usage 'server_info'");
00602     IConsoleHelp("You can change these values by modifying settings 'network.max_clients', 'network.max_companies' and 'network.max_spectators'");
00603     return true;
00604   }
00605 
00606   IConsolePrintF(CC_DEFAULT, "Current/maximum clients:    %2d/%2d", _network_game_info.clients_on, _settings_client.network.max_clients);
00607   IConsolePrintF(CC_DEFAULT, "Current/maximum companies:  %2d/%2d", (int)Company::GetNumItems(), _settings_client.network.max_companies);
00608   IConsolePrintF(CC_DEFAULT, "Current/maximum spectators: %2d/%2d", NetworkSpectatorCount(), _settings_client.network.max_spectators);
00609 
00610   return true;
00611 }
00612 
00613 DEF_CONSOLE_CMD(ConClientNickChange)
00614 {
00615   if (argc != 3) {
00616     IConsoleHelp("Change the nickname of a connected client. Usage: 'client_name <client-id> <new-name>'");
00617     IConsoleHelp("For client-id's, see the command 'clients'");
00618     return true;
00619   }
00620 
00621   ClientID client_id = (ClientID)atoi(argv[1]);
00622 
00623   if (client_id == CLIENT_ID_SERVER) {
00624     IConsoleError("Please use the command 'name' to change your own name!");
00625     return true;
00626   }
00627 
00628   if (NetworkFindClientInfoFromClientID(client_id) == NULL) {
00629     IConsoleError("Invalid client");
00630     return true;
00631   }
00632 
00633   if (!NetworkServerChangeClientName(client_id, argv[2])) {
00634     IConsoleError("Cannot give a client a duplicate name");
00635   }
00636 
00637   return true;
00638 }
00639 
00640 DEF_CONSOLE_CMD(ConJoinCompany)
00641 {
00642   if (argc < 2) {
00643     IConsoleHelp("Request joining another company. Usage: join <company-id> [<password>]");
00644     IConsoleHelp("For valid company-id see company list, use 255 for spectator");
00645     return true;
00646   }
00647 
00648   CompanyID company_id = (CompanyID)(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));
00649 
00650   /* Check we have a valid company id! */
00651   if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
00652     IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
00653     return true;
00654   }
00655 
00656   if (NetworkFindClientInfoFromClientID(_network_own_client_id)->client_playas == company_id) {
00657     IConsoleError("You are already there!");
00658     return true;
00659   }
00660 
00661   if (company_id == COMPANY_SPECTATOR && NetworkMaxSpectatorsReached()) {
00662     IConsoleError("Cannot join spectators, maximum number of spectators reached.");
00663     return true;
00664   }
00665 
00666   if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
00667     IConsoleError("Cannot join AI company.");
00668     return true;
00669   }
00670 
00671   /* Check if the company requires a password */
00672   if (NetworkCompanyIsPassworded(company_id) && argc < 3) {
00673     IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1);
00674     return true;
00675   }
00676 
00677   /* non-dedicated server may just do the move! */
00678   if (_network_server) {
00679     NetworkServerDoMove(CLIENT_ID_SERVER, company_id);
00680   } else {
00681     NetworkClientRequestMove(company_id, NetworkCompanyIsPassworded(company_id) ? argv[2] : "");
00682   }
00683 
00684   return true;
00685 }
00686 
00687 DEF_CONSOLE_CMD(ConMoveClient)
00688 {
00689   if (argc < 3) {
00690     IConsoleHelp("Move a client to another company. Usage: move <client-id> <company-id>");
00691     IConsoleHelp("For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators");
00692     return true;
00693   }
00694 
00695   const NetworkClientInfo *ci = NetworkFindClientInfoFromClientID((ClientID)atoi(argv[1]));
00696   CompanyID company_id = (CompanyID)(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
00697 
00698   /* check the client exists */
00699   if (ci == NULL) {
00700     IConsoleError("Invalid client-id, check the command 'clients' for valid client-id's.");
00701     return true;
00702   }
00703 
00704   if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
00705     IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
00706     return true;
00707   }
00708 
00709   if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
00710     IConsoleError("You cannot move clients to AI companies.");
00711     return true;
00712   }
00713 
00714   if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) {
00715     IConsoleError("Silly boy, you cannot move the server!");
00716     return true;
00717   }
00718 
00719   if (ci->client_playas == company_id) {
00720     IConsoleError("You cannot move someone to where he/she already is!");
00721     return true;
00722   }
00723 
00724   /* we are the server, so force the update */
00725   NetworkServerDoMove(ci->client_id, company_id);
00726 
00727   return true;
00728 }
00729 
00730 DEF_CONSOLE_CMD(ConResetCompany)
00731 {
00732   if (argc == 0) {
00733     IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'");
00734     IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
00735     return true;
00736   }
00737 
00738   if (argc != 2) return false;
00739 
00740   CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
00741 
00742   /* Check valid range */
00743   if (!Company::IsValidID(index)) {
00744     IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
00745     return true;
00746   }
00747 
00748   if (!Company::IsHumanID(index)) {
00749     IConsoleError("Company is owned by an AI.");
00750     return true;
00751   }
00752 
00753   if (NetworkCompanyHasClients(index)) {
00754     IConsoleError("Cannot remove company: a client is connected to that company.");
00755     return false;
00756   }
00757   const NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
00758   if (ci->client_playas == index) {
00759     IConsoleError("Cannot remove company: the server is connected to that company.");
00760     return true;
00761   }
00762 
00763   /* It is safe to remove this company */
00764   DoCommandP(0, 2 | index << 16, 0, CMD_COMPANY_CTRL);
00765   IConsolePrint(CC_DEFAULT, "Company deleted.");
00766 
00767   return true;
00768 }
00769 
00770 DEF_CONSOLE_CMD(ConNetworkClients)
00771 {
00772   if (argc == 0) {
00773     IConsoleHelp("Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'");
00774     return true;
00775   }
00776 
00777   NetworkPrintClients();
00778 
00779   return true;
00780 }
00781 
00782 DEF_CONSOLE_CMD(ConNetworkReconnect)
00783 {
00784   if (argc == 0) {
00785     IConsoleHelp("Reconnect to server to which you were connected last time. Usage: 'reconnect [<company>]'");
00786     IConsoleHelp("Company 255 is spectator (default, if not specified), 0 means creating new company.");
00787     IConsoleHelp("All others are a certain company with Company 1 being #1");
00788     return true;
00789   }
00790 
00791   CompanyID playas = (argc >= 2) ? (CompanyID)atoi(argv[1]) : COMPANY_SPECTATOR;
00792   switch (playas) {
00793     case 0: playas = COMPANY_NEW_COMPANY; break;
00794     case COMPANY_SPECTATOR: /* nothing to do */ break;
00795     default:
00796       /* From a user pov 0 is a new company, internally it's different and all
00797        * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
00798       playas--;
00799       if (playas < COMPANY_FIRST || playas >= MAX_COMPANIES) return false;
00800       break;
00801   }
00802 
00803   if (StrEmpty(_settings_client.network.last_host)) {
00804     IConsolePrint(CC_DEFAULT, "No server for reconnecting.");
00805     return true;
00806   }
00807 
00808   /* Don't resolve the address first, just print it directly as it comes from the config file. */
00809   IConsolePrintF(CC_DEFAULT, "Reconnecting to %s:%d...", _settings_client.network.last_host, _settings_client.network.last_port);
00810 
00811   NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), playas);
00812   return true;
00813 }
00814 
00815 DEF_CONSOLE_CMD(ConNetworkConnect)
00816 {
00817   if (argc == 0) {
00818     IConsoleHelp("Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'");
00819     IConsoleHelp("IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'");
00820     IConsoleHelp("Company #255 is spectator all others are a certain company with Company 1 being #1");
00821     return true;
00822   }
00823 
00824   if (argc < 2) return false;
00825   if (_networking) NetworkDisconnect(); // we are in network-mode, first close it!
00826 
00827   const char *port = NULL;
00828   const char *company = NULL;
00829   char *ip = argv[1];
00830   /* Default settings: default port and new company */
00831   uint16 rport = NETWORK_DEFAULT_PORT;
00832   CompanyID join_as = COMPANY_NEW_COMPANY;
00833 
00834   ParseConnectionString(&company, &port, ip);
00835 
00836   IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip);
00837   if (company != NULL) {
00838     join_as = (CompanyID)atoi(company);
00839     IConsolePrintF(CC_DEFAULT, "    company-no: %d", join_as);
00840 
00841     /* From a user pov 0 is a new company, internally it's different and all
00842      * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
00843     if (join_as != COMPANY_SPECTATOR) {
00844       if (join_as > MAX_COMPANIES) return false;
00845       join_as--;
00846     }
00847   }
00848   if (port != NULL) {
00849     rport = atoi(port);
00850     IConsolePrintF(CC_DEFAULT, "    port: %s", port);
00851   }
00852 
00853   NetworkClientConnectGame(NetworkAddress(ip, rport), join_as);
00854 
00855   return true;
00856 }
00857 
00858 #endif /* ENABLE_NETWORK */
00859 
00860 /*********************************
00861  *  script file console commands
00862  *********************************/
00863 
00864 DEF_CONSOLE_CMD(ConExec)
00865 {
00866   if (argc == 0) {
00867     IConsoleHelp("Execute a local script file. Usage: 'exec <script> <?>'");
00868     return true;
00869   }
00870 
00871   if (argc < 2) return false;
00872 
00873   FILE *script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
00874 
00875   if (script_file == NULL) {
00876     if (argc == 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
00877     return true;
00878   }
00879 
00880   _script_running = true;
00881 
00882   char cmdline[ICON_CMDLN_SIZE];
00883   while (_script_running && fgets(cmdline, sizeof(cmdline), script_file) != NULL) {
00884     /* Remove newline characters from the executing script */
00885     for (char *cmdptr = cmdline; *cmdptr != '\0'; cmdptr++) {
00886       if (*cmdptr == '\n' || *cmdptr == '\r') {
00887         *cmdptr = '\0';
00888         break;
00889       }
00890     }
00891     IConsoleCmdExec(cmdline);
00892   }
00893 
00894   if (ferror(script_file)) {
00895     IConsoleError("Encountered errror while trying to read from script file");
00896   }
00897 
00898   _script_running = false;
00899   FioFCloseFile(script_file);
00900   return true;
00901 }
00902 
00903 DEF_CONSOLE_CMD(ConReturn)
00904 {
00905   if (argc == 0) {
00906     IConsoleHelp("Stop executing a running script. Usage: 'return'");
00907     return true;
00908   }
00909 
00910   _script_running = false;
00911   return true;
00912 }
00913 
00914 /*****************************
00915  *  default console commands
00916  ******************************/
00917 extern bool CloseConsoleLogIfActive();
00918 
00919 DEF_CONSOLE_CMD(ConScript)
00920 {
00921   extern FILE *_iconsole_output_file;
00922 
00923   if (argc == 0) {
00924     IConsoleHelp("Start or stop logging console output to a file. Usage: 'script <filename>'");
00925     IConsoleHelp("If filename is omitted, a running log is stopped if it is active");
00926     return true;
00927   }
00928 
00929   if (!CloseConsoleLogIfActive()) {
00930     if (argc < 2) return false;
00931 
00932     IConsolePrintF(CC_DEFAULT, "file output started to: %s", argv[1]);
00933     _iconsole_output_file = fopen(argv[1], "ab");
00934     if (_iconsole_output_file == NULL) IConsoleError("could not open file");
00935   }
00936 
00937   return true;
00938 }
00939 
00940 
00941 DEF_CONSOLE_CMD(ConEcho)
00942 {
00943   if (argc == 0) {
00944     IConsoleHelp("Print back the first argument to the console. Usage: 'echo <arg>'");
00945     return true;
00946   }
00947 
00948   if (argc < 2) return false;
00949   IConsolePrint(CC_DEFAULT, argv[1]);
00950   return true;
00951 }
00952 
00953 DEF_CONSOLE_CMD(ConEchoC)
00954 {
00955   if (argc == 0) {
00956     IConsoleHelp("Print back the first argument to the console in a given colour. Usage: 'echoc <colour> <arg2>'");
00957     return true;
00958   }
00959 
00960   if (argc < 3) return false;
00961   IConsolePrint((TextColour)Clamp(atoi(argv[1]), TC_BEGIN, TC_END - 1), argv[2]);
00962   return true;
00963 }
00964 
00965 DEF_CONSOLE_CMD(ConNewGame)
00966 {
00967   if (argc == 0) {
00968     IConsoleHelp("Start a new game. Usage: 'newgame [seed]'");
00969     IConsoleHelp("The server can force a new game using 'newgame'; any client joined will rejoin after the server is done generating the new game.");
00970     return true;
00971   }
00972 
00973   StartNewGameWithoutGUI((argc == 2) ? strtoul(argv[1], NULL, 10) : GENERATE_NEW_SEED);
00974   return true;
00975 }
00976 
00977 extern void SwitchToMode(SwitchMode new_mode);
00978 
00979 DEF_CONSOLE_CMD(ConRestart)
00980 {
00981   if (argc == 0) {
00982     IConsoleHelp("Restart game. Usage: 'restart'");
00983     IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
00984     IConsoleHelp("However:");
00985     IConsoleHelp(" * restarting games started in another version might create another map due to difference in map generation");
00986     IConsoleHelp(" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame");
00987     return true;
00988   }
00989 
00990   /* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
00991   _settings_game.game_creation.map_x = MapLogX();
00992   _settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
00993   _switch_mode = SM_RESTARTGAME;
00994   return true;
00995 }
00996 
00997 #ifdef ENABLE_AI
00998 
01003 static void PrintLineByLine(char *buf)
01004 {
01005   char *p = buf;
01006   /* Print output line by line */
01007   for (char *p2 = buf; *p2 != '\0'; p2++) {
01008     if (*p2 == '\n') {
01009       *p2 = '\0';
01010       IConsolePrintF(CC_DEFAULT, "%s", p);
01011       p = p2 + 1;
01012     }
01013   }
01014 }
01015 
01016 DEF_CONSOLE_CMD(ConListAILibs)
01017 {
01018   char buf[4096];
01019   AI::GetConsoleLibraryList(buf, lastof(buf));
01020 
01021   PrintLineByLine(buf);
01022 
01023   return true;
01024 }
01025 
01026 DEF_CONSOLE_CMD(ConListAI)
01027 {
01028   char buf[4096];
01029   AI::GetConsoleList(buf, lastof(buf));
01030 
01031   PrintLineByLine(buf);
01032 
01033   return true;
01034 }
01035 
01036 DEF_CONSOLE_CMD(ConStartAI)
01037 {
01038   if (argc == 0 || argc > 3) {
01039     IConsoleHelp("Start a new AI. Usage: 'start_ai [<AI>] [<settings>]'");
01040     IConsoleHelp("Start a new AI. If <AI> is given, it starts that specific AI (if found).");
01041     IConsoleHelp("If <settings> is given, it is parsed and the AI settings are set to that.");
01042     return true;
01043   }
01044 
01045   if (_game_mode != GM_NORMAL) {
01046     IConsoleWarning("AIs can only be managed in a game.");
01047     return true;
01048   }
01049 
01050   if (Company::GetNumItems() == CompanyPool::MAX_SIZE) {
01051     IConsoleWarning("Can't start a new AI (no more free slots).");
01052     return true;
01053   }
01054   if (_networking && !_network_server) {
01055     IConsoleWarning("Only the server can start a new AI.");
01056     return true;
01057   }
01058   if (_networking && !_settings_game.ai.ai_in_multiplayer) {
01059     IConsoleWarning("AIs are not allowed in multiplayer by configuration.");
01060     IConsoleWarning("Switch AI -> AI in multiplayer to True.");
01061     return true;
01062   }
01063   if (!AI::CanStartNew()) {
01064     IConsoleWarning("Can't start a new AI.");
01065     return true;
01066   }
01067 
01068   int n = 0;
01069   Company *c;
01070   /* Find the next free slot */
01071   FOR_ALL_COMPANIES(c) {
01072     if (c->index != n) break;
01073     n++;
01074   }
01075 
01076   AIConfig *config = AIConfig::GetConfig((CompanyID)n);
01077   if (argc >= 2) {
01078     config->ChangeAI(argv[1], -1, true);
01079     if (!config->HasAI()) {
01080       IConsoleWarning("Failed to load the specified AI");
01081       return true;
01082     }
01083     if (argc == 3) {
01084       config->StringToSettings(argv[2]);
01085     }
01086   }
01087 
01088   /* Start a new AI company */
01089   DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
01090 
01091   return true;
01092 }
01093 
01094 DEF_CONSOLE_CMD(ConReloadAI)
01095 {
01096   if (argc != 2) {
01097     IConsoleHelp("Reload an AI. Usage: 'reload_ai <company-id>'");
01098     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.");
01099     return true;
01100   }
01101 
01102   if (_game_mode != GM_NORMAL) {
01103     IConsoleWarning("AIs can only be managed in a game.");
01104     return true;
01105   }
01106 
01107   if (_networking && !_network_server) {
01108     IConsoleWarning("Only the server can reload an AI.");
01109     return true;
01110   }
01111 
01112   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01113   if (!Company::IsValidID(company_id)) {
01114     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01115     return true;
01116   }
01117 
01118   if (Company::IsHumanID(company_id)) {
01119     IConsoleWarning("Company is not controlled by an AI.");
01120     return true;
01121   }
01122 
01123   /* First kill the company of the AI, then start a new one. This should start the current AI again */
01124   DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
01125   DoCommandP(0, 1 | company_id << 16, 0, CMD_COMPANY_CTRL);
01126   IConsolePrint(CC_DEFAULT, "AI reloaded.");
01127 
01128   return true;
01129 }
01130 
01131 DEF_CONSOLE_CMD(ConStopAI)
01132 {
01133   if (argc != 2) {
01134     IConsoleHelp("Stop an AI. Usage: 'stop_ai <company-id>'");
01135     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.");
01136     return true;
01137   }
01138 
01139   if (_game_mode != GM_NORMAL) {
01140     IConsoleWarning("AIs can only be managed in a game.");
01141     return true;
01142   }
01143 
01144   if (_networking && !_network_server) {
01145     IConsoleWarning("Only the server can stop an AI.");
01146     return true;
01147   }
01148 
01149   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01150   if (!Company::IsValidID(company_id)) {
01151     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01152     return true;
01153   }
01154 
01155   if (Company::IsHumanID(company_id)) {
01156     IConsoleWarning("Company is not controlled by an AI.");
01157     return true;
01158   }
01159 
01160   /* Now kill the company of the AI. */
01161   DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
01162   IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
01163 
01164   return true;
01165 }
01166 
01167 DEF_CONSOLE_CMD(ConRescanAI)
01168 {
01169   if (argc == 0) {
01170     IConsoleHelp("Rescan the AI dir for scripts. Usage: 'rescan_ai'");
01171     return true;
01172   }
01173 
01174   if (_networking && !_network_server) {
01175     IConsoleWarning("Only the server can rescan the AI dir for scripts.");
01176     return true;
01177   }
01178 
01179   TarScanner::DoScan();
01180   AI::Rescan();
01181   InvalidateWindowData(WC_AI_LIST, 0, 1);
01182   SetWindowDirty(WC_AI_SETTINGS, 0);
01183 
01184   return true;
01185 }
01186 #endif /* ENABLE_AI */
01187 
01188 DEF_CONSOLE_CMD(ConRescanNewGRF)
01189 {
01190   if (argc == 0) {
01191     IConsoleHelp("Rescan the data dir for NewGRFs. Usage: 'rescan_newgrf'");
01192     return true;
01193   }
01194 
01195   TarScanner::DoScan();
01196   ScanNewGRFFiles();
01197   InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
01198 
01199   return true;
01200 }
01201 
01202 DEF_CONSOLE_CMD(ConGetSeed)
01203 {
01204   if (argc == 0) {
01205     IConsoleHelp("Returns the seed used to create this game. Usage: 'getseed'");
01206     IConsoleHelp("The seed can be used to reproduce the exact same map as the game started with.");
01207     return true;
01208   }
01209 
01210   IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _settings_game.game_creation.generation_seed);
01211   return true;
01212 }
01213 
01214 DEF_CONSOLE_CMD(ConGetDate)
01215 {
01216   if (argc == 0) {
01217     IConsoleHelp("Returns the current date (day-month-year) of the game. Usage: 'getdate'");
01218     return true;
01219   }
01220 
01221   YearMonthDay ymd;
01222   ConvertDateToYMD(_date, &ymd);
01223   IConsolePrintF(CC_DEFAULT, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
01224   return true;
01225 }
01226 
01227 
01228 DEF_CONSOLE_CMD(ConAlias)
01229 {
01230   IConsoleAlias *alias;
01231 
01232   if (argc == 0) {
01233     IConsoleHelp("Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'");
01234     return true;
01235   }
01236 
01237   if (argc < 3) return false;
01238 
01239   alias = IConsoleAliasGet(argv[1]);
01240   if (alias == NULL) {
01241     IConsoleAliasRegister(argv[1], argv[2]);
01242   } else {
01243     free(alias->cmdline);
01244     alias->cmdline = strdup(argv[2]);
01245   }
01246   return true;
01247 }
01248 
01249 DEF_CONSOLE_CMD(ConScreenShot)
01250 {
01251   if (argc == 0) {
01252     IConsoleHelp("Create a screenshot of the game. Usage: 'screenshot [big | giant | no_con] [file name]'");
01253     IConsoleHelp("'big' makes a zoomed-in screenshot of the visible area, 'giant' makes a screenshot of the "
01254         "whole map, 'no_con' hides the console to create the screenshot. 'big' or 'giant' "
01255         "screenshots are always drawn without console");
01256     return true;
01257   }
01258 
01259   if (argc > 3) return false;
01260 
01261   ScreenshotType type = SC_VIEWPORT;
01262   const char *name = NULL;
01263 
01264   if (argc > 1) {
01265     if (strcmp(argv[1], "big") == 0) {
01266       /* screenshot big [filename] */
01267       type = SC_ZOOMEDIN;
01268       if (argc > 2) name = argv[2];
01269     } else if (strcmp(argv[1], "giant") == 0) {
01270       /* screenshot giant [filename] */
01271       type = SC_WORLD;
01272       if (argc > 2) name = argv[2];
01273     } else if (strcmp(argv[1], "no_con") == 0) {
01274       /* screenshot no_con [filename] */
01275       IConsoleClose();
01276       if (argc > 2) name = argv[2];
01277     } else if (argc == 2) {
01278       /* screenshot filename */
01279       name = argv[1];
01280     } else {
01281       /* screenshot argv[1] argv[2] - invalid */
01282       return false;
01283     }
01284   }
01285 
01286   MakeScreenshot(type, name);
01287   return true;
01288 }
01289 
01290 DEF_CONSOLE_CMD(ConInfoCmd)
01291 {
01292   if (argc == 0) {
01293     IConsoleHelp("Print out debugging information about a command. Usage: 'info_cmd <cmd>'");
01294     return true;
01295   }
01296 
01297   if (argc < 2) return false;
01298 
01299   const IConsoleCmd *cmd = IConsoleCmdGet(argv[1]);
01300   if (cmd == NULL) {
01301     IConsoleError("the given command was not found");
01302     return true;
01303   }
01304 
01305   IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
01306   IConsolePrintF(CC_DEFAULT, "command proc: %p", cmd->proc);
01307 
01308   if (cmd->hook != NULL) IConsoleWarning("command is hooked");
01309 
01310   return true;
01311 }
01312 
01313 DEF_CONSOLE_CMD(ConDebugLevel)
01314 {
01315   if (argc == 0) {
01316     IConsoleHelp("Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'");
01317     IConsoleHelp("Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'s");
01318     return true;
01319   }
01320 
01321   if (argc > 2) return false;
01322 
01323   if (argc == 1) {
01324     IConsolePrintF(CC_DEFAULT, "Current debug-level: '%s'", GetDebugString());
01325   } else {
01326     SetDebugString(argv[1]);
01327   }
01328 
01329   return true;
01330 }
01331 
01332 DEF_CONSOLE_CMD(ConExit)
01333 {
01334   if (argc == 0) {
01335     IConsoleHelp("Exit the game. Usage: 'exit'");
01336     return true;
01337   }
01338 
01339   if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave();
01340 
01341   _exit_game = true;
01342   return true;
01343 }
01344 
01345 DEF_CONSOLE_CMD(ConPart)
01346 {
01347   if (argc == 0) {
01348     IConsoleHelp("Leave the currently joined/running game (only ingame). Usage: 'part'");
01349     return true;
01350   }
01351 
01352   if (_game_mode != GM_NORMAL) return false;
01353 
01354   _switch_mode = SM_MENU;
01355   return true;
01356 }
01357 
01358 DEF_CONSOLE_CMD(ConHelp)
01359 {
01360   if (argc == 2) {
01361     const IConsoleCmd *cmd;
01362     const IConsoleAlias *alias;
01363 
01364     RemoveUnderscores(argv[1]);
01365     cmd = IConsoleCmdGet(argv[1]);
01366     if (cmd != NULL) {
01367       cmd->proc(0, NULL);
01368       return true;
01369     }
01370 
01371     alias = IConsoleAliasGet(argv[1]);
01372     if (alias != NULL) {
01373       cmd = IConsoleCmdGet(alias->cmdline);
01374       if (cmd != NULL) {
01375         cmd->proc(0, NULL);
01376         return true;
01377       }
01378       IConsolePrintF(CC_ERROR, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
01379       return true;
01380     }
01381 
01382     IConsoleError("command not found");
01383     return true;
01384   }
01385 
01386   IConsolePrint(CC_WARNING, " ---- OpenTTD Console Help ---- ");
01387   IConsolePrint(CC_DEFAULT, " - commands: [command to list all commands: list_cmds]");
01388   IConsolePrint(CC_DEFAULT, " call commands with '<command> <arg2> <arg3>...'");
01389   IConsolePrint(CC_DEFAULT, " - to assign strings, or use them as arguments, enclose it within quotes");
01390   IConsolePrint(CC_DEFAULT, " like this: '<command> \"string argument with spaces\"'");
01391   IConsolePrint(CC_DEFAULT, " - use 'help <command>' to get specific information");
01392   IConsolePrint(CC_DEFAULT, " - scroll console output with shift + (up | down) | (pageup | pagedown))");
01393   IConsolePrint(CC_DEFAULT, " - scroll console input history with the up | down arrows");
01394   IConsolePrint(CC_DEFAULT, "");
01395   return true;
01396 }
01397 
01398 DEF_CONSOLE_CMD(ConListCommands)
01399 {
01400   if (argc == 0) {
01401     IConsoleHelp("List all registered commands. Usage: 'list_cmds [<pre-filter>]'");
01402     return true;
01403   }
01404 
01405   for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) {
01406     if (argv[1] == NULL || strstr(cmd->name, argv[1]) != NULL) {
01407       if (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
01408     }
01409   }
01410 
01411   return true;
01412 }
01413 
01414 DEF_CONSOLE_CMD(ConListAliases)
01415 {
01416   if (argc == 0) {
01417     IConsoleHelp("List all registered aliases. Usage: 'list_aliases [<pre-filter>]'");
01418     return true;
01419   }
01420 
01421   for (const IConsoleAlias *alias = _iconsole_aliases; alias != NULL; alias = alias->next) {
01422     if (argv[1] == NULL || strstr(alias->name, argv[1]) != NULL) {
01423       IConsolePrintF(CC_DEFAULT, "%s => %s", alias->name, alias->cmdline);
01424     }
01425   }
01426 
01427   return true;
01428 }
01429 
01430 #ifdef ENABLE_NETWORK
01431 
01432 DEF_CONSOLE_CMD(ConSay)
01433 {
01434   if (argc == 0) {
01435     IConsoleHelp("Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
01436     return true;
01437   }
01438 
01439   if (argc != 2) return false;
01440 
01441   if (!_network_server) {
01442     NetworkClientSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
01443   } else {
01444     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01445     NetworkServerSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], CLIENT_ID_SERVER, from_admin);
01446   }
01447 
01448   return true;
01449 }
01450 
01451 DEF_CONSOLE_CMD(ConCompanies)
01452 {
01453   if (argc == 0) {
01454     IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
01455     return true;
01456   }
01457   NetworkCompanyStats company_stats[MAX_COMPANIES];
01458   NetworkPopulateCompanyStats(company_stats);
01459 
01460   Company *c;
01461   FOR_ALL_COMPANIES(c) {
01462     /* Grab the company name */
01463     char company_name[NETWORK_COMPANY_NAME_LENGTH];
01464     SetDParam(0, c->index);
01465     GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
01466 
01467     char buffer[512];
01468     const NetworkCompanyStats *stats = &company_stats[c->index];
01469 
01470     GetString(buffer, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(buffer));
01471     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) %sprotected",
01472       c->index + 1, buffer, company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
01473       /* trains      */ stats->num_vehicle[0],
01474       /* lorry + bus */ stats->num_vehicle[1] + stats->num_vehicle[2],
01475       /* planes      */ stats->num_vehicle[3],
01476       /* ships       */ stats->num_vehicle[4],
01477       /* protected   */ StrEmpty(_network_company_states[c->index].password) ? "un" : "");
01478   }
01479 
01480   return true;
01481 }
01482 
01483 DEF_CONSOLE_CMD(ConSayCompany)
01484 {
01485   if (argc == 0) {
01486     IConsoleHelp("Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
01487     IConsoleHelp("CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
01488     return true;
01489   }
01490 
01491   if (argc != 3) return false;
01492 
01493   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01494   if (!Company::IsValidID(company_id)) {
01495     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01496     return true;
01497   }
01498 
01499   if (!_network_server) {
01500     NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2]);
01501   } else {
01502     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01503     NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2], CLIENT_ID_SERVER, from_admin);
01504   }
01505 
01506   return true;
01507 }
01508 
01509 DEF_CONSOLE_CMD(ConSayClient)
01510 {
01511   if (argc == 0) {
01512     IConsoleHelp("Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
01513     IConsoleHelp("For client-id's, see the command 'clients'");
01514     return true;
01515   }
01516 
01517   if (argc != 3) return false;
01518 
01519   if (!_network_server) {
01520     NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
01521   } else {
01522     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01523     NetworkServerSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], CLIENT_ID_SERVER, from_admin);
01524   }
01525 
01526   return true;
01527 }
01528 
01529 DEF_CONSOLE_CMD(ConCompanyPassword)
01530 {
01531   if (argc == 0) {
01532     IConsoleHelp("Change the password of your company. Usage: 'company_pw \"<password>\"'");
01533     IConsoleHelp("Use \"*\" to disable the password.");
01534     return true;
01535   }
01536 
01537   if (argc != 2) return false;
01538 
01539   if (!Company::IsValidID(_local_company)) {
01540     IConsoleError("You have to own a company to make use of this command.");
01541     return false;
01542   }
01543 
01544   const char *password = NetworkChangeCompanyPassword(argv[1]);
01545 
01546   if (StrEmpty(password)) {
01547     IConsolePrintF(CC_WARNING, "Company password cleared");
01548   } else {
01549     IConsolePrintF(CC_WARNING, "Company password changed to: %s", password);
01550   }
01551 
01552   return true;
01553 }
01554 
01555 /* Content downloading only is available with ZLIB */
01556 #if defined(WITH_ZLIB)
01557 #include "network/network_content.h"
01558 
01560 static ContentType StringToContentType(const char *str)
01561 {
01562   static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
01563   for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
01564     if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
01565   }
01566   return CONTENT_TYPE_END;
01567 }
01568 
01570 struct ConsoleContentCallback : public ContentCallback {
01571   void OnConnect(bool success)
01572   {
01573     IConsolePrintF(CC_DEFAULT, "Content server connection %s", success ? "established" : "failed");
01574   }
01575 
01576   void OnDisconnect()
01577   {
01578     IConsolePrintF(CC_DEFAULT, "Content server connection closed");
01579   }
01580 
01581   void OnDownloadComplete(ContentID cid)
01582   {
01583     IConsolePrintF(CC_DEFAULT, "Completed download of %d", cid);
01584   }
01585 };
01586 
01587 DEF_CONSOLE_CMD(ConContent)
01588 {
01589   static ContentCallback *cb = NULL;
01590   if (cb == NULL) {
01591     cb = new ConsoleContentCallback();
01592     _network_content_client.AddCallback(cb);
01593   }
01594 
01595   if (argc <= 1) {
01596     IConsoleHelp("Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state|download'");
01597     IConsoleHelp("  update: get a new list of downloadable content; must be run first");
01598     IConsoleHelp("  upgrade: select all items that are upgrades");
01599     IConsoleHelp("  select: select a specific item given by its id or 'all' to select all");
01600     IConsoleHelp("  unselect: unselect a specific item given by its id or 'all' to unselect all");
01601     IConsoleHelp("  state: show the download/select state of all downloadable content");
01602     IConsoleHelp("  download: download all content you've selected");
01603     return true;
01604   }
01605 
01606   if (strcasecmp(argv[1], "update") == 0) {
01607     _network_content_client.RequestContentList((argc > 2) ? StringToContentType(argv[2]) : CONTENT_TYPE_END);
01608     return true;
01609   }
01610 
01611   if (strcasecmp(argv[1], "upgrade") == 0) {
01612     _network_content_client.SelectUpgrade();
01613     return true;
01614   }
01615 
01616   if (strcasecmp(argv[1], "select") == 0) {
01617     if (argc <= 2) {
01618       IConsoleError("You must enter the id.");
01619       return false;
01620     }
01621     if (strcasecmp(argv[2], "all") == 0) {
01622       _network_content_client.SelectAll();
01623     } else {
01624       _network_content_client.Select((ContentID)atoi(argv[2]));
01625     }
01626     return true;
01627   }
01628 
01629   if (strcasecmp(argv[1], "unselect") == 0) {
01630     if (argc <= 2) {
01631       IConsoleError("You must enter the id.");
01632       return false;
01633     }
01634     if (strcasecmp(argv[2], "all") == 0) {
01635       _network_content_client.UnselectAll();
01636     } else {
01637       _network_content_client.Unselect((ContentID)atoi(argv[2]));
01638     }
01639     return true;
01640   }
01641 
01642   if (strcasecmp(argv[1], "state") == 0) {
01643     IConsolePrintF(CC_WHITE, "id, type, state, name");
01644     for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
01645       static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" };
01646       assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
01647       static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
01648       static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
01649 
01650       const ContentInfo *ci = *iter;
01651       IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
01652     }
01653     return true;
01654   }
01655 
01656   if (strcasecmp(argv[1], "download") == 0) {
01657     uint files;
01658     uint bytes;
01659     _network_content_client.DownloadSelectedContent(files, bytes);
01660     IConsolePrintF(CC_DEFAULT, "Downloading %d file(s) (%d bytes)", files, bytes);
01661     return true;
01662   }
01663 
01664   return false;
01665 }
01666 #endif /* defined(WITH_ZLIB) */
01667 #endif /* ENABLE_NETWORK */
01668 
01669 DEF_CONSOLE_CMD(ConSetting)
01670 {
01671   if (argc == 0) {
01672     IConsoleHelp("Change setting for all clients. Usage: 'setting <name> [<value>]'");
01673     IConsoleHelp("Omitting <value> will print out the current value of the setting.");
01674     return true;
01675   }
01676 
01677   if (argc == 1 || argc > 3) return false;
01678 
01679   if (argc == 2) {
01680     IConsoleGetSetting(argv[1]);
01681   } else {
01682     IConsoleSetSetting(argv[1], argv[2]);
01683   }
01684 
01685   return true;
01686 }
01687 
01688 DEF_CONSOLE_CMD(ConSettingNewgame)
01689 {
01690   if (argc == 0) {
01691     IConsoleHelp("Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'");
01692     IConsoleHelp("Omitting <value> will print out the current value of the setting.");
01693     return true;
01694   }
01695 
01696   if (argc == 1 || argc > 3) return false;
01697 
01698   if (argc == 2) {
01699     IConsoleGetSetting(argv[1], true);
01700   } else {
01701     IConsoleSetSetting(argv[1], argv[2], true);
01702   }
01703 
01704   return true;
01705 }
01706 
01707 DEF_CONSOLE_CMD(ConListSettings)
01708 {
01709   if (argc == 0) {
01710     IConsoleHelp("List settings. Usage: 'list_settings [<pre-filter>]'");
01711     return true;
01712   }
01713 
01714   if (argc > 2) return false;
01715 
01716   IConsoleListSettings((argc == 2) ? argv[1] : NULL);
01717   return true;
01718 }
01719 
01720 DEF_CONSOLE_CMD(ConGamelogPrint)
01721 {
01722   GamelogPrintConsole();
01723   return true;
01724 }
01725 
01726 DEF_CONSOLE_CMD(ConNewGRFReload)
01727 {
01728   if (argc == 0) {
01729     IConsoleHelp("Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
01730     return true;
01731   }
01732 
01733   ReloadNewGRFData();
01734   return true;
01735 }
01736 
01737 #ifdef _DEBUG
01738 /******************
01739  *  debug commands
01740  ******************/
01741 
01742 static void IConsoleDebugLibRegister()
01743 {
01744   IConsoleCmdRegister("resettile",        ConResetTile);
01745   IConsoleCmdRegister("stopall",          ConStopAllVehicles);
01746   IConsoleAliasRegister("dbg_echo",       "echo %A; echo %B");
01747   IConsoleAliasRegister("dbg_echo2",      "echo %!");
01748 }
01749 #endif
01750 
01751 /*******************************
01752  * console command registration
01753  *******************************/
01754 
01755 void IConsoleStdLibRegister()
01756 {
01757   IConsoleCmdRegister("debug_level",  ConDebugLevel);
01758   IConsoleCmdRegister("echo",         ConEcho);
01759   IConsoleCmdRegister("echoc",        ConEchoC);
01760   IConsoleCmdRegister("exec",         ConExec);
01761   IConsoleCmdRegister("exit",         ConExit);
01762   IConsoleCmdRegister("part",         ConPart);
01763   IConsoleCmdRegister("help",         ConHelp);
01764   IConsoleCmdRegister("info_cmd",     ConInfoCmd);
01765   IConsoleCmdRegister("list_cmds",    ConListCommands);
01766   IConsoleCmdRegister("list_aliases", ConListAliases);
01767   IConsoleCmdRegister("newgame",      ConNewGame);
01768   IConsoleCmdRegister("restart",      ConRestart);
01769   IConsoleCmdRegister("getseed",      ConGetSeed);
01770   IConsoleCmdRegister("getdate",      ConGetDate);
01771   IConsoleCmdRegister("quit",         ConExit);
01772   IConsoleCmdRegister("resetengines", ConResetEngines, ConHookNoNetwork);
01773   IConsoleCmdRegister("return",       ConReturn);
01774   IConsoleCmdRegister("screenshot",   ConScreenShot);
01775   IConsoleCmdRegister("script",       ConScript);
01776   IConsoleCmdRegister("scrollto",     ConScrollToTile);
01777   IConsoleCmdRegister("alias",        ConAlias);
01778   IConsoleCmdRegister("load",         ConLoad);
01779   IConsoleCmdRegister("rm",           ConRemove);
01780   IConsoleCmdRegister("save",         ConSave);
01781   IConsoleCmdRegister("saveconfig",   ConSaveConfig);
01782   IConsoleCmdRegister("ls",           ConListFiles);
01783   IConsoleCmdRegister("cd",           ConChangeDirectory);
01784   IConsoleCmdRegister("pwd",          ConPrintWorkingDirectory);
01785   IConsoleCmdRegister("clear",        ConClearBuffer);
01786   IConsoleCmdRegister("setting",      ConSetting);
01787   IConsoleCmdRegister("setting_newgame", ConSettingNewgame);
01788   IConsoleCmdRegister("list_settings",ConListSettings);
01789   IConsoleCmdRegister("gamelog",      ConGamelogPrint);
01790   IConsoleCmdRegister("rescan_newgrf", ConRescanNewGRF);
01791 
01792   IConsoleAliasRegister("dir",          "ls");
01793   IConsoleAliasRegister("del",          "rm %+");
01794   IConsoleAliasRegister("newmap",       "newgame");
01795   IConsoleAliasRegister("patch",        "setting %+");
01796   IConsoleAliasRegister("set",          "setting %+");
01797   IConsoleAliasRegister("set_newgame",  "setting_newgame %+");
01798   IConsoleAliasRegister("list_patches", "list_settings %+");
01799   IConsoleAliasRegister("developer",    "setting developer %+");
01800 
01801 #ifdef ENABLE_AI
01802   IConsoleCmdRegister("list_ai_libs", ConListAILibs);
01803   IConsoleCmdRegister("list_ai",      ConListAI);
01804   IConsoleCmdRegister("reload_ai",    ConReloadAI);
01805   IConsoleCmdRegister("rescan_ai",    ConRescanAI);
01806   IConsoleCmdRegister("start_ai",     ConStartAI);
01807   IConsoleCmdRegister("stop_ai",      ConStopAI);
01808 #endif /* ENABLE_AI */
01809 
01810   /* networking functions */
01811 #ifdef ENABLE_NETWORK
01812 /* Content downloading is only available with ZLIB */
01813 #if defined(WITH_ZLIB)
01814   IConsoleCmdRegister("content",         ConContent);
01815 #endif /* defined(WITH_ZLIB) */
01816 
01817   /*** Networking commands ***/
01818   IConsoleCmdRegister("say",             ConSay, ConHookNeedNetwork);
01819   IConsoleCmdRegister("companies",       ConCompanies, ConHookServerOnly);
01820   IConsoleAliasRegister("players",       "companies");
01821   IConsoleCmdRegister("say_company",     ConSayCompany, ConHookNeedNetwork);
01822   IConsoleAliasRegister("say_player",    "say_company %+");
01823   IConsoleCmdRegister("say_client",      ConSayClient, ConHookNeedNetwork);
01824 
01825   IConsoleCmdRegister("connect",         ConNetworkConnect, ConHookClientOnly);
01826   IConsoleCmdRegister("clients",         ConNetworkClients, ConHookNeedNetwork);
01827   IConsoleCmdRegister("status",          ConStatus, ConHookServerOnly);
01828   IConsoleCmdRegister("server_info",     ConServerInfo, ConHookServerOnly);
01829   IConsoleAliasRegister("info",          "server_info");
01830   IConsoleCmdRegister("reconnect",       ConNetworkReconnect, ConHookClientOnly);
01831   IConsoleCmdRegister("rcon",            ConRcon, ConHookNeedNetwork);
01832 
01833   IConsoleCmdRegister("join",            ConJoinCompany, ConHookNeedNetwork);
01834   IConsoleAliasRegister("spectate",      "join 255");
01835   IConsoleCmdRegister("move",            ConMoveClient, ConHookServerOnly);
01836   IConsoleCmdRegister("reset_company",   ConResetCompany, ConHookServerOnly);
01837   IConsoleAliasRegister("clean_company", "reset_company %A");
01838   IConsoleCmdRegister("client_name",     ConClientNickChange, ConHookServerOnly);
01839   IConsoleCmdRegister("kick",            ConKick, ConHookServerOnly);
01840   IConsoleCmdRegister("ban",             ConBan, ConHookServerOnly);
01841   IConsoleCmdRegister("unban",           ConUnBan, ConHookServerOnly);
01842   IConsoleCmdRegister("banlist",         ConBanList, ConHookServerOnly);
01843 
01844   IConsoleCmdRegister("pause",           ConPauseGame, ConHookServerOnly);
01845   IConsoleCmdRegister("unpause",         ConUnPauseGame, ConHookServerOnly);
01846 
01847   IConsoleCmdRegister("company_pw",      ConCompanyPassword, ConHookNeedNetwork);
01848   IConsoleAliasRegister("company_password",      "company_pw %+");
01849 
01850   IConsoleAliasRegister("net_frame_freq",        "setting frame_freq %+");
01851   IConsoleAliasRegister("net_sync_freq",         "setting sync_freq %+");
01852   IConsoleAliasRegister("server_pw",             "setting server_password %+");
01853   IConsoleAliasRegister("server_password",       "setting server_password %+");
01854   IConsoleAliasRegister("rcon_pw",               "setting rcon_password %+");
01855   IConsoleAliasRegister("rcon_password",         "setting rcon_password %+");
01856   IConsoleAliasRegister("name",                  "setting client_name %+");
01857   IConsoleAliasRegister("server_name",           "setting server_name %+");
01858   IConsoleAliasRegister("server_port",           "setting server_port %+");
01859   IConsoleAliasRegister("server_advertise",      "setting server_advertise %+");
01860   IConsoleAliasRegister("max_clients",           "setting max_clients %+");
01861   IConsoleAliasRegister("max_companies",         "setting max_companies %+");
01862   IConsoleAliasRegister("max_spectators",        "setting max_spectators %+");
01863   IConsoleAliasRegister("max_join_time",         "setting max_join_time %+");
01864   IConsoleAliasRegister("pause_on_join",         "setting pause_on_join %+");
01865   IConsoleAliasRegister("autoclean_companies",   "setting autoclean_companies %+");
01866   IConsoleAliasRegister("autoclean_protected",   "setting autoclean_protected %+");
01867   IConsoleAliasRegister("autoclean_unprotected", "setting autoclean_unprotected %+");
01868   IConsoleAliasRegister("restart_game_year",     "setting restart_game_year %+");
01869   IConsoleAliasRegister("min_players",           "setting min_active_clients %+");
01870   IConsoleAliasRegister("reload_cfg",            "setting reload_cfg %+");
01871 #endif /* ENABLE_NETWORK */
01872 
01873   /* debugging stuff */
01874 #ifdef _DEBUG
01875   IConsoleDebugLibRegister();
01876 #endif
01877 
01878   /* NewGRF development stuff */
01879   IConsoleCmdRegister("reload_newgrfs",  ConNewGRFReload, ConHookNewGRFDeveloperTool);
01880 }

Generated on Sun Jan 9 16:01:53 2011 for OpenTTD by  doxygen 1.6.1