console_cmds.cpp

Go to the documentation of this file.
00001 /* $Id: console_cmds.cpp 21250 2010-11-18 23:31:06Z rubidium $ */
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((ConsoleColour)atoi(argv[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 DEF_CONSOLE_CMD(ConListAI)
00999 {
01000   char buf[4096];
01001   char *p = &buf[0];
01002   p = AI::GetConsoleList(p, lastof(buf));
01003 
01004   p = &buf[0];
01005   /* Print output line by line */
01006   for (char *p2 = &buf[0]; *p2 != '\0'; p2++) {
01007     if (*p2 == '\n') {
01008       *p2 = '\0';
01009       IConsolePrintF(CC_DEFAULT, "%s", p);
01010       p = p2 + 1;
01011     }
01012   }
01013 
01014   return true;
01015 }
01016 
01017 DEF_CONSOLE_CMD(ConStartAI)
01018 {
01019   if (argc == 0 || argc > 3) {
01020     IConsoleHelp("Start a new AI. Usage: 'start_ai [<AI>] [<settings>]'");
01021     IConsoleHelp("Start a new AI. If <AI> is given, it starts that specific AI (if found).");
01022     IConsoleHelp("If <settings> is given, it is parsed and the AI settings are set to that.");
01023     return true;
01024   }
01025 
01026   if (_game_mode != GM_NORMAL) {
01027     IConsoleWarning("AIs can only be managed in a game.");
01028     return true;
01029   }
01030 
01031   if (Company::GetNumItems() == CompanyPool::MAX_SIZE) {
01032     IConsoleWarning("Can't start a new AI (no more free slots).");
01033     return true;
01034   }
01035   if (_networking && !_network_server) {
01036     IConsoleWarning("Only the server can start a new AI.");
01037     return true;
01038   }
01039   if (_networking && !_settings_game.ai.ai_in_multiplayer) {
01040     IConsoleWarning("AIs are not allowed in multiplayer by configuration.");
01041     IConsoleWarning("Switch AI -> AI in multiplayer to True.");
01042     return true;
01043   }
01044   if (!AI::CanStartNew()) {
01045     IConsoleWarning("Can't start a new AI.");
01046     return true;
01047   }
01048 
01049   int n = 0;
01050   Company *c;
01051   /* Find the next free slot */
01052   FOR_ALL_COMPANIES(c) {
01053     if (c->index != n) break;
01054     n++;
01055   }
01056 
01057   AIConfig *config = AIConfig::GetConfig((CompanyID)n);
01058   if (argc >= 2) {
01059     config->ChangeAI(argv[1], -1, true);
01060     if (!config->HasAI()) {
01061       IConsoleWarning("Failed to load the specified AI");
01062       return true;
01063     }
01064     if (argc == 3) {
01065       config->StringToSettings(argv[2]);
01066     }
01067   }
01068 
01069   /* Start a new AI company */
01070   DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
01071 
01072   return true;
01073 }
01074 
01075 DEF_CONSOLE_CMD(ConReloadAI)
01076 {
01077   if (argc != 2) {
01078     IConsoleHelp("Reload an AI. Usage: 'reload_ai <company-id>'");
01079     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.");
01080     return true;
01081   }
01082 
01083   if (_game_mode != GM_NORMAL) {
01084     IConsoleWarning("AIs can only be managed in a game.");
01085     return true;
01086   }
01087 
01088   if (_networking && !_network_server) {
01089     IConsoleWarning("Only the server can reload an AI.");
01090     return true;
01091   }
01092 
01093   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01094   if (!Company::IsValidID(company_id)) {
01095     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01096     return true;
01097   }
01098 
01099   if (Company::IsHumanID(company_id)) {
01100     IConsoleWarning("Company is not controlled by an AI.");
01101     return true;
01102   }
01103 
01104   /* First kill the company of the AI, then start a new one. This should start the current AI again */
01105   DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
01106   DoCommandP(0, 1 | company_id << 16, 0, CMD_COMPANY_CTRL);
01107   IConsolePrint(CC_DEFAULT, "AI reloaded.");
01108 
01109   return true;
01110 }
01111 
01112 DEF_CONSOLE_CMD(ConStopAI)
01113 {
01114   if (argc != 2) {
01115     IConsoleHelp("Stop an AI. Usage: 'stop_ai <company-id>'");
01116     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.");
01117     return true;
01118   }
01119 
01120   if (_game_mode != GM_NORMAL) {
01121     IConsoleWarning("AIs can only be managed in a game.");
01122     return true;
01123   }
01124 
01125   if (_networking && !_network_server) {
01126     IConsoleWarning("Only the server can stop an AI.");
01127     return true;
01128   }
01129 
01130   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01131   if (!Company::IsValidID(company_id)) {
01132     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01133     return true;
01134   }
01135 
01136   if (Company::IsHumanID(company_id)) {
01137     IConsoleWarning("Company is not controlled by an AI.");
01138     return true;
01139   }
01140 
01141   /* Now kill the company of the AI. */
01142   DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
01143   IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
01144 
01145   return true;
01146 }
01147 
01148 DEF_CONSOLE_CMD(ConRescanAI)
01149 {
01150   if (argc == 0) {
01151     IConsoleHelp("Rescan the AI dir for scripts. Usage: 'rescan_ai'");
01152     return true;
01153   }
01154 
01155   if (_networking && !_network_server) {
01156     IConsoleWarning("Only the server can rescan the AI dir for scripts.");
01157     return true;
01158   }
01159 
01160   TarScanner::DoScan();
01161   AI::Rescan();
01162   InvalidateWindowData(WC_AI_LIST, 0, 1);
01163   SetWindowDirty(WC_AI_SETTINGS, 0);
01164 
01165   return true;
01166 }
01167 #endif /* ENABLE_AI */
01168 
01169 DEF_CONSOLE_CMD(ConRescanNewGRF)
01170 {
01171   if (argc == 0) {
01172     IConsoleHelp("Rescan the data dir for NewGRFs. Usage: 'rescan_newgrf'");
01173     return true;
01174   }
01175 
01176   TarScanner::DoScan();
01177   ScanNewGRFFiles();
01178   InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
01179 
01180   return true;
01181 }
01182 
01183 DEF_CONSOLE_CMD(ConGetSeed)
01184 {
01185   if (argc == 0) {
01186     IConsoleHelp("Returns the seed used to create this game. Usage: 'getseed'");
01187     IConsoleHelp("The seed can be used to reproduce the exact same map as the game started with.");
01188     return true;
01189   }
01190 
01191   IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _settings_game.game_creation.generation_seed);
01192   return true;
01193 }
01194 
01195 DEF_CONSOLE_CMD(ConGetDate)
01196 {
01197   if (argc == 0) {
01198     IConsoleHelp("Returns the current date (day-month-year) of the game. Usage: 'getdate'");
01199     return true;
01200   }
01201 
01202   YearMonthDay ymd;
01203   ConvertDateToYMD(_date, &ymd);
01204   IConsolePrintF(CC_DEFAULT, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
01205   return true;
01206 }
01207 
01208 
01209 DEF_CONSOLE_CMD(ConAlias)
01210 {
01211   IConsoleAlias *alias;
01212 
01213   if (argc == 0) {
01214     IConsoleHelp("Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'");
01215     return true;
01216   }
01217 
01218   if (argc < 3) return false;
01219 
01220   alias = IConsoleAliasGet(argv[1]);
01221   if (alias == NULL) {
01222     IConsoleAliasRegister(argv[1], argv[2]);
01223   } else {
01224     free(alias->cmdline);
01225     alias->cmdline = strdup(argv[2]);
01226   }
01227   return true;
01228 }
01229 
01230 DEF_CONSOLE_CMD(ConScreenShot)
01231 {
01232   if (argc == 0) {
01233     IConsoleHelp("Create a screenshot of the game. Usage: 'screenshot [big | giant | no_con] [file name]'");
01234     IConsoleHelp("'big' makes a zoomed-in screenshot of the visible area, 'giant' makes a screenshot of the "
01235         "whole map, 'no_con' hides the console to create the screenshot. 'big' or 'giant' "
01236         "screenshots are always drawn without console");
01237     return true;
01238   }
01239 
01240   if (argc > 3) return false;
01241 
01242   ScreenshotType type = SC_VIEWPORT;
01243   const char *name = NULL;
01244 
01245   if (argc > 1) {
01246     if (strcmp(argv[1], "big") == 0) {
01247       /* screenshot big [filename] */
01248       type = SC_ZOOMEDIN;
01249       if (argc > 2) name = argv[2];
01250     } else if (strcmp(argv[1], "giant") == 0) {
01251       /* screenshot giant [filename] */
01252       type = SC_WORLD;
01253       if (argc > 2) name = argv[2];
01254     } else if (strcmp(argv[1], "no_con") == 0) {
01255       /* screenshot no_con [filename] */
01256       IConsoleClose();
01257       if (argc > 2) name = argv[2];
01258     } else if (argc == 2) {
01259       /* screenshot filename */
01260       name = argv[1];
01261     } else {
01262       /* screenshot argv[1] argv[2] - invalid */
01263       return false;
01264     }
01265   }
01266 
01267   MakeScreenshot(type, name);
01268   return true;
01269 }
01270 
01271 DEF_CONSOLE_CMD(ConInfoCmd)
01272 {
01273   if (argc == 0) {
01274     IConsoleHelp("Print out debugging information about a command. Usage: 'info_cmd <cmd>'");
01275     return true;
01276   }
01277 
01278   if (argc < 2) return false;
01279 
01280   const IConsoleCmd *cmd = IConsoleCmdGet(argv[1]);
01281   if (cmd == NULL) {
01282     IConsoleError("the given command was not found");
01283     return true;
01284   }
01285 
01286   IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
01287   IConsolePrintF(CC_DEFAULT, "command proc: %p", cmd->proc);
01288 
01289   if (cmd->hook != NULL) IConsoleWarning("command is hooked");
01290 
01291   return true;
01292 }
01293 
01294 DEF_CONSOLE_CMD(ConDebugLevel)
01295 {
01296   if (argc == 0) {
01297     IConsoleHelp("Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'");
01298     IConsoleHelp("Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'s");
01299     return true;
01300   }
01301 
01302   if (argc > 2) return false;
01303 
01304   if (argc == 1) {
01305     IConsolePrintF(CC_DEFAULT, "Current debug-level: '%s'", GetDebugString());
01306   } else {
01307     SetDebugString(argv[1]);
01308   }
01309 
01310   return true;
01311 }
01312 
01313 DEF_CONSOLE_CMD(ConExit)
01314 {
01315   if (argc == 0) {
01316     IConsoleHelp("Exit the game. Usage: 'exit'");
01317     return true;
01318   }
01319 
01320   if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave();
01321 
01322   _exit_game = true;
01323   return true;
01324 }
01325 
01326 DEF_CONSOLE_CMD(ConPart)
01327 {
01328   if (argc == 0) {
01329     IConsoleHelp("Leave the currently joined/running game (only ingame). Usage: 'part'");
01330     return true;
01331   }
01332 
01333   if (_game_mode != GM_NORMAL) return false;
01334 
01335   _switch_mode = SM_MENU;
01336   return true;
01337 }
01338 
01339 DEF_CONSOLE_CMD(ConHelp)
01340 {
01341   if (argc == 2) {
01342     const IConsoleCmd *cmd;
01343     const IConsoleAlias *alias;
01344 
01345     RemoveUnderscores(argv[1]);
01346     cmd = IConsoleCmdGet(argv[1]);
01347     if (cmd != NULL) {
01348       cmd->proc(0, NULL);
01349       return true;
01350     }
01351 
01352     alias = IConsoleAliasGet(argv[1]);
01353     if (alias != NULL) {
01354       cmd = IConsoleCmdGet(alias->cmdline);
01355       if (cmd != NULL) {
01356         cmd->proc(0, NULL);
01357         return true;
01358       }
01359       IConsolePrintF(CC_ERROR, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
01360       return true;
01361     }
01362 
01363     IConsoleError("command not found");
01364     return true;
01365   }
01366 
01367   IConsolePrint(CC_WARNING, " ---- OpenTTD Console Help ---- ");
01368   IConsolePrint(CC_DEFAULT, " - commands: [command to list all commands: list_cmds]");
01369   IConsolePrint(CC_DEFAULT, " call commands with '<command> <arg2> <arg3>...'");
01370   IConsolePrint(CC_DEFAULT, " - to assign strings, or use them as arguments, enclose it within quotes");
01371   IConsolePrint(CC_DEFAULT, " like this: '<command> \"string argument with spaces\"'");
01372   IConsolePrint(CC_DEFAULT, " - use 'help <command>' to get specific information");
01373   IConsolePrint(CC_DEFAULT, " - scroll console output with shift + (up | down) | (pageup | pagedown))");
01374   IConsolePrint(CC_DEFAULT, " - scroll console input history with the up | down arrows");
01375   IConsolePrint(CC_DEFAULT, "");
01376   return true;
01377 }
01378 
01379 DEF_CONSOLE_CMD(ConListCommands)
01380 {
01381   if (argc == 0) {
01382     IConsoleHelp("List all registered commands. Usage: 'list_cmds [<pre-filter>]'");
01383     return true;
01384   }
01385 
01386   for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) {
01387     if (argv[1] == NULL || strstr(cmd->name, argv[1]) != NULL) {
01388       if (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
01389     }
01390   }
01391 
01392   return true;
01393 }
01394 
01395 DEF_CONSOLE_CMD(ConListAliases)
01396 {
01397   if (argc == 0) {
01398     IConsoleHelp("List all registered aliases. Usage: 'list_aliases [<pre-filter>]'");
01399     return true;
01400   }
01401 
01402   for (const IConsoleAlias *alias = _iconsole_aliases; alias != NULL; alias = alias->next) {
01403     if (argv[1] == NULL || strstr(alias->name, argv[1]) != NULL) {
01404       IConsolePrintF(CC_DEFAULT, "%s => %s", alias->name, alias->cmdline);
01405     }
01406   }
01407 
01408   return true;
01409 }
01410 
01411 #ifdef ENABLE_NETWORK
01412 
01413 DEF_CONSOLE_CMD(ConSay)
01414 {
01415   if (argc == 0) {
01416     IConsoleHelp("Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
01417     return true;
01418   }
01419 
01420   if (argc != 2) return false;
01421 
01422   if (!_network_server) {
01423     NetworkClientSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
01424   } else {
01425     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01426     NetworkServerSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], CLIENT_ID_SERVER, from_admin);
01427   }
01428 
01429   return true;
01430 }
01431 
01432 DEF_CONSOLE_CMD(ConCompanies)
01433 {
01434   if (argc == 0) {
01435     IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
01436     return true;
01437   }
01438   NetworkCompanyStats company_stats[MAX_COMPANIES];
01439   NetworkPopulateCompanyStats(company_stats);
01440 
01441   Company *c;
01442   FOR_ALL_COMPANIES(c) {
01443     /* Grab the company name */
01444     char company_name[NETWORK_COMPANY_NAME_LENGTH];
01445     SetDParam(0, c->index);
01446     GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
01447 
01448     char buffer[512];
01449     const NetworkCompanyStats *stats = &company_stats[c->index];
01450 
01451     GetString(buffer, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(buffer));
01452     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",
01453       c->index + 1, buffer, company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
01454       /* trains      */ stats->num_vehicle[0],
01455       /* lorry + bus */ stats->num_vehicle[1] + stats->num_vehicle[2],
01456       /* planes      */ stats->num_vehicle[3],
01457       /* ships       */ stats->num_vehicle[4],
01458       /* protected   */ StrEmpty(_network_company_states[c->index].password) ? "un" : "");
01459   }
01460 
01461   return true;
01462 }
01463 
01464 DEF_CONSOLE_CMD(ConSayCompany)
01465 {
01466   if (argc == 0) {
01467     IConsoleHelp("Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
01468     IConsoleHelp("CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
01469     return true;
01470   }
01471 
01472   if (argc != 3) return false;
01473 
01474   CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
01475   if (!Company::IsValidID(company_id)) {
01476     IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
01477     return true;
01478   }
01479 
01480   if (!_network_server) {
01481     NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2]);
01482   } else {
01483     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01484     NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2], CLIENT_ID_SERVER, from_admin);
01485   }
01486 
01487   return true;
01488 }
01489 
01490 DEF_CONSOLE_CMD(ConSayClient)
01491 {
01492   if (argc == 0) {
01493     IConsoleHelp("Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
01494     IConsoleHelp("For client-id's, see the command 'clients'");
01495     return true;
01496   }
01497 
01498   if (argc != 3) return false;
01499 
01500   if (!_network_server) {
01501     NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
01502   } else {
01503     bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
01504     NetworkServerSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], CLIENT_ID_SERVER, from_admin);
01505   }
01506 
01507   return true;
01508 }
01509 
01510 extern void HashCurrentCompanyPassword(const char *password);
01511 
01512 DEF_CONSOLE_CMD(ConCompanyPassword)
01513 {
01514   if (argc == 0) {
01515     IConsoleHelp("Change the password of your company. Usage: 'company_pw \"<password>\"'");
01516     IConsoleHelp("Use \"*\" to disable the password.");
01517     return true;
01518   }
01519 
01520   if (argc != 2) return false;
01521 
01522   if (!Company::IsValidID(_local_company)) {
01523     IConsoleError("You have to own a company to make use of this command.");
01524     return false;
01525   }
01526 
01527   const char *password = NetworkChangeCompanyPassword(argv[1]);
01528 
01529   if (StrEmpty(password)) {
01530     IConsolePrintF(CC_WARNING, "Company password cleared");
01531   } else {
01532     IConsolePrintF(CC_WARNING, "Company password changed to: %s", password);
01533   }
01534 
01535   return true;
01536 }
01537 
01538 /* Content downloading only is available with ZLIB */
01539 #if defined(WITH_ZLIB)
01540 #include "network/network_content.h"
01541 
01543 static ContentType StringToContentType(const char *str)
01544 {
01545   static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
01546   for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
01547     if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
01548   }
01549   return CONTENT_TYPE_END;
01550 }
01551 
01553 struct ConsoleContentCallback : public ContentCallback {
01554   void OnConnect(bool success)
01555   {
01556     IConsolePrintF(CC_DEFAULT, "Content server connection %s", success ? "established" : "failed");
01557   }
01558 
01559   void OnDisconnect()
01560   {
01561     IConsolePrintF(CC_DEFAULT, "Content server connection closed");
01562   }
01563 
01564   void OnDownloadComplete(ContentID cid)
01565   {
01566     IConsolePrintF(CC_DEFAULT, "Completed download of %d", cid);
01567   }
01568 };
01569 
01570 DEF_CONSOLE_CMD(ConContent)
01571 {
01572   static ContentCallback *cb = NULL;
01573   if (cb == NULL) {
01574     cb = new ConsoleContentCallback();
01575     _network_content_client.AddCallback(cb);
01576   }
01577 
01578   if (argc <= 1) {
01579     IConsoleHelp("Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state|download'");
01580     IConsoleHelp("  update: get a new list of downloadable content; must be run first");
01581     IConsoleHelp("  upgrade: select all items that are upgrades");
01582     IConsoleHelp("  select: select a specific item given by its id or 'all' to select all");
01583     IConsoleHelp("  unselect: unselect a specific item given by its id or 'all' to unselect all");
01584     IConsoleHelp("  state: show the download/select state of all downloadable content");
01585     IConsoleHelp("  download: download all content you've selected");
01586     return true;
01587   }
01588 
01589   if (strcasecmp(argv[1], "update") == 0) {
01590     _network_content_client.RequestContentList((argc > 2) ? StringToContentType(argv[2]) : CONTENT_TYPE_END);
01591     return true;
01592   }
01593 
01594   if (strcasecmp(argv[1], "upgrade") == 0) {
01595     _network_content_client.SelectUpgrade();
01596     return true;
01597   }
01598 
01599   if (strcasecmp(argv[1], "select") == 0) {
01600     if (argc <= 2) {
01601       IConsoleError("You must enter the id.");
01602       return false;
01603     }
01604     if (strcasecmp(argv[2], "all") == 0) {
01605       _network_content_client.SelectAll();
01606     } else {
01607       _network_content_client.Select((ContentID)atoi(argv[2]));
01608     }
01609     return true;
01610   }
01611 
01612   if (strcasecmp(argv[1], "unselect") == 0) {
01613     if (argc <= 2) {
01614       IConsoleError("You must enter the id.");
01615       return false;
01616     }
01617     if (strcasecmp(argv[2], "all") == 0) {
01618       _network_content_client.UnselectAll();
01619     } else {
01620       _network_content_client.Unselect((ContentID)atoi(argv[2]));
01621     }
01622     return true;
01623   }
01624 
01625   if (strcasecmp(argv[1], "state") == 0) {
01626     IConsolePrintF(CC_WHITE, "id, type, state, name");
01627     for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
01628       static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" };
01629       assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
01630       static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
01631       static const ConsoleColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
01632 
01633       const ContentInfo *ci = *iter;
01634       IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
01635     }
01636     return true;
01637   }
01638 
01639   if (strcasecmp(argv[1], "download") == 0) {
01640     uint files;
01641     uint bytes;
01642     _network_content_client.DownloadSelectedContent(files, bytes);
01643     IConsolePrintF(CC_DEFAULT, "Downloading %d file(s) (%d bytes)", files, bytes);
01644     return true;
01645   }
01646 
01647   return false;
01648 }
01649 #endif /* defined(WITH_ZLIB) */
01650 #endif /* ENABLE_NETWORK */
01651 
01652 DEF_CONSOLE_CMD(ConSetting)
01653 {
01654   if (argc == 0) {
01655     IConsoleHelp("Change setting for all clients. Usage: 'setting <name> [<value>]'");
01656     IConsoleHelp("Omitting <value> will print out the current value of the setting.");
01657     return true;
01658   }
01659 
01660   if (argc == 1 || argc > 3) return false;
01661 
01662   if (argc == 2) {
01663     IConsoleGetSetting(argv[1]);
01664   } else {
01665     IConsoleSetSetting(argv[1], argv[2]);
01666   }
01667 
01668   return true;
01669 }
01670 
01671 DEF_CONSOLE_CMD(ConSettingNewgame)
01672 {
01673   if (argc == 0) {
01674     IConsoleHelp("Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'");
01675     IConsoleHelp("Omitting <value> will print out the current value of the setting.");
01676     return true;
01677   }
01678 
01679   if (argc == 1 || argc > 3) return false;
01680 
01681   if (argc == 2) {
01682     IConsoleGetSetting(argv[1], true);
01683   } else {
01684     IConsoleSetSetting(argv[1], argv[2], true);
01685   }
01686 
01687   return true;
01688 }
01689 
01690 DEF_CONSOLE_CMD(ConListSettings)
01691 {
01692   if (argc == 0) {
01693     IConsoleHelp("List settings. Usage: 'list_settings [<pre-filter>]'");
01694     return true;
01695   }
01696 
01697   if (argc > 2) return false;
01698 
01699   IConsoleListSettings((argc == 2) ? argv[1] : NULL);
01700   return true;
01701 }
01702 
01703 DEF_CONSOLE_CMD(ConGamelogPrint)
01704 {
01705   GamelogPrintConsole();
01706   return true;
01707 }
01708 
01709 DEF_CONSOLE_CMD(ConNewGRFReload)
01710 {
01711   if (argc == 0) {
01712     IConsoleHelp("Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
01713     return true;
01714   }
01715 
01716   ReloadNewGRFData();
01717   return true;
01718 }
01719 
01720 #ifdef _DEBUG
01721 /******************
01722  *  debug commands
01723  ******************/
01724 
01725 static void IConsoleDebugLibRegister()
01726 {
01727   IConsoleCmdRegister("resettile",        ConResetTile);
01728   IConsoleCmdRegister("stopall",          ConStopAllVehicles);
01729   IConsoleAliasRegister("dbg_echo",       "echo %A; echo %B");
01730   IConsoleAliasRegister("dbg_echo2",      "echo %!");
01731 }
01732 #endif
01733 
01734 /*******************************
01735  * console command registration
01736  *******************************/
01737 
01738 void IConsoleStdLibRegister()
01739 {
01740   IConsoleCmdRegister("debug_level",  ConDebugLevel);
01741   IConsoleCmdRegister("echo",         ConEcho);
01742   IConsoleCmdRegister("echoc",        ConEchoC);
01743   IConsoleCmdRegister("exec",         ConExec);
01744   IConsoleCmdRegister("exit",         ConExit);
01745   IConsoleCmdRegister("part",         ConPart);
01746   IConsoleCmdRegister("help",         ConHelp);
01747   IConsoleCmdRegister("info_cmd",     ConInfoCmd);
01748   IConsoleCmdRegister("list_cmds",    ConListCommands);
01749   IConsoleCmdRegister("list_aliases", ConListAliases);
01750   IConsoleCmdRegister("newgame",      ConNewGame);
01751   IConsoleCmdRegister("restart",      ConRestart);
01752   IConsoleCmdRegister("getseed",      ConGetSeed);
01753   IConsoleCmdRegister("getdate",      ConGetDate);
01754   IConsoleCmdRegister("quit",         ConExit);
01755   IConsoleCmdRegister("resetengines", ConResetEngines, ConHookNoNetwork);
01756   IConsoleCmdRegister("return",       ConReturn);
01757   IConsoleCmdRegister("screenshot",   ConScreenShot);
01758   IConsoleCmdRegister("script",       ConScript);
01759   IConsoleCmdRegister("scrollto",     ConScrollToTile);
01760   IConsoleCmdRegister("alias",        ConAlias);
01761   IConsoleCmdRegister("load",         ConLoad);
01762   IConsoleCmdRegister("rm",           ConRemove);
01763   IConsoleCmdRegister("save",         ConSave);
01764   IConsoleCmdRegister("saveconfig",   ConSaveConfig);
01765   IConsoleCmdRegister("ls",           ConListFiles);
01766   IConsoleCmdRegister("cd",           ConChangeDirectory);
01767   IConsoleCmdRegister("pwd",          ConPrintWorkingDirectory);
01768   IConsoleCmdRegister("clear",        ConClearBuffer);
01769   IConsoleCmdRegister("setting",      ConSetting);
01770   IConsoleCmdRegister("setting_newgame", ConSettingNewgame);
01771   IConsoleCmdRegister("list_settings",ConListSettings);
01772   IConsoleCmdRegister("gamelog",      ConGamelogPrint);
01773   IConsoleCmdRegister("rescan_newgrf", ConRescanNewGRF);
01774 
01775   IConsoleAliasRegister("dir",          "ls");
01776   IConsoleAliasRegister("del",          "rm %+");
01777   IConsoleAliasRegister("newmap",       "newgame");
01778   IConsoleAliasRegister("patch",        "setting %+");
01779   IConsoleAliasRegister("set",          "setting %+");
01780   IConsoleAliasRegister("set_newgame",  "setting_newgame %+");
01781   IConsoleAliasRegister("list_patches", "list_settings %+");
01782   IConsoleAliasRegister("developer",    "setting developer %+");
01783 
01784 #ifdef ENABLE_AI
01785   IConsoleCmdRegister("list_ai",      ConListAI);
01786   IConsoleCmdRegister("reload_ai",    ConReloadAI);
01787   IConsoleCmdRegister("rescan_ai",    ConRescanAI);
01788   IConsoleCmdRegister("start_ai",     ConStartAI);
01789   IConsoleCmdRegister("stop_ai",      ConStopAI);
01790 #endif /* ENABLE_AI */
01791 
01792   /* networking functions */
01793 #ifdef ENABLE_NETWORK
01794 /* Content downloading is only available with ZLIB */
01795 #if defined(WITH_ZLIB)
01796   IConsoleCmdRegister("content",         ConContent);
01797 #endif /* defined(WITH_ZLIB) */
01798 
01799   /*** Networking commands ***/
01800   IConsoleCmdRegister("say",             ConSay, ConHookNeedNetwork);
01801   IConsoleCmdRegister("companies",       ConCompanies, ConHookServerOnly);
01802   IConsoleAliasRegister("players",       "companies");
01803   IConsoleCmdRegister("say_company",     ConSayCompany, ConHookNeedNetwork);
01804   IConsoleAliasRegister("say_player",    "say_company %+");
01805   IConsoleCmdRegister("say_client",      ConSayClient, ConHookNeedNetwork);
01806 
01807   IConsoleCmdRegister("connect",         ConNetworkConnect, ConHookClientOnly);
01808   IConsoleCmdRegister("clients",         ConNetworkClients, ConHookNeedNetwork);
01809   IConsoleCmdRegister("status",          ConStatus, ConHookServerOnly);
01810   IConsoleCmdRegister("server_info",     ConServerInfo, ConHookServerOnly);
01811   IConsoleAliasRegister("info",          "server_info");
01812   IConsoleCmdRegister("reconnect",       ConNetworkReconnect, ConHookClientOnly);
01813   IConsoleCmdRegister("rcon",            ConRcon, ConHookNeedNetwork);
01814 
01815   IConsoleCmdRegister("join",            ConJoinCompany, ConHookNeedNetwork);
01816   IConsoleAliasRegister("spectate",      "join 255");
01817   IConsoleCmdRegister("move",            ConMoveClient, ConHookServerOnly);
01818   IConsoleCmdRegister("reset_company",   ConResetCompany, ConHookServerOnly);
01819   IConsoleAliasRegister("clean_company", "reset_company %A");
01820   IConsoleCmdRegister("client_name",     ConClientNickChange, ConHookServerOnly);
01821   IConsoleCmdRegister("kick",            ConKick, ConHookServerOnly);
01822   IConsoleCmdRegister("ban",             ConBan, ConHookServerOnly);
01823   IConsoleCmdRegister("unban",           ConUnBan, ConHookServerOnly);
01824   IConsoleCmdRegister("banlist",         ConBanList, ConHookServerOnly);
01825 
01826   IConsoleCmdRegister("pause",           ConPauseGame, ConHookServerOnly);
01827   IConsoleCmdRegister("unpause",         ConUnPauseGame, ConHookServerOnly);
01828 
01829   IConsoleCmdRegister("company_pw",      ConCompanyPassword, ConHookNeedNetwork);
01830   IConsoleAliasRegister("company_password",      "company_pw %+");
01831 
01832   IConsoleAliasRegister("net_frame_freq",        "setting frame_freq %+");
01833   IConsoleAliasRegister("net_sync_freq",         "setting sync_freq %+");
01834   IConsoleAliasRegister("server_pw",             "setting server_password %+");
01835   IConsoleAliasRegister("server_password",       "setting server_password %+");
01836   IConsoleAliasRegister("rcon_pw",               "setting rcon_password %+");
01837   IConsoleAliasRegister("rcon_password",         "setting rcon_password %+");
01838   IConsoleAliasRegister("name",                  "setting client_name %+");
01839   IConsoleAliasRegister("server_name",           "setting server_name %+");
01840   IConsoleAliasRegister("server_port",           "setting server_port %+");
01841   IConsoleAliasRegister("server_advertise",      "setting server_advertise %+");
01842   IConsoleAliasRegister("max_clients",           "setting max_clients %+");
01843   IConsoleAliasRegister("max_companies",         "setting max_companies %+");
01844   IConsoleAliasRegister("max_spectators",        "setting max_spectators %+");
01845   IConsoleAliasRegister("max_join_time",         "setting max_join_time %+");
01846   IConsoleAliasRegister("pause_on_join",         "setting pause_on_join %+");
01847   IConsoleAliasRegister("autoclean_companies",   "setting autoclean_companies %+");
01848   IConsoleAliasRegister("autoclean_protected",   "setting autoclean_protected %+");
01849   IConsoleAliasRegister("autoclean_unprotected", "setting autoclean_unprotected %+");
01850   IConsoleAliasRegister("restart_game_year",     "setting restart_game_year %+");
01851   IConsoleAliasRegister("min_players",           "setting min_active_clients %+");
01852   IConsoleAliasRegister("reload_cfg",            "setting reload_cfg %+");
01853 #endif /* ENABLE_NETWORK */
01854 
01855   /* debugging stuff */
01856 #ifdef _DEBUG
01857   IConsoleDebugLibRegister();
01858 #endif
01859 
01860   /* NewGRF development stuff */
01861   IConsoleCmdRegister("reload_newgrfs",  ConNewGRFReload, ConHookNewGRFDeveloperTool);
01862 }

Generated on Fri Dec 31 17:15:30 2010 for OpenTTD by  doxygen 1.6.1