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