OpenTTD Source  13.2.1
console_cmds.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #include "stdafx.h"
11 #include "console_internal.h"
12 #include "debug.h"
13 #include "engine_func.h"
14 #include "landscape.h"
15 #include "saveload/saveload.h"
16 #include "network/core/game_info.h"
17 #include "network/network.h"
18 #include "network/network_func.h"
19 #include "network/network_base.h"
20 #include "network/network_admin.h"
21 #include "network/network_client.h"
22 #include "command_func.h"
23 #include "settings_func.h"
24 #include "fios.h"
25 #include "fileio_func.h"
26 #include "fontcache.h"
27 #include "screenshot.h"
28 #include "genworld.h"
29 #include "strings_func.h"
30 #include "viewport_func.h"
31 #include "window_func.h"
32 #include "date_func.h"
33 #include "company_func.h"
34 #include "gamelog.h"
35 #include "ai/ai.hpp"
36 #include "ai/ai_config.hpp"
37 #include "newgrf.h"
38 #include "newgrf_profiling.h"
39 #include "console_func.h"
40 #include "engine_base.h"
41 #include "road.h"
42 #include "rail.h"
43 #include "game/game.hpp"
44 #include "table/strings.h"
45 #include "walltime_func.h"
46 #include "company_cmd.h"
47 #include "misc_cmd.h"
48 
49 #include <sstream>
50 
51 #include "safeguards.h"
52 
53 /* scriptfile handling */
54 static uint _script_current_depth;
55 
57 class ConsoleFileList : public FileList {
58 public:
60  {
61  this->file_list_valid = false;
62  }
63 
66  {
67  this->clear();
68  this->file_list_valid = false;
69  }
70 
75  void ValidateFileList(bool force_reload = false)
76  {
77  if (force_reload || !this->file_list_valid) {
79  this->file_list_valid = true;
80  }
81  }
82 
84 };
85 
87 
88 /* console command defines */
89 #define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
90 #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
91 
92 
93 /****************
94  * command hooks
95  ****************/
96 
101 static inline bool NetworkAvailable(bool echo)
102 {
103  if (!_network_available) {
104  if (echo) IConsolePrint(CC_ERROR, "You cannot use this command because there is no network available.");
105  return false;
106  }
107  return true;
108 }
109 
114 DEF_CONSOLE_HOOK(ConHookServerOnly)
115 {
116  if (!NetworkAvailable(echo)) return CHR_DISALLOW;
117 
118  if (!_network_server) {
119  if (echo) IConsolePrint(CC_ERROR, "This command is only available to a network server.");
120  return CHR_DISALLOW;
121  }
122  return CHR_ALLOW;
123 }
124 
129 DEF_CONSOLE_HOOK(ConHookClientOnly)
130 {
131  if (!NetworkAvailable(echo)) return CHR_DISALLOW;
132 
133  if (_network_server) {
134  if (echo) IConsolePrint(CC_ERROR, "This command is not available to a network server.");
135  return CHR_DISALLOW;
136  }
137  return CHR_ALLOW;
138 }
139 
144 DEF_CONSOLE_HOOK(ConHookNeedNetwork)
145 {
146  if (!NetworkAvailable(echo)) return CHR_DISALLOW;
147 
149  if (echo) IConsolePrint(CC_ERROR, "Not connected. This command is only available in multiplayer.");
150  return CHR_DISALLOW;
151  }
152  return CHR_ALLOW;
153 }
154 
159 DEF_CONSOLE_HOOK(ConHookNoNetwork)
160 {
161  if (_networking) {
162  if (echo) IConsolePrint(CC_ERROR, "This command is forbidden in multiplayer.");
163  return CHR_DISALLOW;
164  }
165  return CHR_ALLOW;
166 }
167 
172 DEF_CONSOLE_HOOK(ConHookServerOrNoNetwork)
173 {
174  if (_networking && !_network_server) {
175  if (echo) IConsolePrint(CC_ERROR, "This command is only available to a network server.");
176  return CHR_DISALLOW;
177  }
178  return CHR_ALLOW;
179 }
180 
181 DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
182 {
184  if (_game_mode == GM_MENU) {
185  if (echo) IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor.");
186  return CHR_DISALLOW;
187  }
188  return ConHookNoNetwork(echo);
189  }
190  return CHR_HIDE;
191 }
192 
197 DEF_CONSOLE_CMD(ConResetEngines)
198 {
199  if (argc == 0) {
200  IConsolePrint(CC_HELP, "Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'.");
201  return true;
202  }
203 
204  StartupEngines();
205  return true;
206 }
207 
213 DEF_CONSOLE_CMD(ConResetEnginePool)
214 {
215  if (argc == 0) {
216  IConsolePrint(CC_HELP, "Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again.");
217  return true;
218  }
219 
220  if (_game_mode == GM_MENU) {
221  IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor.");
222  return true;
223  }
224 
226  IConsolePrint(CC_ERROR, "This can only be done when there are no vehicles in the game.");
227  return true;
228  }
229 
230  return true;
231 }
232 
233 #ifdef _DEBUG
234 
239 DEF_CONSOLE_CMD(ConResetTile)
240 {
241  if (argc == 0) {
242  IConsolePrint(CC_HELP, "Reset a tile to bare land. Usage: 'resettile <tile>'.");
243  IConsolePrint(CC_HELP, "Tile can be either decimal (34161) or hexadecimal (0x4a5B).");
244  return true;
245  }
246 
247  if (argc == 2) {
248  uint32 result;
249  if (GetArgumentInteger(&result, argv[1])) {
250  DoClearSquare((TileIndex)result);
251  return true;
252  }
253  }
254 
255  return false;
256 }
257 #endif /* _DEBUG */
258 
264 DEF_CONSOLE_CMD(ConZoomToLevel)
265 {
266  switch (argc) {
267  case 0:
268  IConsolePrint(CC_HELP, "Set the current zoom level of the main viewport.");
269  IConsolePrint(CC_HELP, "Usage: 'zoomto <level>'.");
271  CC_HELP,
273  "The lowest zoom-in level allowed by current client settings is {}." :
274  "The lowest supported zoom-in level is {}.",
276  );
278  CC_HELP,
280  "The highest zoom-out level allowed by current client settings is {}." :
281  "The highest supported zoom-out level is {}.",
283  );
284  return true;
285 
286  case 2: {
287  uint32 level;
288  if (GetArgumentInteger(&level, argv[1])) {
289  if (level < ZOOM_LVL_MIN) {
290  IConsolePrint(CC_ERROR, "Zoom-in levels below {} are not supported.", ZOOM_LVL_MIN);
291  } else if (level < _settings_client.gui.zoom_min) {
292  IConsolePrint(CC_ERROR, "Current client settings do not allow zooming in below level {}.", _settings_client.gui.zoom_min);
293  } else if (level > ZOOM_LVL_MAX) {
294  IConsolePrint(CC_ERROR, "Zoom-in levels above {} are not supported.", ZOOM_LVL_MAX);
295  } else if (level > _settings_client.gui.zoom_max) {
296  IConsolePrint(CC_ERROR, "Current client settings do not allow zooming out beyond level {}.", _settings_client.gui.zoom_max);
297  } else {
299  Viewport *vp = w->viewport;
300  while (vp->zoom > level) DoZoomInOutWindow(ZOOM_IN, w);
301  while (vp->zoom < level) DoZoomInOutWindow(ZOOM_OUT, w);
302  }
303  return true;
304  }
305  break;
306  }
307  }
308 
309  return false;
310 }
311 
321 DEF_CONSOLE_CMD(ConScrollToTile)
322 {
323  if (argc == 0) {
324  IConsolePrint(CC_HELP, "Center the screen on a given tile.");
325  IConsolePrint(CC_HELP, "Usage: 'scrollto [instant] <tile>' or 'scrollto [instant] <x> <y>'.");
326  IConsolePrint(CC_HELP, "Numbers can be either decimal (34161) or hexadecimal (0x4a5B).");
327  IConsolePrint(CC_HELP, "'instant' will immediately move and redraw viewport without smooth scrolling.");
328  return true;
329  }
330  if (argc < 2) return false;
331 
332  uint32 arg_index = 1;
333  bool instant = false;
334  if (strcmp(argv[arg_index], "instant") == 0) {
335  ++arg_index;
336  instant = true;
337  }
338 
339  switch (argc - arg_index) {
340  case 1: {
341  uint32 result;
342  if (GetArgumentInteger(&result, argv[arg_index])) {
343  if (result >= MapSize()) {
344  IConsolePrint(CC_ERROR, "Tile does not exist.");
345  return true;
346  }
347  ScrollMainWindowToTile((TileIndex)result, instant);
348  return true;
349  }
350  break;
351  }
352 
353  case 2: {
354  uint32 x, y;
355  if (GetArgumentInteger(&x, argv[arg_index]) && GetArgumentInteger(&y, argv[arg_index + 1])) {
356  if (x >= MapSizeX() || y >= MapSizeY()) {
357  IConsolePrint(CC_ERROR, "Tile does not exist.");
358  return true;
359  }
360  ScrollMainWindowToTile(TileXY(x, y), instant);
361  return true;
362  }
363  break;
364  }
365  }
366 
367  return false;
368 }
369 
376 {
377  if (argc == 0) {
378  IConsolePrint(CC_HELP, "Save the current game. Usage: 'save <filename>'.");
379  return true;
380  }
381 
382  if (argc == 2) {
383  char *filename = str_fmt("%s.sav", argv[1]);
384  IConsolePrint(CC_DEFAULT, "Saving map...");
385 
386  if (SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, SAVE_DIR) != SL_OK) {
387  IConsolePrint(CC_ERROR, "Saving map failed.");
388  } else {
389  IConsolePrint(CC_INFO, "Map successfully saved to '{}'.", filename);
390  }
391  free(filename);
392  return true;
393  }
394 
395  return false;
396 }
397 
402 DEF_CONSOLE_CMD(ConSaveConfig)
403 {
404  if (argc == 0) {
405  IConsolePrint(CC_HELP, "Saves the configuration for new games to the configuration file, typically 'openttd.cfg'.");
406  IConsolePrint(CC_HELP, "It does not save the configuration of the current game to the configuration file.");
407  return true;
408  }
409 
410  SaveToConfig();
411  IConsolePrint(CC_DEFAULT, "Saved config.");
412  return true;
413 }
414 
415 DEF_CONSOLE_CMD(ConLoad)
416 {
417  if (argc == 0) {
418  IConsolePrint(CC_HELP, "Load a game by name or index. Usage: 'load <file | number>'.");
419  return true;
420  }
421 
422  if (argc != 2) return false;
423 
424  const char *file = argv[1];
426  const FiosItem *item = _console_file_list.FindItem(file);
427  if (item != nullptr) {
428  if (GetAbstractFileType(item->type) == FT_SAVEGAME) {
430  _file_to_saveload.SetMode(item->type);
432  _file_to_saveload.SetTitle(item->title);
433  } else {
434  IConsolePrint(CC_ERROR, "'{}' is not a savegame.", file);
435  }
436  } else {
437  IConsolePrint(CC_ERROR, "'{}' cannot be found.", file);
438  }
439 
440  return true;
441 }
442 
443 
444 DEF_CONSOLE_CMD(ConRemove)
445 {
446  if (argc == 0) {
447  IConsolePrint(CC_HELP, "Remove a savegame by name or index. Usage: 'rm <file | number>'.");
448  return true;
449  }
450 
451  if (argc != 2) return false;
452 
453  const char *file = argv[1];
455  const FiosItem *item = _console_file_list.FindItem(file);
456  if (item != nullptr) {
457  if (unlink(item->name) != 0) {
458  IConsolePrint(CC_ERROR, "Failed to delete '{}'.", item->name);
459  }
460  } else {
461  IConsolePrint(CC_ERROR, "'{}' could not be found.", file);
462  }
463 
465  return true;
466 }
467 
468 
469 /* List all the files in the current dir via console */
470 DEF_CONSOLE_CMD(ConListFiles)
471 {
472  if (argc == 0) {
473  IConsolePrint(CC_HELP, "List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'.");
474  return true;
475  }
476 
478  for (uint i = 0; i < _console_file_list.size(); i++) {
479  IConsolePrint(CC_DEFAULT, "{}) {}", i, _console_file_list[i].title);
480  }
481 
482  return true;
483 }
484 
485 /* Change the dir via console */
486 DEF_CONSOLE_CMD(ConChangeDirectory)
487 {
488  if (argc == 0) {
489  IConsolePrint(CC_HELP, "Change the dir via console. Usage: 'cd <directory | number>'.");
490  return true;
491  }
492 
493  if (argc != 2) return false;
494 
495  const char *file = argv[1];
497  const FiosItem *item = _console_file_list.FindItem(file);
498  if (item != nullptr) {
499  switch (item->type) {
500  case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT:
501  FiosBrowseTo(item);
502  break;
503  default: IConsolePrint(CC_ERROR, "{}: Not a directory.", file);
504  }
505  } else {
506  IConsolePrint(CC_ERROR, "{}: No such file or directory.", file);
507  }
508 
510  return true;
511 }
512 
513 DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
514 {
515  const char *path;
516 
517  if (argc == 0) {
518  IConsolePrint(CC_HELP, "Print out the current working directory. Usage: 'pwd'.");
519  return true;
520  }
521 
522  /* XXX - Workaround for broken file handling */
525 
526  FiosGetDescText(&path, nullptr);
527  IConsolePrint(CC_DEFAULT, path);
528  return true;
529 }
530 
531 DEF_CONSOLE_CMD(ConClearBuffer)
532 {
533  if (argc == 0) {
534  IConsolePrint(CC_HELP, "Clear the console buffer. Usage: 'clear'.");
535  return true;
536  }
537 
538  IConsoleClearBuffer();
540  return true;
541 }
542 
543 
544 /**********************************
545  * Network Core Console Commands
546  **********************************/
547 
548 static bool ConKickOrBan(const char *argv, bool ban, const std::string &reason)
549 {
550  uint n;
551 
552  if (strchr(argv, '.') == nullptr && strchr(argv, ':') == nullptr) { // banning with ID
553  ClientID client_id = (ClientID)atoi(argv);
554 
555  /* Don't kill the server, or the client doing the rcon. The latter can't be kicked because
556  * kicking frees closes and subsequently free the connection related instances, which we
557  * would be reading from and writing to after returning. So we would read or write data
558  * from freed memory up till the segfault triggers. */
559  if (client_id == CLIENT_ID_SERVER || client_id == _redirect_console_to_client) {
560  IConsolePrint(CC_ERROR, "You can not {} yourself!", ban ? "ban" : "kick");
561  return true;
562  }
563 
565  if (ci == nullptr) {
566  IConsolePrint(CC_ERROR, "Invalid client ID.");
567  return true;
568  }
569 
570  if (!ban) {
571  /* Kick only this client, not all clients with that IP */
572  NetworkServerKickClient(client_id, reason);
573  return true;
574  }
575 
576  /* When banning, kick+ban all clients with that IP */
577  n = NetworkServerKickOrBanIP(client_id, ban, reason);
578  } else {
579  n = NetworkServerKickOrBanIP(argv, ban, reason);
580  }
581 
582  if (n == 0) {
583  IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist." : "Client not found.");
584  } else {
585  IConsolePrint(CC_DEFAULT, "{}ed {} client(s).", ban ? "Bann" : "Kick", n);
586  }
587 
588  return true;
589 }
590 
591 DEF_CONSOLE_CMD(ConKick)
592 {
593  if (argc == 0) {
594  IConsolePrint(CC_HELP, "Kick a client from a network game. Usage: 'kick <ip | client-id> [<kick-reason>]'.");
595  IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
596  return true;
597  }
598 
599  if (argc != 2 && argc != 3) return false;
600 
601  /* No reason supplied for kicking */
602  if (argc == 2) return ConKickOrBan(argv[1], false, {});
603 
604  /* Reason for kicking supplied */
605  size_t kick_message_length = strlen(argv[2]);
606  if (kick_message_length >= 255) {
607  IConsolePrint(CC_ERROR, "Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length);
608  return false;
609  } else {
610  return ConKickOrBan(argv[1], false, argv[2]);
611  }
612 }
613 
614 DEF_CONSOLE_CMD(ConBan)
615 {
616  if (argc == 0) {
617  IConsolePrint(CC_HELP, "Ban a client from a network game. Usage: 'ban <ip | client-id> [<ban-reason>]'.");
618  IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
619  IConsolePrint(CC_HELP, "If the client is no longer online, you can still ban their IP.");
620  return true;
621  }
622 
623  if (argc != 2 && argc != 3) return false;
624 
625  /* No reason supplied for kicking */
626  if (argc == 2) return ConKickOrBan(argv[1], true, {});
627 
628  /* Reason for kicking supplied */
629  size_t kick_message_length = strlen(argv[2]);
630  if (kick_message_length >= 255) {
631  IConsolePrint(CC_ERROR, "Maximum kick message length is 254 characters. You entered {} characters.", kick_message_length);
632  return false;
633  } else {
634  return ConKickOrBan(argv[1], true, argv[2]);
635  }
636 }
637 
638 DEF_CONSOLE_CMD(ConUnBan)
639 {
640  if (argc == 0) {
641  IConsolePrint(CC_HELP, "Unban a client from a network game. Usage: 'unban <ip | banlist-index>'.");
642  IConsolePrint(CC_HELP, "For a list of banned IP's, see the command 'banlist'.");
643  return true;
644  }
645 
646  if (argc != 2) return false;
647 
648  /* Try by IP. */
649  uint index;
650  for (index = 0; index < _network_ban_list.size(); index++) {
651  if (_network_ban_list[index] == argv[1]) break;
652  }
653 
654  /* Try by index. */
655  if (index >= _network_ban_list.size()) {
656  index = atoi(argv[1]) - 1U; // let it wrap
657  }
658 
659  if (index < _network_ban_list.size()) {
660  IConsolePrint(CC_DEFAULT, "Unbanned {}.", _network_ban_list[index]);
661  _network_ban_list.erase(_network_ban_list.begin() + index);
662  } else {
663  IConsolePrint(CC_DEFAULT, "Invalid list index or IP not in ban-list.");
664  IConsolePrint(CC_DEFAULT, "For a list of banned IP's, see the command 'banlist'.");
665  }
666 
667  return true;
668 }
669 
670 DEF_CONSOLE_CMD(ConBanList)
671 {
672  if (argc == 0) {
673  IConsolePrint(CC_HELP, "List the IP's of banned clients: Usage 'banlist'.");
674  return true;
675  }
676 
677  IConsolePrint(CC_DEFAULT, "Banlist:");
678 
679  uint i = 1;
680  for (const auto &entry : _network_ban_list) {
681  IConsolePrint(CC_DEFAULT, " {}) {}", i, entry);
682  i++;
683  }
684 
685  return true;
686 }
687 
688 DEF_CONSOLE_CMD(ConPauseGame)
689 {
690  if (argc == 0) {
691  IConsolePrint(CC_HELP, "Pause a network game. Usage: 'pause'.");
692  return true;
693  }
694 
695  if (_game_mode == GM_MENU) {
696  IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor.");
697  return true;
698  }
699 
702  if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused.");
703  } else {
704  IConsolePrint(CC_DEFAULT, "Game is already paused.");
705  }
706 
707  return true;
708 }
709 
710 DEF_CONSOLE_CMD(ConUnpauseGame)
711 {
712  if (argc == 0) {
713  IConsolePrint(CC_HELP, "Unpause a network game. Usage: 'unpause'.");
714  return true;
715  }
716 
717  if (_game_mode == GM_MENU) {
718  IConsolePrint(CC_ERROR, "This command is only available in-game and in the editor.");
719  return true;
720  }
721 
724  if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused.");
725  } else if ((_pause_mode & PM_PAUSED_ERROR) != PM_UNPAUSED) {
726  IConsolePrint(CC_DEFAULT, "Game is in error state and cannot be unpaused via console.");
727  } else if (_pause_mode != PM_UNPAUSED) {
728  IConsolePrint(CC_DEFAULT, "Game cannot be unpaused manually; disable pause_on_join/min_active_clients.");
729  } else {
730  IConsolePrint(CC_DEFAULT, "Game is already unpaused.");
731  }
732 
733  return true;
734 }
735 
736 DEF_CONSOLE_CMD(ConRcon)
737 {
738  if (argc == 0) {
739  IConsolePrint(CC_HELP, "Remote control the server from another client. Usage: 'rcon <password> <command>'.");
740  IConsolePrint(CC_HELP, "Remember to enclose the command in quotes, otherwise only the first parameter is sent.");
741  return true;
742  }
743 
744  if (argc < 3) return false;
745 
746  if (_network_server) {
747  IConsoleCmdExec(argv[2]);
748  } else {
749  NetworkClientSendRcon(argv[1], argv[2]);
750  }
751  return true;
752 }
753 
754 DEF_CONSOLE_CMD(ConStatus)
755 {
756  if (argc == 0) {
757  IConsolePrint(CC_HELP, "List the status of all clients connected to the server. Usage 'status'.");
758  return true;
759  }
760 
762  return true;
763 }
764 
765 DEF_CONSOLE_CMD(ConServerInfo)
766 {
767  if (argc == 0) {
768  IConsolePrint(CC_HELP, "List current and maximum client/company limits. Usage 'server_info'.");
769  IConsolePrint(CC_HELP, "You can change these values by modifying settings 'network.max_clients' and 'network.max_companies'.");
770  return true;
771  }
772 
774  IConsolePrint(CC_DEFAULT, "Current/maximum clients: {:3d}/{:3d}", _network_game_info.clients_on, _settings_client.network.max_clients);
775  IConsolePrint(CC_DEFAULT, "Current/maximum companies: {:3d}/{:3d}", Company::GetNumItems(), _settings_client.network.max_companies);
776  IConsolePrint(CC_DEFAULT, "Current spectators: {:3d}", NetworkSpectatorCount());
777 
778  return true;
779 }
780 
781 DEF_CONSOLE_CMD(ConClientNickChange)
782 {
783  if (argc != 3) {
784  IConsolePrint(CC_HELP, "Change the nickname of a connected client. Usage: 'client_name <client-id> <new-name>'.");
785  IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
786  return true;
787  }
788 
789  ClientID client_id = (ClientID)atoi(argv[1]);
790 
791  if (client_id == CLIENT_ID_SERVER) {
792  IConsolePrint(CC_ERROR, "Please use the command 'name' to change your own name!");
793  return true;
794  }
795 
796  if (NetworkClientInfo::GetByClientID(client_id) == nullptr) {
797  IConsolePrint(CC_ERROR, "Invalid client ID.");
798  return true;
799  }
800 
801  std::string client_name(argv[2]);
802  StrTrimInPlace(client_name);
803  if (!NetworkIsValidClientName(client_name)) {
804  IConsolePrint(CC_ERROR, "Cannot give a client an empty name.");
805  return true;
806  }
807 
808  if (!NetworkServerChangeClientName(client_id, client_name)) {
809  IConsolePrint(CC_ERROR, "Cannot give a client a duplicate name.");
810  }
811 
812  return true;
813 }
814 
815 DEF_CONSOLE_CMD(ConJoinCompany)
816 {
817  if (argc < 2) {
818  IConsolePrint(CC_HELP, "Request joining another company. Usage: 'join <company-id> [<password>]'.");
819  IConsolePrint(CC_HELP, "For valid company-id see company list, use 255 for spectator.");
820  return true;
821  }
822 
823  CompanyID company_id = (CompanyID)(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));
824 
825  /* Check we have a valid company id! */
826  if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
827  IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES);
828  return true;
829  }
830 
831  if (NetworkClientInfo::GetByClientID(_network_own_client_id)->client_playas == company_id) {
832  IConsolePrint(CC_ERROR, "You are already there!");
833  return true;
834  }
835 
836  if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
837  IConsolePrint(CC_ERROR, "Cannot join AI company.");
838  return true;
839  }
840 
841  /* Check if the company requires a password */
842  if (NetworkCompanyIsPassworded(company_id) && argc < 3) {
843  IConsolePrint(CC_ERROR, "Company {} requires a password to join.", company_id + 1);
844  return true;
845  }
846 
847  /* non-dedicated server may just do the move! */
848  if (_network_server) {
850  } else {
851  NetworkClientRequestMove(company_id, NetworkCompanyIsPassworded(company_id) ? argv[2] : "");
852  }
853 
854  return true;
855 }
856 
857 DEF_CONSOLE_CMD(ConMoveClient)
858 {
859  if (argc < 3) {
860  IConsolePrint(CC_HELP, "Move a client to another company. Usage: 'move <client-id> <company-id>'.");
861  IConsolePrint(CC_HELP, "For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators.");
862  return true;
863  }
864 
865  const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID((ClientID)atoi(argv[1]));
866  CompanyID company_id = (CompanyID)(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
867 
868  /* check the client exists */
869  if (ci == nullptr) {
870  IConsolePrint(CC_ERROR, "Invalid client-id, check the command 'clients' for valid client-id's.");
871  return true;
872  }
873 
874  if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
875  IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES);
876  return true;
877  }
878 
879  if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
880  IConsolePrint(CC_ERROR, "You cannot move clients to AI companies.");
881  return true;
882  }
883 
885  IConsolePrint(CC_ERROR, "You cannot move the server!");
886  return true;
887  }
888 
889  if (ci->client_playas == company_id) {
890  IConsolePrint(CC_ERROR, "You cannot move someone to where they already are!");
891  return true;
892  }
893 
894  /* we are the server, so force the update */
895  NetworkServerDoMove(ci->client_id, company_id);
896 
897  return true;
898 }
899 
900 DEF_CONSOLE_CMD(ConResetCompany)
901 {
902  if (argc == 0) {
903  IConsolePrint(CC_HELP, "Remove an idle company from the game. Usage: 'reset_company <company-id>'.");
904  IConsolePrint(CC_HELP, "For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
905  return true;
906  }
907 
908  if (argc != 2) return false;
909 
910  CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
911 
912  /* Check valid range */
913  if (!Company::IsValidID(index)) {
914  IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES);
915  return true;
916  }
917 
918  if (!Company::IsHumanID(index)) {
919  IConsolePrint(CC_ERROR, "Company is owned by an AI.");
920  return true;
921  }
922 
923  if (NetworkCompanyHasClients(index)) {
924  IConsolePrint(CC_ERROR, "Cannot remove company: a client is connected to that company.");
925  return false;
926  }
928  if (ci->client_playas == index) {
929  IConsolePrint(CC_ERROR, "Cannot remove company: the server is connected to that company.");
930  return true;
931  }
932 
933  /* It is safe to remove this company */
935  IConsolePrint(CC_DEFAULT, "Company deleted.");
936 
937  return true;
938 }
939 
940 DEF_CONSOLE_CMD(ConNetworkClients)
941 {
942  if (argc == 0) {
943  IConsolePrint(CC_HELP, "Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'.");
944  return true;
945  }
946 
948 
949  return true;
950 }
951 
952 DEF_CONSOLE_CMD(ConNetworkReconnect)
953 {
954  if (argc == 0) {
955  IConsolePrint(CC_HELP, "Reconnect to server to which you were connected last time. Usage: 'reconnect [<company>]'.");
956  IConsolePrint(CC_HELP, "Company 255 is spectator (default, if not specified), 0 means creating new company.");
957  IConsolePrint(CC_HELP, "All others are a certain company with Company 1 being #1.");
958  return true;
959  }
960 
961  CompanyID playas = (argc >= 2) ? (CompanyID)atoi(argv[1]) : COMPANY_SPECTATOR;
962  switch (playas) {
963  case 0: playas = COMPANY_NEW_COMPANY; break;
964  case COMPANY_SPECTATOR: /* nothing to do */ break;
965  default:
966  /* From a user pov 0 is a new company, internally it's different and all
967  * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
968  if (playas < COMPANY_FIRST + 1 || playas > MAX_COMPANIES + 1) return false;
969  break;
970  }
971 
972  if (_settings_client.network.last_joined.empty()) {
973  IConsolePrint(CC_DEFAULT, "No server for reconnecting.");
974  return true;
975  }
976 
977  /* Don't resolve the address first, just print it directly as it comes from the config file. */
978  IConsolePrint(CC_DEFAULT, "Reconnecting to {} ...", _settings_client.network.last_joined);
979 
981 }
982 
983 DEF_CONSOLE_CMD(ConNetworkConnect)
984 {
985  if (argc == 0) {
986  IConsolePrint(CC_HELP, "Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'.");
987  IConsolePrint(CC_HELP, "IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'.");
988  IConsolePrint(CC_HELP, "Company #255 is spectator all others are a certain company with Company 1 being #1.");
989  return true;
990  }
991 
992  if (argc < 2) return false;
993 
995 }
996 
997 /*********************************
998  * script file console commands
999  *********************************/
1000 
1001 DEF_CONSOLE_CMD(ConExec)
1002 {
1003  if (argc == 0) {
1004  IConsolePrint(CC_HELP, "Execute a local script file. Usage: 'exec <script> <?>'.");
1005  return true;
1006  }
1007 
1008  if (argc < 2) return false;
1009 
1010  FILE *script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
1011 
1012  if (script_file == nullptr) {
1013  if (argc == 2 || atoi(argv[2]) != 0) IConsolePrint(CC_ERROR, "Script file '{}' not found.", argv[1]);
1014  return true;
1015  }
1016 
1017  if (_script_current_depth == 11) {
1018  FioFCloseFile(script_file);
1019  IConsolePrint(CC_ERROR, "Maximum 'exec' depth reached; script A is calling script B is calling script C ... more than 10 times.");
1020  return true;
1021  }
1022 
1024  uint script_depth = _script_current_depth;
1025 
1026  char cmdline[ICON_CMDLN_SIZE];
1027  while (fgets(cmdline, sizeof(cmdline), script_file) != nullptr) {
1028  /* Remove newline characters from the executing script */
1029  for (char *cmdptr = cmdline; *cmdptr != '\0'; cmdptr++) {
1030  if (*cmdptr == '\n' || *cmdptr == '\r') {
1031  *cmdptr = '\0';
1032  break;
1033  }
1034  }
1035  IConsoleCmdExec(cmdline);
1036  /* Ensure that we are still on the same depth or that we returned via 'return'. */
1037  assert(_script_current_depth == script_depth || _script_current_depth == script_depth - 1);
1038 
1039  /* The 'return' command was executed. */
1040  if (_script_current_depth == script_depth - 1) break;
1041  }
1042 
1043  if (ferror(script_file)) {
1044  IConsolePrint(CC_ERROR, "Encountered error while trying to read from script file '{}'.", argv[1]);
1045  }
1046 
1047  if (_script_current_depth == script_depth) _script_current_depth--;
1048  FioFCloseFile(script_file);
1049  return true;
1050 }
1051 
1052 DEF_CONSOLE_CMD(ConReturn)
1053 {
1054  if (argc == 0) {
1055  IConsolePrint(CC_HELP, "Stop executing a running script. Usage: 'return'.");
1056  return true;
1057  }
1058 
1060  return true;
1061 }
1062 
1063 /*****************************
1064  * default console commands
1065  ******************************/
1066 extern bool CloseConsoleLogIfActive();
1067 
1068 DEF_CONSOLE_CMD(ConScript)
1069 {
1070  extern FILE *_iconsole_output_file;
1071 
1072  if (argc == 0) {
1073  IConsolePrint(CC_HELP, "Start or stop logging console output to a file. Usage: 'script <filename>'.");
1074  IConsolePrint(CC_HELP, "If filename is omitted, a running log is stopped if it is active.");
1075  return true;
1076  }
1077 
1078  if (!CloseConsoleLogIfActive()) {
1079  if (argc < 2) return false;
1080 
1081  _iconsole_output_file = fopen(argv[1], "ab");
1082  if (_iconsole_output_file == nullptr) {
1083  IConsolePrint(CC_ERROR, "Could not open console log file '{}'.", argv[1]);
1084  } else {
1085  IConsolePrint(CC_INFO, "Console log output started to '{}'.", argv[1]);
1086  }
1087  }
1088 
1089  return true;
1090 }
1091 
1092 
1093 DEF_CONSOLE_CMD(ConEcho)
1094 {
1095  if (argc == 0) {
1096  IConsolePrint(CC_HELP, "Print back the first argument to the console. Usage: 'echo <arg>'.");
1097  return true;
1098  }
1099 
1100  if (argc < 2) return false;
1101  IConsolePrint(CC_DEFAULT, argv[1]);
1102  return true;
1103 }
1104 
1105 DEF_CONSOLE_CMD(ConEchoC)
1106 {
1107  if (argc == 0) {
1108  IConsolePrint(CC_HELP, "Print back the first argument to the console in a given colour. Usage: 'echoc <colour> <arg2>'.");
1109  return true;
1110  }
1111 
1112  if (argc < 3) return false;
1113  IConsolePrint((TextColour)Clamp(atoi(argv[1]), TC_BEGIN, TC_END - 1), argv[2]);
1114  return true;
1115 }
1116 
1117 DEF_CONSOLE_CMD(ConNewGame)
1118 {
1119  if (argc == 0) {
1120  IConsolePrint(CC_HELP, "Start a new game. Usage: 'newgame [seed]'.");
1121  IConsolePrint(CC_HELP, "The server can force a new game using 'newgame'; any client joined will rejoin after the server is done generating the new game.");
1122  return true;
1123  }
1124 
1125  StartNewGameWithoutGUI((argc == 2) ? strtoul(argv[1], nullptr, 10) : GENERATE_NEW_SEED);
1126  return true;
1127 }
1128 
1129 DEF_CONSOLE_CMD(ConRestart)
1130 {
1131  if (argc == 0) {
1132  IConsolePrint(CC_HELP, "Restart game. Usage: 'restart'.");
1133  IConsolePrint(CC_HELP, "Restarts a game. It tries to reproduce the exact same map as the game started with.");
1134  IConsolePrint(CC_HELP, "However:");
1135  IConsolePrint(CC_HELP, " * restarting games started in another version might create another map due to difference in map generation.");
1136  IConsolePrint(CC_HELP, " * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame.");
1137  return true;
1138  }
1139 
1140  /* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
1144  return true;
1145 }
1146 
1147 DEF_CONSOLE_CMD(ConReload)
1148 {
1149  if (argc == 0) {
1150  IConsolePrint(CC_HELP, "Reload game. Usage: 'reload'.");
1151  IConsolePrint(CC_HELP, "Reloads a game.");
1152  IConsolePrint(CC_HELP, " * if you started from a savegame / scenario / heightmap, that exact same savegame / scenario / heightmap will be loaded.");
1153  IConsolePrint(CC_HELP, " * if you started from a new game, this acts the same as 'restart'.");
1154  return true;
1155  }
1156 
1157  /* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
1161  return true;
1162 }
1163 
1168 static void PrintLineByLine(const std::string &full_string)
1169 {
1170  std::istringstream in(full_string);
1171  std::string line;
1172  while (std::getline(in, line)) {
1173  IConsolePrint(CC_DEFAULT, line.c_str());
1174  }
1175 }
1176 
1177 DEF_CONSOLE_CMD(ConListAILibs)
1178 {
1179  if (argc == 0) {
1180  IConsolePrint(CC_HELP, "List installed AI libraries. Usage: 'list_ai_libs'.");
1181  return true;
1182  }
1183 
1184  const std::string output_str = AI::GetConsoleLibraryList();
1185  PrintLineByLine(output_str);
1186 
1187  return true;
1188 }
1189 
1190 DEF_CONSOLE_CMD(ConListAI)
1191 {
1192  if (argc == 0) {
1193  IConsolePrint(CC_HELP, "List installed AIs. Usage: 'list_ai'.");
1194  return true;
1195  }
1196 
1197  const std::string output_str = AI::GetConsoleList();
1198  PrintLineByLine(output_str);
1199 
1200  return true;
1201 }
1202 
1203 DEF_CONSOLE_CMD(ConListGameLibs)
1204 {
1205  if (argc == 0) {
1206  IConsolePrint(CC_HELP, "List installed Game Script libraries. Usage: 'list_game_libs'.");
1207  return true;
1208  }
1209 
1210  const std::string output_str = Game::GetConsoleLibraryList();
1211  PrintLineByLine(output_str);
1212 
1213  return true;
1214 }
1215 
1216 DEF_CONSOLE_CMD(ConListGame)
1217 {
1218  if (argc == 0) {
1219  IConsolePrint(CC_HELP, "List installed Game Scripts. Usage: 'list_game'.");
1220  return true;
1221  }
1222 
1223  const std::string output_str = Game::GetConsoleList();
1224  PrintLineByLine(output_str);
1225 
1226  return true;
1227 }
1228 
1229 DEF_CONSOLE_CMD(ConStartAI)
1230 {
1231  if (argc == 0 || argc > 3) {
1232  IConsolePrint(CC_HELP, "Start a new AI. Usage: 'start_ai [<AI>] [<settings>]'.");
1233  IConsolePrint(CC_HELP, "Start a new AI. If <AI> is given, it starts that specific AI (if found).");
1234  IConsolePrint(CC_HELP, "If <settings> is given, it is parsed and the AI settings are set to that.");
1235  return true;
1236  }
1237 
1238  if (_game_mode != GM_NORMAL) {
1239  IConsolePrint(CC_ERROR, "AIs can only be managed in a game.");
1240  return true;
1241  }
1242 
1244  IConsolePrint(CC_ERROR, "Can't start a new AI (no more free slots).");
1245  return true;
1246  }
1247  if (_networking && !_network_server) {
1248  IConsolePrint(CC_ERROR, "Only the server can start a new AI.");
1249  return true;
1250  }
1252  IConsolePrint(CC_ERROR, "AIs are not allowed in multiplayer by configuration.");
1253  IConsolePrint(CC_ERROR, "Switch AI -> AI in multiplayer to True.");
1254  return true;
1255  }
1256  if (!AI::CanStartNew()) {
1257  IConsolePrint(CC_ERROR, "Can't start a new AI.");
1258  return true;
1259  }
1260 
1261  int n = 0;
1262  /* Find the next free slot */
1263  for (const Company *c : Company::Iterate()) {
1264  if (c->index != n) break;
1265  n++;
1266  }
1267 
1268  AIConfig *config = AIConfig::GetConfig((CompanyID)n);
1269  if (argc >= 2) {
1270  config->Change(argv[1], -1, false);
1271 
1272  /* If the name is not found, and there is a dot in the name,
1273  * try again with the assumption everything right of the dot is
1274  * the version the user wants to load. */
1275  if (!config->HasScript()) {
1276  char *name = stredup(argv[1]);
1277  char *e = strrchr(name, '.');
1278  if (e != nullptr) {
1279  *e = '\0';
1280  e++;
1281 
1282  int version = atoi(e);
1283  config->Change(name, version, true);
1284  }
1285  free(name);
1286  }
1287 
1288  if (!config->HasScript()) {
1289  IConsolePrint(CC_ERROR, "Failed to load the specified AI.");
1290  return true;
1291  }
1292  if (argc == 3) {
1293  config->StringToSettings(argv[2]);
1294  }
1295  }
1296 
1297  /* Start a new AI company */
1299 
1300  return true;
1301 }
1302 
1303 DEF_CONSOLE_CMD(ConReloadAI)
1304 {
1305  if (argc != 2) {
1306  IConsolePrint(CC_HELP, "Reload an AI. Usage: 'reload_ai <company-id>'.");
1307  IConsolePrint(CC_HELP, "Reload the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
1308  return true;
1309  }
1310 
1311  if (_game_mode != GM_NORMAL) {
1312  IConsolePrint(CC_ERROR, "AIs can only be managed in a game.");
1313  return true;
1314  }
1315 
1316  if (_networking && !_network_server) {
1317  IConsolePrint(CC_ERROR, "Only the server can reload an AI.");
1318  return true;
1319  }
1320 
1321  CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
1322  if (!Company::IsValidID(company_id)) {
1323  IConsolePrint(CC_ERROR, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
1324  return true;
1325  }
1326 
1327  /* In singleplayer mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
1328  if (Company::IsHumanID(company_id) || company_id == _local_company) {
1329  IConsolePrint(CC_ERROR, "Company is not controlled by an AI.");
1330  return true;
1331  }
1332 
1333  /* First kill the company of the AI, then start a new one. This should start the current AI again */
1336  IConsolePrint(CC_DEFAULT, "AI reloaded.");
1337 
1338  return true;
1339 }
1340 
1341 DEF_CONSOLE_CMD(ConStopAI)
1342 {
1343  if (argc != 2) {
1344  IConsolePrint(CC_HELP, "Stop an AI. Usage: 'stop_ai <company-id>'.");
1345  IConsolePrint(CC_HELP, "Stop the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
1346  return true;
1347  }
1348 
1349  if (_game_mode != GM_NORMAL) {
1350  IConsolePrint(CC_ERROR, "AIs can only be managed in a game.");
1351  return true;
1352  }
1353 
1354  if (_networking && !_network_server) {
1355  IConsolePrint(CC_ERROR, "Only the server can stop an AI.");
1356  return true;
1357  }
1358 
1359  CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
1360  if (!Company::IsValidID(company_id)) {
1361  IConsolePrint(CC_ERROR, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
1362  return true;
1363  }
1364 
1365  /* In singleplayer mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
1366  if (Company::IsHumanID(company_id) || company_id == _local_company) {
1367  IConsolePrint(CC_ERROR, "Company is not controlled by an AI.");
1368  return true;
1369  }
1370 
1371  /* Now kill the company of the AI. */
1373  IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
1374 
1375  return true;
1376 }
1377 
1378 DEF_CONSOLE_CMD(ConRescanAI)
1379 {
1380  if (argc == 0) {
1381  IConsolePrint(CC_HELP, "Rescan the AI dir for scripts. Usage: 'rescan_ai'.");
1382  return true;
1383  }
1384 
1385  if (_networking && !_network_server) {
1386  IConsolePrint(CC_ERROR, "Only the server can rescan the AI dir for scripts.");
1387  return true;
1388  }
1389 
1390  AI::Rescan();
1391 
1392  return true;
1393 }
1394 
1395 DEF_CONSOLE_CMD(ConRescanGame)
1396 {
1397  if (argc == 0) {
1398  IConsolePrint(CC_HELP, "Rescan the Game Script dir for scripts. Usage: 'rescan_game'.");
1399  return true;
1400  }
1401 
1402  if (_networking && !_network_server) {
1403  IConsolePrint(CC_ERROR, "Only the server can rescan the Game Script dir for scripts.");
1404  return true;
1405  }
1406 
1407  Game::Rescan();
1408 
1409  return true;
1410 }
1411 
1412 DEF_CONSOLE_CMD(ConRescanNewGRF)
1413 {
1414  if (argc == 0) {
1415  IConsolePrint(CC_HELP, "Rescan the data dir for NewGRFs. Usage: 'rescan_newgrf'.");
1416  return true;
1417  }
1418 
1419  if (!RequestNewGRFScan()) {
1420  IConsolePrint(CC_ERROR, "NewGRF scanning is already running. Please wait until completed to run again.");
1421  }
1422 
1423  return true;
1424 }
1425 
1426 DEF_CONSOLE_CMD(ConGetSeed)
1427 {
1428  if (argc == 0) {
1429  IConsolePrint(CC_HELP, "Returns the seed used to create this game. Usage: 'getseed'.");
1430  IConsolePrint(CC_HELP, "The seed can be used to reproduce the exact same map as the game started with.");
1431  return true;
1432  }
1433 
1435  return true;
1436 }
1437 
1438 DEF_CONSOLE_CMD(ConGetDate)
1439 {
1440  if (argc == 0) {
1441  IConsolePrint(CC_HELP, "Returns the current date (year-month-day) of the game. Usage: 'getdate'.");
1442  return true;
1443  }
1444 
1445  YearMonthDay ymd;
1446  ConvertDateToYMD(_date, &ymd);
1447  IConsolePrint(CC_DEFAULT, "Date: {:04d}-{:02d}-{:02d}", ymd.year, ymd.month + 1, ymd.day);
1448  return true;
1449 }
1450 
1451 DEF_CONSOLE_CMD(ConGetSysDate)
1452 {
1453  if (argc == 0) {
1454  IConsolePrint(CC_HELP, "Returns the current date (year-month-day) of your system. Usage: 'getsysdate'.");
1455  return true;
1456  }
1457 
1458  char buffer[lengthof("2000-01-02 03:04:05")];
1459  LocalTime::Format(buffer, lastof(buffer), "%Y-%m-%d %H:%M:%S");
1460  IConsolePrint(CC_DEFAULT, "System Date: {}", buffer);
1461  return true;
1462 }
1463 
1464 
1465 DEF_CONSOLE_CMD(ConAlias)
1466 {
1467  IConsoleAlias *alias;
1468 
1469  if (argc == 0) {
1470  IConsolePrint(CC_HELP, "Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'.");
1471  return true;
1472  }
1473 
1474  if (argc < 3) return false;
1475 
1476  alias = IConsole::AliasGet(argv[1]);
1477  if (alias == nullptr) {
1478  IConsole::AliasRegister(argv[1], argv[2]);
1479  } else {
1480  alias->cmdline = argv[2];
1481  }
1482  return true;
1483 }
1484 
1485 DEF_CONSOLE_CMD(ConScreenShot)
1486 {
1487  if (argc == 0) {
1488  IConsolePrint(CC_HELP, "Create a screenshot of the game. Usage: 'screenshot [viewport | normal | big | giant | heightmap | minimap] [no_con] [size <width> <height>] [<filename>]'.");
1489  IConsolePrint(CC_HELP, " 'viewport' (default) makes a screenshot of the current viewport (including menus, windows).");
1490  IConsolePrint(CC_HELP, " 'normal' makes a screenshot of the visible area.");
1491  IConsolePrint(CC_HELP, " 'big' makes a zoomed-in screenshot of the visible area.");
1492  IConsolePrint(CC_HELP, " 'giant' makes a screenshot of the whole map.");
1493  IConsolePrint(CC_HELP, " 'heightmap' makes a heightmap screenshot of the map that can be loaded in as heightmap.");
1494  IConsolePrint(CC_HELP, " 'minimap' makes a top-viewed minimap screenshot of the whole world which represents one tile by one pixel.");
1495  IConsolePrint(CC_HELP, " 'no_con' hides the console to create the screenshot (only useful in combination with 'viewport').");
1496  IConsolePrint(CC_HELP, " 'size' sets the width and height of the viewport to make a screenshot of (only useful in combination with 'normal' or 'big').");
1497  IConsolePrint(CC_HELP, " A filename ending in # will prevent overwriting existing files and will number files counting upwards.");
1498  return true;
1499  }
1500 
1501  if (argc > 7) return false;
1502 
1503  ScreenshotType type = SC_VIEWPORT;
1504  uint32 width = 0;
1505  uint32 height = 0;
1506  std::string name{};
1507  uint32 arg_index = 1;
1508 
1509  if (argc > arg_index) {
1510  if (strcmp(argv[arg_index], "viewport") == 0) {
1511  type = SC_VIEWPORT;
1512  arg_index += 1;
1513  } else if (strcmp(argv[arg_index], "normal") == 0) {
1514  type = SC_DEFAULTZOOM;
1515  arg_index += 1;
1516  } else if (strcmp(argv[arg_index], "big") == 0) {
1517  type = SC_ZOOMEDIN;
1518  arg_index += 1;
1519  } else if (strcmp(argv[arg_index], "giant") == 0) {
1520  type = SC_WORLD;
1521  arg_index += 1;
1522  } else if (strcmp(argv[arg_index], "heightmap") == 0) {
1523  type = SC_HEIGHTMAP;
1524  arg_index += 1;
1525  } else if (strcmp(argv[arg_index], "minimap") == 0) {
1526  type = SC_MINIMAP;
1527  arg_index += 1;
1528  }
1529  }
1530 
1531  if (argc > arg_index && strcmp(argv[arg_index], "no_con") == 0) {
1532  if (type != SC_VIEWPORT) {
1533  IConsolePrint(CC_ERROR, "'no_con' can only be used in combination with 'viewport'.");
1534  return true;
1535  }
1536  IConsoleClose();
1537  arg_index += 1;
1538  }
1539 
1540  if (argc > arg_index + 2 && strcmp(argv[arg_index], "size") == 0) {
1541  /* size <width> <height> */
1542  if (type != SC_DEFAULTZOOM && type != SC_ZOOMEDIN) {
1543  IConsolePrint(CC_ERROR, "'size' can only be used in combination with 'normal' or 'big'.");
1544  return true;
1545  }
1546  GetArgumentInteger(&width, argv[arg_index + 1]);
1547  GetArgumentInteger(&height, argv[arg_index + 2]);
1548  arg_index += 3;
1549  }
1550 
1551  if (argc > arg_index) {
1552  /* Last parameter that was not one of the keywords must be the filename. */
1553  name = argv[arg_index];
1554  arg_index += 1;
1555  }
1556 
1557  if (argc > arg_index) {
1558  /* We have parameters we did not process; means we misunderstood any of the above. */
1559  return false;
1560  }
1561 
1562  MakeScreenshot(type, name, width, height);
1563  return true;
1564 }
1565 
1566 DEF_CONSOLE_CMD(ConInfoCmd)
1567 {
1568  if (argc == 0) {
1569  IConsolePrint(CC_HELP, "Print out debugging information about a command. Usage: 'info_cmd <cmd>'.");
1570  return true;
1571  }
1572 
1573  if (argc < 2) return false;
1574 
1575  const IConsoleCmd *cmd = IConsole::CmdGet(argv[1]);
1576  if (cmd == nullptr) {
1577  IConsolePrint(CC_ERROR, "The given command was not found.");
1578  return true;
1579  }
1580 
1581  IConsolePrint(CC_DEFAULT, "Command name: '{}'", cmd->name);
1582 
1583  if (cmd->hook != nullptr) IConsolePrint(CC_DEFAULT, "Command is hooked.");
1584 
1585  return true;
1586 }
1587 
1588 DEF_CONSOLE_CMD(ConDebugLevel)
1589 {
1590  if (argc == 0) {
1591  IConsolePrint(CC_HELP, "Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'.");
1592  IConsolePrint(CC_HELP, "Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'\"s.");
1593  return true;
1594  }
1595 
1596  if (argc > 2) return false;
1597 
1598  if (argc == 1) {
1599  IConsolePrint(CC_DEFAULT, "Current debug-level: '{}'", GetDebugString());
1600  } else {
1601  SetDebugString(argv[1], [](const char *err) { IConsolePrint(CC_ERROR, std::string(err)); });
1602  }
1603 
1604  return true;
1605 }
1606 
1607 DEF_CONSOLE_CMD(ConExit)
1608 {
1609  if (argc == 0) {
1610  IConsolePrint(CC_HELP, "Exit the game. Usage: 'exit'.");
1611  return true;
1612  }
1613 
1614  if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave();
1615 
1616  _exit_game = true;
1617  return true;
1618 }
1619 
1620 DEF_CONSOLE_CMD(ConPart)
1621 {
1622  if (argc == 0) {
1623  IConsolePrint(CC_HELP, "Leave the currently joined/running game (only ingame). Usage: 'part'.");
1624  return true;
1625  }
1626 
1627  if (_game_mode != GM_NORMAL) return false;
1628 
1630  return true;
1631 }
1632 
1633 DEF_CONSOLE_CMD(ConHelp)
1634 {
1635  if (argc == 2) {
1636  const IConsoleCmd *cmd;
1637  const IConsoleAlias *alias;
1638 
1639  cmd = IConsole::CmdGet(argv[1]);
1640  if (cmd != nullptr) {
1641  cmd->proc(0, nullptr);
1642  return true;
1643  }
1644 
1645  alias = IConsole::AliasGet(argv[1]);
1646  if (alias != nullptr) {
1647  cmd = IConsole::CmdGet(alias->cmdline);
1648  if (cmd != nullptr) {
1649  cmd->proc(0, nullptr);
1650  return true;
1651  }
1652  IConsolePrint(CC_ERROR, "Alias is of special type, please see its execution-line: '{}'.", alias->cmdline);
1653  return true;
1654  }
1655 
1656  IConsolePrint(CC_ERROR, "Command not found.");
1657  return true;
1658  }
1659 
1660  IConsolePrint(TC_LIGHT_BLUE, " ---- OpenTTD Console Help ---- ");
1661  IConsolePrint(CC_DEFAULT, " - commands: the command to list all commands is 'list_cmds'.");
1662  IConsolePrint(CC_DEFAULT, " call commands with '<command> <arg2> <arg3>...'");
1663  IConsolePrint(CC_DEFAULT, " - to assign strings, or use them as arguments, enclose it within quotes.");
1664  IConsolePrint(CC_DEFAULT, " like this: '<command> \"string argument with spaces\"'.");
1665  IConsolePrint(CC_DEFAULT, " - use 'help <command>' to get specific information.");
1666  IConsolePrint(CC_DEFAULT, " - scroll console output with shift + (up | down | pageup | pagedown).");
1667  IConsolePrint(CC_DEFAULT, " - scroll console input history with the up or down arrows.");
1669  return true;
1670 }
1671 
1672 DEF_CONSOLE_CMD(ConListCommands)
1673 {
1674  if (argc == 0) {
1675  IConsolePrint(CC_HELP, "List all registered commands. Usage: 'list_cmds [<pre-filter>]'.");
1676  return true;
1677  }
1678 
1679  for (auto &it : IConsole::Commands()) {
1680  const IConsoleCmd *cmd = &it.second;
1681  if (argv[1] == nullptr || cmd->name.find(argv[1]) != std::string::npos) {
1682  if (cmd->hook == nullptr || cmd->hook(false) != CHR_HIDE) IConsolePrint(CC_DEFAULT, cmd->name);
1683  }
1684  }
1685 
1686  return true;
1687 }
1688 
1689 DEF_CONSOLE_CMD(ConListAliases)
1690 {
1691  if (argc == 0) {
1692  IConsolePrint(CC_HELP, "List all registered aliases. Usage: 'list_aliases [<pre-filter>]'.");
1693  return true;
1694  }
1695 
1696  for (auto &it : IConsole::Aliases()) {
1697  const IConsoleAlias *alias = &it.second;
1698  if (argv[1] == nullptr || alias->name.find(argv[1]) != std::string::npos) {
1699  IConsolePrint(CC_DEFAULT, "{} => {}", alias->name, alias->cmdline);
1700  }
1701  }
1702 
1703  return true;
1704 }
1705 
1706 DEF_CONSOLE_CMD(ConCompanies)
1707 {
1708  if (argc == 0) {
1709  IConsolePrint(CC_HELP, "List the details of all companies in the game. Usage 'companies'.");
1710  return true;
1711  }
1712 
1713  for (const Company *c : Company::Iterate()) {
1714  /* Grab the company name */
1715  char company_name[512];
1716  SetDParam(0, c->index);
1717  GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
1718 
1719  const char *password_state = "";
1720  if (c->is_ai) {
1721  password_state = "AI";
1722  } else if (_network_server) {
1723  password_state = _network_company_states[c->index].password.empty() ? "unprotected" : "protected";
1724  }
1725 
1726  char colour[512];
1727  GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
1728  IConsolePrint(CC_INFO, "#:{}({}) Company Name: '{}' Year Founded: {} Money: {} Loan: {} Value: {} (T:{}, R:{}, P:{}, S:{}) {}",
1729  c->index + 1, colour, company_name,
1730  c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
1731  c->group_all[VEH_TRAIN].num_vehicle,
1732  c->group_all[VEH_ROAD].num_vehicle,
1733  c->group_all[VEH_AIRCRAFT].num_vehicle,
1734  c->group_all[VEH_SHIP].num_vehicle,
1735  password_state);
1736  }
1737 
1738  return true;
1739 }
1740 
1741 DEF_CONSOLE_CMD(ConSay)
1742 {
1743  if (argc == 0) {
1744  IConsolePrint(CC_HELP, "Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'.");
1745  return true;
1746  }
1747 
1748  if (argc != 2) return false;
1749 
1750  if (!_network_server) {
1751  NetworkClientSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
1752  } else {
1753  bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
1754  NetworkServerSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], CLIENT_ID_SERVER, from_admin);
1755  }
1756 
1757  return true;
1758 }
1759 
1760 DEF_CONSOLE_CMD(ConSayCompany)
1761 {
1762  if (argc == 0) {
1763  IConsolePrint(CC_HELP, "Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'.");
1764  IConsolePrint(CC_HELP, "CompanyNo is the company that plays as company <companyno>, 1 through max_companies.");
1765  return true;
1766  }
1767 
1768  if (argc != 3) return false;
1769 
1770  CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
1771  if (!Company::IsValidID(company_id)) {
1772  IConsolePrint(CC_DEFAULT, "Unknown company. Company range is between 1 and {}.", MAX_COMPANIES);
1773  return true;
1774  }
1775 
1776  if (!_network_server) {
1777  NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2]);
1778  } else {
1779  bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
1780  NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2], CLIENT_ID_SERVER, from_admin);
1781  }
1782 
1783  return true;
1784 }
1785 
1786 DEF_CONSOLE_CMD(ConSayClient)
1787 {
1788  if (argc == 0) {
1789  IConsolePrint(CC_HELP, "Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'.");
1790  IConsolePrint(CC_HELP, "For client-id's, see the command 'clients'.");
1791  return true;
1792  }
1793 
1794  if (argc != 3) return false;
1795 
1796  if (!_network_server) {
1797  NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
1798  } else {
1799  bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
1800  NetworkServerSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], CLIENT_ID_SERVER, from_admin);
1801  }
1802 
1803  return true;
1804 }
1805 
1806 DEF_CONSOLE_CMD(ConCompanyPassword)
1807 {
1808  if (argc == 0) {
1809  if (_network_dedicated) {
1810  IConsolePrint(CC_HELP, "Change the password of a company. Usage: 'company_pw <company-no> \"<password>\".");
1811  } else if (_network_server) {
1812  IConsolePrint(CC_HELP, "Change the password of your or any other company. Usage: 'company_pw [<company-no>] \"<password>\"'.");
1813  } else {
1814  IConsolePrint(CC_HELP, "Change the password of your company. Usage: 'company_pw \"<password>\"'.");
1815  }
1816 
1817  IConsolePrint(CC_HELP, "Use \"*\" to disable the password.");
1818  return true;
1819  }
1820 
1821  CompanyID company_id;
1822  std::string password;
1823  const char *errormsg;
1824 
1825  if (argc == 2) {
1826  company_id = _local_company;
1827  password = argv[1];
1828  errormsg = "You have to own a company to make use of this command.";
1829  } else if (argc == 3 && _network_server) {
1830  company_id = (CompanyID)(atoi(argv[1]) - 1);
1831  password = argv[2];
1832  errormsg = "You have to specify the ID of a valid human controlled company.";
1833  } else {
1834  return false;
1835  }
1836 
1837  if (!Company::IsValidHumanID(company_id)) {
1838  IConsolePrint(CC_ERROR, errormsg);
1839  return false;
1840  }
1841 
1842  password = NetworkChangeCompanyPassword(company_id, password);
1843 
1844  if (password.empty()) {
1845  IConsolePrint(CC_INFO, "Company password cleared.");
1846  } else {
1847  IConsolePrint(CC_INFO, "Company password changed to '{}'.", password);
1848  }
1849 
1850  return true;
1851 }
1852 
1853 /* Content downloading only is available with ZLIB */
1854 #if defined(WITH_ZLIB)
1855 #include "network/network_content.h"
1856 
1858 static ContentType StringToContentType(const char *str)
1859 {
1860  static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
1861  for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
1862  if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
1863  }
1864  return CONTENT_TYPE_END;
1865 }
1866 
1869  void OnConnect(bool success)
1870  {
1871  IConsolePrint(CC_DEFAULT, "Content server connection {}.", success ? "established" : "failed");
1872  }
1873 
1875  {
1876  IConsolePrint(CC_DEFAULT, "Content server connection closed.");
1877  }
1878 
1880  {
1881  IConsolePrint(CC_DEFAULT, "Completed download of {}.", cid);
1882  }
1883 };
1884 
1889 static void OutputContentState(const ContentInfo *const ci)
1890 {
1891  static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music", "Game script", "GS library" };
1892  static_assert(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
1893  static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
1894  static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
1895 
1896  char buf[sizeof(ci->md5sum) * 2 + 1];
1897  md5sumToString(buf, lastof(buf), ci->md5sum);
1898  IConsolePrint(state_to_colour[ci->state], "{}, {}, {}, {}, {:08X}, {}", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, buf);
1899 }
1900 
1901 DEF_CONSOLE_CMD(ConContent)
1902 {
1903  static ContentCallback *cb = nullptr;
1904  if (cb == nullptr) {
1905  cb = new ConsoleContentCallback();
1907  }
1908 
1909  if (argc <= 1) {
1910  IConsolePrint(CC_HELP, "Query, select and download content. Usage: 'content update|upgrade|select [id]|unselect [all|id]|state [filter]|download'.");
1911  IConsolePrint(CC_HELP, " update: get a new list of downloadable content; must be run first.");
1912  IConsolePrint(CC_HELP, " upgrade: select all items that are upgrades.");
1913  IConsolePrint(CC_HELP, " select: select a specific item given by its id. If no parameter is given, all selected content will be listed.");
1914  IConsolePrint(CC_HELP, " unselect: unselect a specific item given by its id or 'all' to unselect all.");
1915  IConsolePrint(CC_HELP, " state: show the download/select state of all downloadable content. Optionally give a filter string.");
1916  IConsolePrint(CC_HELP, " download: download all content you've selected.");
1917  return true;
1918  }
1919 
1920  if (strcasecmp(argv[1], "update") == 0) {
1922  return true;
1923  }
1924 
1925  if (strcasecmp(argv[1], "upgrade") == 0) {
1927  return true;
1928  }
1929 
1930  if (strcasecmp(argv[1], "select") == 0) {
1931  if (argc <= 2) {
1932  /* List selected content */
1933  IConsolePrint(CC_WHITE, "id, type, state, name");
1935  if ((*iter)->state != ContentInfo::SELECTED && (*iter)->state != ContentInfo::AUTOSELECTED) continue;
1936  OutputContentState(*iter);
1937  }
1938  } else if (strcasecmp(argv[2], "all") == 0) {
1939  /* The intention of this function was that you could download
1940  * everything after a filter was applied; but this never really
1941  * took off. Instead, a select few people used this functionality
1942  * to download every available package on BaNaNaS. This is not in
1943  * the spirit of this service. Additionally, these few people were
1944  * good for 70% of the consumed bandwidth of BaNaNaS. */
1945  IConsolePrint(CC_ERROR, "'select all' is no longer supported since 1.11.");
1946  } else {
1947  _network_content_client.Select((ContentID)atoi(argv[2]));
1948  }
1949  return true;
1950  }
1951 
1952  if (strcasecmp(argv[1], "unselect") == 0) {
1953  if (argc <= 2) {
1954  IConsolePrint(CC_ERROR, "You must enter the id.");
1955  return false;
1956  }
1957  if (strcasecmp(argv[2], "all") == 0) {
1959  } else {
1960  _network_content_client.Unselect((ContentID)atoi(argv[2]));
1961  }
1962  return true;
1963  }
1964 
1965  if (strcasecmp(argv[1], "state") == 0) {
1966  IConsolePrint(CC_WHITE, "id, type, state, name");
1968  if (argc > 2 && strcasestr((*iter)->name.c_str(), argv[2]) == nullptr) continue;
1969  OutputContentState(*iter);
1970  }
1971  return true;
1972  }
1973 
1974  if (strcasecmp(argv[1], "download") == 0) {
1975  uint files;
1976  uint bytes;
1978  IConsolePrint(CC_DEFAULT, "Downloading {} file(s) ({} bytes).", files, bytes);
1979  return true;
1980  }
1981 
1982  return false;
1983 }
1984 #endif /* defined(WITH_ZLIB) */
1985 
1986 DEF_CONSOLE_CMD(ConFont)
1987 {
1988  if (argc == 0) {
1989  IConsolePrint(CC_HELP, "Manage the fonts configuration.");
1990  IConsolePrint(CC_HELP, "Usage 'font'.");
1991  IConsolePrint(CC_HELP, " Print out the fonts configuration.");
1992  IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [<name>] [<size>] [aa|noaa]'.");
1993  IConsolePrint(CC_HELP, " Change the configuration for a font.");
1994  IConsolePrint(CC_HELP, " Omitting an argument will keep the current value.");
1995  IConsolePrint(CC_HELP, " Set <name> to \"\" for the sprite font (size and aa have no effect on sprite font).");
1996  return true;
1997  }
1998 
1999  FontSize argfs;
2000  for (argfs = FS_BEGIN; argfs < FS_END; argfs++) {
2001  if (argc > 1 && strcasecmp(argv[1], FontSizeToName(argfs)) == 0) break;
2002  }
2003 
2004  /* First argument must be a FontSize. */
2005  if (argc > 1 && argfs == FS_END) return false;
2006 
2007  if (argc > 2) {
2008  FontCacheSubSetting *setting = GetFontCacheSubSetting(argfs);
2009  std::string font = setting->font;
2010  uint size = setting->size;
2011  bool aa = setting->aa;
2012 
2013  byte arg_index = 2;
2014 
2015  if (argc > arg_index) {
2016  /* We may encounter "aa" or "noaa" but it must be the last argument. */
2017  if (strcasecmp(argv[arg_index], "aa") == 0 || strcasecmp(argv[arg_index], "noaa") == 0) {
2018  aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
2019  if (argc > arg_index) return false;
2020  } else {
2021  /* For <name> we want a string. */
2022  uint v;
2023  if (!GetArgumentInteger(&v, argv[arg_index])) {
2024  font = argv[arg_index++];
2025  }
2026  }
2027  }
2028 
2029  if (argc > arg_index) {
2030  /* For <size> we want a number. */
2031  uint v;
2032  if (GetArgumentInteger(&v, argv[arg_index])) {
2033  size = v;
2034  arg_index++;
2035  }
2036  }
2037 
2038  if (argc > arg_index) {
2039  /* Last argument must be "aa" or "noaa". */
2040  if (strcasecmp(argv[arg_index], "aa") != 0 && strcasecmp(argv[arg_index], "noaa") != 0) return false;
2041  aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
2042  if (argc > arg_index) return false;
2043  }
2044 
2045  SetFont(argfs, font, size, aa);
2046  }
2047 
2048  for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
2049  FontCache *fc = FontCache::Get(fs);
2051  /* Make sure all non sprite fonts are loaded. */
2052  if (!setting->font.empty() && !fc->HasParent()) {
2053  InitFontCache(fs == FS_MONO);
2054  fc = FontCache::Get(fs);
2055  }
2056  IConsolePrint(CC_DEFAULT, "{}: \"{}\" {} {} [\"{}\" {} {}]", FontSizeToName(fs), fc->GetFontName(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa", setting->font, setting->size, setting->aa ? "aa" : "noaa");
2057  }
2058 
2059  return true;
2060 }
2061 
2062 DEF_CONSOLE_CMD(ConSetting)
2063 {
2064  if (argc == 0) {
2065  IConsolePrint(CC_HELP, "Change setting for all clients. Usage: 'setting <name> [<value>]'.");
2066  IConsolePrint(CC_HELP, "Omitting <value> will print out the current value of the setting.");
2067  return true;
2068  }
2069 
2070  if (argc == 1 || argc > 3) return false;
2071 
2072  if (argc == 2) {
2073  IConsoleGetSetting(argv[1]);
2074  } else {
2075  IConsoleSetSetting(argv[1], argv[2]);
2076  }
2077 
2078  return true;
2079 }
2080 
2081 DEF_CONSOLE_CMD(ConSettingNewgame)
2082 {
2083  if (argc == 0) {
2084  IConsolePrint(CC_HELP, "Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'.");
2085  IConsolePrint(CC_HELP, "Omitting <value> will print out the current value of the setting.");
2086  return true;
2087  }
2088 
2089  if (argc == 1 || argc > 3) return false;
2090 
2091  if (argc == 2) {
2092  IConsoleGetSetting(argv[1], true);
2093  } else {
2094  IConsoleSetSetting(argv[1], argv[2], true);
2095  }
2096 
2097  return true;
2098 }
2099 
2100 DEF_CONSOLE_CMD(ConListSettings)
2101 {
2102  if (argc == 0) {
2103  IConsolePrint(CC_HELP, "List settings. Usage: 'list_settings [<pre-filter>]'.");
2104  return true;
2105  }
2106 
2107  if (argc > 2) return false;
2108 
2109  IConsoleListSettings((argc == 2) ? argv[1] : nullptr);
2110  return true;
2111 }
2112 
2113 DEF_CONSOLE_CMD(ConGamelogPrint)
2114 {
2116  return true;
2117 }
2118 
2119 DEF_CONSOLE_CMD(ConNewGRFReload)
2120 {
2121  if (argc == 0) {
2122  IConsolePrint(CC_HELP, "Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
2123  return true;
2124  }
2125 
2126  ReloadNewGRFData();
2127  return true;
2128 }
2129 
2130 DEF_CONSOLE_CMD(ConListDirs)
2131 {
2132  struct SubdirNameMap {
2133  Subdirectory subdir;
2134  const char *name;
2135  bool default_only;
2136  };
2137  static const SubdirNameMap subdir_name_map[] = {
2138  /* Game data directories */
2139  { BASESET_DIR, "baseset", false },
2140  { NEWGRF_DIR, "newgrf", false },
2141  { AI_DIR, "ai", false },
2142  { AI_LIBRARY_DIR, "ailib", false },
2143  { GAME_DIR, "gs", false },
2144  { GAME_LIBRARY_DIR, "gslib", false },
2145  { SCENARIO_DIR, "scenario", false },
2146  { HEIGHTMAP_DIR, "heightmap", false },
2147  /* Default save locations for user data */
2148  { SAVE_DIR, "save", true },
2149  { AUTOSAVE_DIR, "autosave", true },
2150  { SCREENSHOT_DIR, "screenshot", true },
2151  };
2152 
2153  if (argc != 2) {
2154  IConsolePrint(CC_HELP, "List all search paths or default directories for various categories.");
2155  IConsolePrint(CC_HELP, "Usage: list_dirs <category>");
2156  std::string cats = subdir_name_map[0].name;
2157  bool first = true;
2158  for (const SubdirNameMap &sdn : subdir_name_map) {
2159  if (!first) cats = cats + ", " + sdn.name;
2160  first = false;
2161  }
2162  IConsolePrint(CC_HELP, "Valid categories: {}", cats);
2163  return true;
2164  }
2165 
2166  std::set<std::string> seen_dirs;
2167  for (const SubdirNameMap &sdn : subdir_name_map) {
2168  if (strcasecmp(argv[1], sdn.name) != 0) continue;
2169  bool found = false;
2170  for (Searchpath sp : _valid_searchpaths) {
2171  /* Get the directory */
2172  std::string path = FioGetDirectory(sp, sdn.subdir);
2173  /* Check it hasn't already been listed */
2174  if (seen_dirs.find(path) != seen_dirs.end()) continue;
2175  seen_dirs.insert(path);
2176  /* Check if exists and mark found */
2177  bool exists = FileExists(path);
2178  found |= exists;
2179  /* Print */
2180  if (!sdn.default_only || exists) {
2181  IConsolePrint(exists ? CC_DEFAULT : CC_INFO, "{} {}", path, exists ? "[ok]" : "[not found]");
2182  if (sdn.default_only) break;
2183  }
2184  }
2185  if (!found) {
2186  IConsolePrint(CC_ERROR, "No directories exist for category {}", argv[1]);
2187  }
2188  return true;
2189  }
2190 
2191  IConsolePrint(CC_ERROR, "Invalid category name: {}", argv[1]);
2192  return false;
2193 }
2194 
2195 DEF_CONSOLE_CMD(ConNewGRFProfile)
2196 {
2197  if (argc == 0) {
2198  IConsolePrint(CC_HELP, "Collect performance data about NewGRF sprite requests and callbacks. Sub-commands can be abbreviated.");
2199  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile [list]':");
2200  IConsolePrint(CC_HELP, " List all NewGRFs that can be profiled, and their status.");
2201  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile select <grf-num>...':");
2202  IConsolePrint(CC_HELP, " Select one or more GRFs for profiling.");
2203  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile unselect <grf-num>...':");
2204  IConsolePrint(CC_HELP, " Unselect one or more GRFs from profiling. Use the keyword \"all\" instead of a GRF number to unselect all. Removing an active profiler aborts data collection.");
2205  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile start [<num-days>]':");
2206  IConsolePrint(CC_HELP, " Begin profiling all selected GRFs. If a number of days is provided, profiling stops after that many in-game days.");
2207  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile stop':");
2208  IConsolePrint(CC_HELP, " End profiling and write the collected data to CSV files.");
2209  IConsolePrint(CC_HELP, "Usage: 'newgrf_profile abort':");
2210  IConsolePrint(CC_HELP, " End profiling and discard all collected data.");
2211  return true;
2212  }
2213 
2214  extern const std::vector<GRFFile *> &GetAllGRFFiles();
2215  const std::vector<GRFFile *> &files = GetAllGRFFiles();
2216 
2217  /* "list" sub-command */
2218  if (argc == 1 || strncasecmp(argv[1], "lis", 3) == 0) {
2219  IConsolePrint(CC_INFO, "Loaded GRF files:");
2220  int i = 1;
2221  for (GRFFile *grf : files) {
2222  auto profiler = std::find_if(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](NewGRFProfiler &pr) { return pr.grffile == grf; });
2223  bool selected = profiler != _newgrf_profilers.end();
2224  bool active = selected && profiler->active;
2225  TextColour tc = active ? TC_LIGHT_BLUE : selected ? TC_GREEN : CC_INFO;
2226  const char *statustext = active ? " (active)" : selected ? " (selected)" : "";
2227  IConsolePrint(tc, "{}: [{:08X}] {}{}", i, BSWAP32(grf->grfid), grf->filename, statustext);
2228  i++;
2229  }
2230  return true;
2231  }
2232 
2233  /* "select" sub-command */
2234  if (strncasecmp(argv[1], "sel", 3) == 0 && argc >= 3) {
2235  for (size_t argnum = 2; argnum < argc; ++argnum) {
2236  int grfnum = atoi(argv[argnum]);
2237  if (grfnum < 1 || grfnum > (int)files.size()) { // safe cast, files.size() should not be larger than a few hundred in the most extreme cases
2238  IConsolePrint(CC_WARNING, "GRF number {} out of range, not added.", grfnum);
2239  continue;
2240  }
2241  GRFFile *grf = files[grfnum - 1];
2242  if (std::any_of(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](NewGRFProfiler &pr) { return pr.grffile == grf; })) {
2243  IConsolePrint(CC_WARNING, "GRF number {} [{:08X}] is already selected for profiling.", grfnum, BSWAP32(grf->grfid));
2244  continue;
2245  }
2246  _newgrf_profilers.emplace_back(grf);
2247  }
2248  return true;
2249  }
2250 
2251  /* "unselect" sub-command */
2252  if (strncasecmp(argv[1], "uns", 3) == 0 && argc >= 3) {
2253  for (size_t argnum = 2; argnum < argc; ++argnum) {
2254  if (strcasecmp(argv[argnum], "all") == 0) {
2255  _newgrf_profilers.clear();
2256  break;
2257  }
2258  int grfnum = atoi(argv[argnum]);
2259  if (grfnum < 1 || grfnum > (int)files.size()) {
2260  IConsolePrint(CC_WARNING, "GRF number {} out of range, not removing.", grfnum);
2261  continue;
2262  }
2263  GRFFile *grf = files[grfnum - 1];
2264  auto pos = std::find_if(_newgrf_profilers.begin(), _newgrf_profilers.end(), [&](NewGRFProfiler &pr) { return pr.grffile == grf; });
2265  if (pos != _newgrf_profilers.end()) _newgrf_profilers.erase(pos);
2266  }
2267  return true;
2268  }
2269 
2270  /* "start" sub-command */
2271  if (strncasecmp(argv[1], "sta", 3) == 0) {
2272  std::string grfids;
2273  size_t started = 0;
2274  for (NewGRFProfiler &pr : _newgrf_profilers) {
2275  if (!pr.active) {
2276  pr.Start();
2277  started++;
2278 
2279  if (!grfids.empty()) grfids += ", ";
2280  char grfidstr[12]{ 0 };
2281  seprintf(grfidstr, lastof(grfidstr), "[%08X]", BSWAP32(pr.grffile->grfid));
2282  grfids += grfidstr;
2283  }
2284  }
2285  if (started > 0) {
2286  IConsolePrint(CC_DEBUG, "Started profiling for GRFID{} {}.", (started > 1) ? "s" : "", grfids);
2287  if (argc >= 3) {
2288  int days = std::max(atoi(argv[2]), 1);
2289  _newgrf_profile_end_date = _date + days;
2290 
2291  char datestrbuf[32]{ 0 };
2292  SetDParam(0, _newgrf_profile_end_date);
2293  GetString(datestrbuf, STR_JUST_DATE_ISO, lastof(datestrbuf));
2294  IConsolePrint(CC_DEBUG, "Profiling will automatically stop on game date {}.", datestrbuf);
2295  } else {
2296  _newgrf_profile_end_date = MAX_DAY;
2297  }
2298  } else if (_newgrf_profilers.empty()) {
2299  IConsolePrint(CC_ERROR, "No GRFs selected for profiling, did not start.");
2300  } else {
2301  IConsolePrint(CC_ERROR, "Did not start profiling for any GRFs, all selected GRFs are already profiling.");
2302  }
2303  return true;
2304  }
2305 
2306  /* "stop" sub-command */
2307  if (strncasecmp(argv[1], "sto", 3) == 0) {
2308  NewGRFProfiler::FinishAll();
2309  return true;
2310  }
2311 
2312  /* "abort" sub-command */
2313  if (strncasecmp(argv[1], "abo", 3) == 0) {
2314  for (NewGRFProfiler &pr : _newgrf_profilers) {
2315  pr.Abort();
2316  }
2317  _newgrf_profile_end_date = MAX_DAY;
2318  return true;
2319  }
2320 
2321  return false;
2322 }
2323 
2324 #ifdef _DEBUG
2325 /******************
2326  * debug commands
2327  ******************/
2328 
2329 static void IConsoleDebugLibRegister()
2330 {
2331  IConsole::CmdRegister("resettile", ConResetTile);
2332  IConsole::AliasRegister("dbg_echo", "echo %A; echo %B");
2333  IConsole::AliasRegister("dbg_echo2", "echo %!");
2334 }
2335 #endif
2336 
2337 DEF_CONSOLE_CMD(ConFramerate)
2338 {
2339  extern void ConPrintFramerate(); // framerate_gui.cpp
2340 
2341  if (argc == 0) {
2342  IConsolePrint(CC_HELP, "Show frame rate and game speed information.");
2343  return true;
2344  }
2345 
2347  return true;
2348 }
2349 
2350 DEF_CONSOLE_CMD(ConFramerateWindow)
2351 {
2352  extern void ShowFramerateWindow();
2353 
2354  if (argc == 0) {
2355  IConsolePrint(CC_HELP, "Open the frame rate window.");
2356  return true;
2357  }
2358 
2359  if (_network_dedicated) {
2360  IConsolePrint(CC_ERROR, "Can not open frame rate window on a dedicated server.");
2361  return false;
2362  }
2363 
2365  return true;
2366 }
2367 
2368 static void ConDumpRoadTypes()
2369 {
2370  IConsolePrint(CC_DEFAULT, " Flags:");
2371  IConsolePrint(CC_DEFAULT, " c = catenary");
2372  IConsolePrint(CC_DEFAULT, " l = no level crossings");
2373  IConsolePrint(CC_DEFAULT, " X = no houses");
2374  IConsolePrint(CC_DEFAULT, " h = hidden");
2375  IConsolePrint(CC_DEFAULT, " T = buildable by towns");
2376 
2377  std::map<uint32, const GRFFile *> grfs;
2378  for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
2379  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
2380  if (rti->label == 0) continue;
2381  uint32 grfid = 0;
2382  const GRFFile *grf = rti->grffile[ROTSG_GROUND];
2383  if (grf != nullptr) {
2384  grfid = grf->grfid;
2385  grfs.emplace(grfid, grf);
2386  }
2387  IConsolePrint(CC_DEFAULT, " {:02d} {} {:c}{:c}{:c}{:c}, Flags: {}{}{}{}{}, GRF: {:08X}, {}",
2388  (uint)rt,
2389  RoadTypeIsTram(rt) ? "Tram" : "Road",
2390  rti->label >> 24, rti->label >> 16, rti->label >> 8, rti->label,
2391  HasBit(rti->flags, ROTF_CATENARY) ? 'c' : '-',
2392  HasBit(rti->flags, ROTF_NO_LEVEL_CROSSING) ? 'l' : '-',
2393  HasBit(rti->flags, ROTF_NO_HOUSES) ? 'X' : '-',
2394  HasBit(rti->flags, ROTF_HIDDEN) ? 'h' : '-',
2395  HasBit(rti->flags, ROTF_TOWN_BUILD) ? 'T' : '-',
2396  BSWAP32(grfid),
2397  GetStringPtr(rti->strings.name)
2398  );
2399  }
2400  for (const auto &grf : grfs) {
2401  IConsolePrint(CC_DEFAULT, " GRF: {:08X} = {}", BSWAP32(grf.first), grf.second->filename);
2402  }
2403 }
2404 
2405 static void ConDumpRailTypes()
2406 {
2407  IConsolePrint(CC_DEFAULT, " Flags:");
2408  IConsolePrint(CC_DEFAULT, " c = catenary");
2409  IConsolePrint(CC_DEFAULT, " l = no level crossings");
2410  IConsolePrint(CC_DEFAULT, " h = hidden");
2411  IConsolePrint(CC_DEFAULT, " s = no sprite combine");
2412  IConsolePrint(CC_DEFAULT, " a = always allow 90 degree turns");
2413  IConsolePrint(CC_DEFAULT, " d = always disallow 90 degree turns");
2414 
2415  std::map<uint32, const GRFFile *> grfs;
2416  for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
2417  const RailtypeInfo *rti = GetRailTypeInfo(rt);
2418  if (rti->label == 0) continue;
2419  uint32 grfid = 0;
2420  const GRFFile *grf = rti->grffile[RTSG_GROUND];
2421  if (grf != nullptr) {
2422  grfid = grf->grfid;
2423  grfs.emplace(grfid, grf);
2424  }
2425  IConsolePrint(CC_DEFAULT, " {:02d} {:c}{:c}{:c}{:c}, Flags: {}{}{}{}{}{}, GRF: {:08X}, {}",
2426  (uint)rt,
2427  rti->label >> 24, rti->label >> 16, rti->label >> 8, rti->label,
2428  HasBit(rti->flags, RTF_CATENARY) ? 'c' : '-',
2429  HasBit(rti->flags, RTF_NO_LEVEL_CROSSING) ? 'l' : '-',
2430  HasBit(rti->flags, RTF_HIDDEN) ? 'h' : '-',
2431  HasBit(rti->flags, RTF_NO_SPRITE_COMBINE) ? 's' : '-',
2432  HasBit(rti->flags, RTF_ALLOW_90DEG) ? 'a' : '-',
2433  HasBit(rti->flags, RTF_DISALLOW_90DEG) ? 'd' : '-',
2434  BSWAP32(grfid),
2435  GetStringPtr(rti->strings.name)
2436  );
2437  }
2438  for (const auto &grf : grfs) {
2439  IConsolePrint(CC_DEFAULT, " GRF: {:08X} = {}", BSWAP32(grf.first), grf.second->filename);
2440  }
2441 }
2442 
2443 static void ConDumpCargoTypes()
2444 {
2445  IConsolePrint(CC_DEFAULT, " Cargo classes:");
2446  IConsolePrint(CC_DEFAULT, " p = passenger");
2447  IConsolePrint(CC_DEFAULT, " m = mail");
2448  IConsolePrint(CC_DEFAULT, " x = express");
2449  IConsolePrint(CC_DEFAULT, " a = armoured");
2450  IConsolePrint(CC_DEFAULT, " b = bulk");
2451  IConsolePrint(CC_DEFAULT, " g = piece goods");
2452  IConsolePrint(CC_DEFAULT, " l = liquid");
2453  IConsolePrint(CC_DEFAULT, " r = refrigerated");
2454  IConsolePrint(CC_DEFAULT, " h = hazardous");
2455  IConsolePrint(CC_DEFAULT, " c = covered/sheltered");
2456  IConsolePrint(CC_DEFAULT, " S = special");
2457 
2458  std::map<uint32, const GRFFile *> grfs;
2459  for (CargoID i = 0; i < NUM_CARGO; i++) {
2460  const CargoSpec *spec = CargoSpec::Get(i);
2461  if (!spec->IsValid()) continue;
2462  uint32 grfid = 0;
2463  const GRFFile *grf = spec->grffile;
2464  if (grf != nullptr) {
2465  grfid = grf->grfid;
2466  grfs.emplace(grfid, grf);
2467  }
2468  IConsolePrint(CC_DEFAULT, " {:02d} Bit: {:2d}, Label: {:c}{:c}{:c}{:c}, Callback mask: 0x{:02X}, Cargo class: {}{}{}{}{}{}{}{}{}{}{}, GRF: {:08X}, {}",
2469  (uint)i,
2470  spec->bitnum,
2471  spec->label >> 24, spec->label >> 16, spec->label >> 8, spec->label,
2472  spec->callback_mask,
2473  (spec->classes & CC_PASSENGERS) != 0 ? 'p' : '-',
2474  (spec->classes & CC_MAIL) != 0 ? 'm' : '-',
2475  (spec->classes & CC_EXPRESS) != 0 ? 'x' : '-',
2476  (spec->classes & CC_ARMOURED) != 0 ? 'a' : '-',
2477  (spec->classes & CC_BULK) != 0 ? 'b' : '-',
2478  (spec->classes & CC_PIECE_GOODS) != 0 ? 'g' : '-',
2479  (spec->classes & CC_LIQUID) != 0 ? 'l' : '-',
2480  (spec->classes & CC_REFRIGERATED) != 0 ? 'r' : '-',
2481  (spec->classes & CC_HAZARDOUS) != 0 ? 'h' : '-',
2482  (spec->classes & CC_COVERED) != 0 ? 'c' : '-',
2483  (spec->classes & CC_SPECIAL) != 0 ? 'S' : '-',
2484  BSWAP32(grfid),
2485  GetStringPtr(spec->name)
2486  );
2487  }
2488  for (const auto &grf : grfs) {
2489  IConsolePrint(CC_DEFAULT, " GRF: {:08X} = {}", BSWAP32(grf.first), grf.second->filename);
2490  }
2491 }
2492 
2493 
2494 DEF_CONSOLE_CMD(ConDumpInfo)
2495 {
2496  if (argc != 2) {
2497  IConsolePrint(CC_HELP, "Dump debugging information.");
2498  IConsolePrint(CC_HELP, "Usage: 'dump_info roadtypes|railtypes|cargotypes'.");
2499  IConsolePrint(CC_HELP, " Show information about road/tram types, rail types or cargo types.");
2500  return true;
2501  }
2502 
2503  if (strcasecmp(argv[1], "roadtypes") == 0) {
2504  ConDumpRoadTypes();
2505  return true;
2506  }
2507 
2508  if (strcasecmp(argv[1], "railtypes") == 0) {
2509  ConDumpRailTypes();
2510  return true;
2511  }
2512 
2513  if (strcasecmp(argv[1], "cargotypes") == 0) {
2514  ConDumpCargoTypes();
2515  return true;
2516  }
2517 
2518  return false;
2519 }
2520 
2521 /*******************************
2522  * console command registration
2523  *******************************/
2524 
2525 void IConsoleStdLibRegister()
2526 {
2527  IConsole::CmdRegister("debug_level", ConDebugLevel);
2528  IConsole::CmdRegister("echo", ConEcho);
2529  IConsole::CmdRegister("echoc", ConEchoC);
2530  IConsole::CmdRegister("exec", ConExec);
2531  IConsole::CmdRegister("exit", ConExit);
2532  IConsole::CmdRegister("part", ConPart);
2533  IConsole::CmdRegister("help", ConHelp);
2534  IConsole::CmdRegister("info_cmd", ConInfoCmd);
2535  IConsole::CmdRegister("list_cmds", ConListCommands);
2536  IConsole::CmdRegister("list_aliases", ConListAliases);
2537  IConsole::CmdRegister("newgame", ConNewGame);
2538  IConsole::CmdRegister("restart", ConRestart);
2539  IConsole::CmdRegister("reload", ConReload);
2540  IConsole::CmdRegister("getseed", ConGetSeed);
2541  IConsole::CmdRegister("getdate", ConGetDate);
2542  IConsole::CmdRegister("getsysdate", ConGetSysDate);
2543  IConsole::CmdRegister("quit", ConExit);
2544  IConsole::CmdRegister("resetengines", ConResetEngines, ConHookNoNetwork);
2545  IConsole::CmdRegister("reset_enginepool", ConResetEnginePool, ConHookNoNetwork);
2546  IConsole::CmdRegister("return", ConReturn);
2547  IConsole::CmdRegister("screenshot", ConScreenShot);
2548  IConsole::CmdRegister("script", ConScript);
2549  IConsole::CmdRegister("zoomto", ConZoomToLevel);
2550  IConsole::CmdRegister("scrollto", ConScrollToTile);
2551  IConsole::CmdRegister("alias", ConAlias);
2552  IConsole::CmdRegister("load", ConLoad);
2553  IConsole::CmdRegister("rm", ConRemove);
2554  IConsole::CmdRegister("save", ConSave);
2555  IConsole::CmdRegister("saveconfig", ConSaveConfig);
2556  IConsole::CmdRegister("ls", ConListFiles);
2557  IConsole::CmdRegister("cd", ConChangeDirectory);
2558  IConsole::CmdRegister("pwd", ConPrintWorkingDirectory);
2559  IConsole::CmdRegister("clear", ConClearBuffer);
2560  IConsole::CmdRegister("font", ConFont);
2561  IConsole::CmdRegister("setting", ConSetting);
2562  IConsole::CmdRegister("setting_newgame", ConSettingNewgame);
2563  IConsole::CmdRegister("list_settings", ConListSettings);
2564  IConsole::CmdRegister("gamelog", ConGamelogPrint);
2565  IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF);
2566  IConsole::CmdRegister("list_dirs", ConListDirs);
2567 
2568  IConsole::AliasRegister("dir", "ls");
2569  IConsole::AliasRegister("del", "rm %+");
2570  IConsole::AliasRegister("newmap", "newgame");
2571  IConsole::AliasRegister("patch", "setting %+");
2572  IConsole::AliasRegister("set", "setting %+");
2573  IConsole::AliasRegister("set_newgame", "setting_newgame %+");
2574  IConsole::AliasRegister("list_patches", "list_settings %+");
2575  IConsole::AliasRegister("developer", "setting developer %+");
2576 
2577  IConsole::CmdRegister("list_ai_libs", ConListAILibs);
2578  IConsole::CmdRegister("list_ai", ConListAI);
2579  IConsole::CmdRegister("reload_ai", ConReloadAI);
2580  IConsole::CmdRegister("rescan_ai", ConRescanAI);
2581  IConsole::CmdRegister("start_ai", ConStartAI);
2582  IConsole::CmdRegister("stop_ai", ConStopAI);
2583 
2584  IConsole::CmdRegister("list_game", ConListGame);
2585  IConsole::CmdRegister("list_game_libs", ConListGameLibs);
2586  IConsole::CmdRegister("rescan_game", ConRescanGame);
2587 
2588  IConsole::CmdRegister("companies", ConCompanies);
2589  IConsole::AliasRegister("players", "companies");
2590 
2591  /* networking functions */
2592 
2593 /* Content downloading is only available with ZLIB */
2594 #if defined(WITH_ZLIB)
2595  IConsole::CmdRegister("content", ConContent);
2596 #endif /* defined(WITH_ZLIB) */
2597 
2598  /*** Networking commands ***/
2599  IConsole::CmdRegister("say", ConSay, ConHookNeedNetwork);
2600  IConsole::CmdRegister("say_company", ConSayCompany, ConHookNeedNetwork);
2601  IConsole::AliasRegister("say_player", "say_company %+");
2602  IConsole::CmdRegister("say_client", ConSayClient, ConHookNeedNetwork);
2603 
2604  IConsole::CmdRegister("connect", ConNetworkConnect, ConHookClientOnly);
2605  IConsole::CmdRegister("clients", ConNetworkClients, ConHookNeedNetwork);
2606  IConsole::CmdRegister("status", ConStatus, ConHookServerOnly);
2607  IConsole::CmdRegister("server_info", ConServerInfo, ConHookServerOnly);
2608  IConsole::AliasRegister("info", "server_info");
2609  IConsole::CmdRegister("reconnect", ConNetworkReconnect, ConHookClientOnly);
2610  IConsole::CmdRegister("rcon", ConRcon, ConHookNeedNetwork);
2611 
2612  IConsole::CmdRegister("join", ConJoinCompany, ConHookNeedNetwork);
2613  IConsole::AliasRegister("spectate", "join 255");
2614  IConsole::CmdRegister("move", ConMoveClient, ConHookServerOnly);
2615  IConsole::CmdRegister("reset_company", ConResetCompany, ConHookServerOnly);
2616  IConsole::AliasRegister("clean_company", "reset_company %A");
2617  IConsole::CmdRegister("client_name", ConClientNickChange, ConHookServerOnly);
2618  IConsole::CmdRegister("kick", ConKick, ConHookServerOnly);
2619  IConsole::CmdRegister("ban", ConBan, ConHookServerOnly);
2620  IConsole::CmdRegister("unban", ConUnBan, ConHookServerOnly);
2621  IConsole::CmdRegister("banlist", ConBanList, ConHookServerOnly);
2622 
2623  IConsole::CmdRegister("pause", ConPauseGame, ConHookServerOrNoNetwork);
2624  IConsole::CmdRegister("unpause", ConUnpauseGame, ConHookServerOrNoNetwork);
2625 
2626  IConsole::CmdRegister("company_pw", ConCompanyPassword, ConHookNeedNetwork);
2627  IConsole::AliasRegister("company_password", "company_pw %+");
2628 
2629  IConsole::AliasRegister("net_frame_freq", "setting frame_freq %+");
2630  IConsole::AliasRegister("net_sync_freq", "setting sync_freq %+");
2631  IConsole::AliasRegister("server_pw", "setting server_password %+");
2632  IConsole::AliasRegister("server_password", "setting server_password %+");
2633  IConsole::AliasRegister("rcon_pw", "setting rcon_password %+");
2634  IConsole::AliasRegister("rcon_password", "setting rcon_password %+");
2635  IConsole::AliasRegister("name", "setting client_name %+");
2636  IConsole::AliasRegister("server_name", "setting server_name %+");
2637  IConsole::AliasRegister("server_port", "setting server_port %+");
2638  IConsole::AliasRegister("max_clients", "setting max_clients %+");
2639  IConsole::AliasRegister("max_companies", "setting max_companies %+");
2640  IConsole::AliasRegister("max_join_time", "setting max_join_time %+");
2641  IConsole::AliasRegister("pause_on_join", "setting pause_on_join %+");
2642  IConsole::AliasRegister("autoclean_companies", "setting autoclean_companies %+");
2643  IConsole::AliasRegister("autoclean_protected", "setting autoclean_protected %+");
2644  IConsole::AliasRegister("autoclean_unprotected", "setting autoclean_unprotected %+");
2645  IConsole::AliasRegister("restart_game_year", "setting restart_game_year %+");
2646  IConsole::AliasRegister("min_players", "setting min_active_clients %+");
2647  IConsole::AliasRegister("reload_cfg", "setting reload_cfg %+");
2648 
2649  /* debugging stuff */
2650 #ifdef _DEBUG
2651  IConsoleDebugLibRegister();
2652 #endif
2653  IConsole::CmdRegister("fps", ConFramerate);
2654  IConsole::CmdRegister("fps_wnd", ConFramerateWindow);
2655 
2656  /* NewGRF development stuff */
2657  IConsole::CmdRegister("reload_newgrfs", ConNewGRFReload, ConHookNewGRFDeveloperTool);
2658  IConsole::CmdRegister("newgrf_profile", ConNewGRFProfile, ConHookNewGRFDeveloperTool);
2659 
2660  IConsole::CmdRegister("dump_info", ConDumpInfo);
2661 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
MapLogX
static uint MapLogX()
Logarithm of the map size along the X side.
Definition: map_func.h:51
game.hpp
RoadTypeInfo::flags
RoadTypeFlags flags
Bit mask of road type flags.
Definition: road.h:125
NetworkClientSendRcon
void NetworkClientSendRcon(const std::string &password, const std::string &command)
Send a remote console command.
Definition: network_client.cpp:1174
network_content.h
ROTF_NO_LEVEL_CROSSING
@ ROTF_NO_LEVEL_CROSSING
Bit number for disabling level crossing.
Definition: road.h:40
YearMonthDay::day
Day day
Day (1..31)
Definition: date_type.h:107
_console_file_list
static ConsoleFileList _console_file_list
File storage cache for the console.
Definition: console_cmds.cpp:86
ContentCallback
Callbacks for notifying others about incoming data.
Definition: network_content.h:28
RoadTypeInfo
Definition: road.h:76
CC_INFO
static const TextColour CC_INFO
Colour for information lines.
Definition: console_type.h:27
ROTSG_GROUND
@ ROTSG_GROUND
Required: Main group of ground images.
Definition: road.h:60
CC_HAZARDOUS
@ CC_HAZARDOUS
Hazardous cargo (Nuclear Fuel, Explosives, etc.)
Definition: cargotype.h:49
CargoSpec::callback_mask
uint8 callback_mask
Bitmask of cargo callbacks that have to be called.
Definition: cargotype.h:69
GameCreationSettings::generation_seed
uint32 generation_seed
noise seed for world generation
Definition: settings_type.h:312
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
ContentInfo::name
std::string name
Name of the content.
Definition: tcp_content_type.h:65
CC_COVERED
@ CC_COVERED
Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
Definition: cargotype.h:50
IConsoleCmd::proc
IConsoleCmdProc * proc
process executed when command is typed
Definition: console_internal.h:40
AIConfig
Definition: ai_config.hpp:16
EngineOverrideManager::ResetToCurrentNewGRFConfig
static bool ResetToCurrentNewGRFConfig()
Tries to reset the engine mapping to match the current NewGRF configuration.
Definition: engine.cpp:519
ScrollMainWindowToTile
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Definition: viewport.cpp:2456
CargoSpec::label
CargoLabel label
Unique label of the cargo type.
Definition: cargotype.h:59
FiosGetDescText
StringID FiosGetDescText(const char **path, uint64 *total_free)
Get descriptive texts.
Definition: fios.cpp:139
SAVE_DIR
@ SAVE_DIR
Base directory for all savegames.
Definition: fileio_type.h:110
NetworkServerShowStatusToConsole
void NetworkServerShowStatusToConsole()
Show the status message of all clients on the console.
Definition: network_server.cpp:1844
ContentInfo::type
ContentType type
Type of content.
Definition: tcp_content_type.h:61
CRR_NONE
@ CRR_NONE
Dummy reason for actions that don't need one.
Definition: company_type.h:63
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3156
ClientNetworkContentSocketHandler::End
ConstContentIterator End() const
Get the end of the content inf iterator.
Definition: network_content.h:138
ReloadNewGRFData
void ReloadNewGRFData()
Reload all NewGRF files during a running game.
Definition: afterload.cpp:3247
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:48
GUISettings::newgrf_developer_tools
bool newgrf_developer_tools
activate NewGRF developer tools and allow modifying NewGRFs in an existing game
Definition: settings_type.h:192
ROTF_CATENARY
@ ROTF_CATENARY
Bit number for adding catenary.
Definition: road.h:39
ScreenshotType
ScreenshotType
Type of requested screenshot.
Definition: screenshot.h:18
FontCacheSubSetting
Settings for a single font.
Definition: fontcache.h:203
SM_LOAD_GAME
@ SM_LOAD_GAME
Load game, Play Scenario.
Definition: openttd.h:31
OutputContentState
static void OutputContentState(const ContentInfo *const ci)
Outputs content state information to console.
Definition: console_cmds.cpp:1889
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:74
command_func.h
NetworkServerSendChat
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
Definition: network_server.cpp:1185
GameCreationSettings::map_y
uint8 map_y
Y size of map.
Definition: settings_type.h:316
DoExitSave
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition: saveload.cpp:3344
NetworkSettings::max_clients
uint8 max_clients
maximum amount of clients
Definition: settings_type.h:301
FileToSaveLoad::SetTitle
void SetTitle(const char *title)
Set the title of the file.
Definition: saveload.cpp:3425
ROTF_TOWN_BUILD
@ ROTF_TOWN_BUILD
Bit number for allowing towns to build this roadtype.
Definition: road.h:43
CCA_DELETE
@ CCA_DELETE
Delete a company.
Definition: company_type.h:70
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:27
FS_BEGIN
@ FS_BEGIN
First font.
Definition: gfx_type.h:209
GUISettings::autosave_on_exit
bool autosave_on_exit
save an autosave when you quit the game, but do not ask "Do you really want to quit?...
Definition: settings_type.h:140
BASESET_DIR
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:116
SaveOrLoad
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded)
Main Save or Load function where the high-level saveload functions are handled.
Definition: saveload.cpp:3234
NetworkClientRequestMove
void NetworkClientRequestMove(CompanyID company_id, const std::string &pass)
Notify the server of this client wanting to be moved to another company.
Definition: network_client.cpp:1185
ICON_CMDLN_SIZE
static const uint ICON_CMDLN_SIZE
maximum length of a typed in command
Definition: console_internal.h:16
SC_HEIGHTMAP
@ SC_HEIGHTMAP
Heightmap of the world.
Definition: screenshot.h:24
CC_EXPRESS
@ CC_EXPRESS
Express cargo (Goods, Food, Candy, but also possible for passengers)
Definition: cargotype.h:43
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:255
_network_server
bool _network_server
network-server is active
Definition: network.cpp:59
GAME_LIBRARY_DIR
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
Definition: fileio_type.h:122
NewGRFProfiler::grffile
const GRFFile * grffile
Which GRF is being profiled.
Definition: newgrf_profiling.h:53
SaveToConfig
void SaveToConfig()
Save the values to the configuration file.
Definition: settings.cpp:1260
SCREENSHOT_DIR
@ SCREENSHOT_DIR
Subdirectory for all screenshots.
Definition: fileio_type.h:123
NetworkCompanyHasClients
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
Definition: network_server.cpp:2022
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:118
Game::GetConsoleList
static std::string GetConsoleList(bool newest_only=false)
Wrapper function for GameScanner::GetConsoleList.
Definition: game_core.cpp:222
Game::GetConsoleLibraryList
static std::string GetConsoleLibraryList()
Wrapper function for GameScanner::GetConsoleLibraryList.
Definition: game_core.cpp:227
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1161
Searchpath
Searchpath
Types of searchpaths OpenTTD might use.
Definition: fileio_type.h:131
misc_cmd.h
FontCacheSubSetting::aa
bool aa
Whether to do anti aliasing or not.
Definition: fontcache.h:206
FindFirstBit
uint8 FindFirstBit(uint64 x)
Search the first set bit in a 64 bit variable.
Definition: bitmath_func.cpp:37
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
IConsole::AliasGet
static IConsoleAlias * AliasGet(const std::string &name)
Find the alias pointed to by its string.
Definition: console.cpp:202
NetworkServerDoMove
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
Definition: network_server.cpp:1915
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
DFT_GAME_FILE
@ DFT_GAME_FILE
Save game or scenario file.
Definition: fileio_type.h:31
HEIGHTMAP_DIR
@ HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
Definition: fileio_type.h:113
RailtypeInfo::grffile
const GRFFile * grffile[RTSG_END]
NewGRF providing the Action3 for the railtype.
Definition: rail.h:273
FileToSaveLoad::SetName
void SetName(const char *name)
Set the name of the file.
Definition: saveload.cpp:3416
ConPrintFramerate
void ConPrintFramerate()
Print performance statistics to game console.
Definition: framerate_gui.cpp:1041
AI::CanStartNew
static bool CanStartNew()
Is it possible to start a new AI company?
Definition: ai_core.cpp:30
RequestNewGRFScan
bool RequestNewGRFScan(NewGRFScanCallback *callback)
Request a new NewGRF scan.
Definition: openttd.cpp:1453
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:253
DoZoomInOutWindow
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Definition: main_gui.cpp:92
saveload.h
fileio_func.h
DESTTYPE_TEAM
@ DESTTYPE_TEAM
Send message/notice to everyone playing the same company (Team)
Definition: network_type.h:91
AUTOSAVE_DIR
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
Definition: fileio_type.h:111
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
SC_ZOOMEDIN
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Definition: screenshot.h:21
ZOOM_LVL_MAX
@ ZOOM_LVL_MAX
Maximum zoom level.
Definition: zoom_type.h:46
CargoSpec
Specification of a cargo type.
Definition: cargotype.h:57
Company::IsValidHumanID
static bool IsValidHumanID(size_t index)
Is this company a valid company, not controlled by a NoAI program?
Definition: company_base.h:149
CC_LIQUID
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
Definition: cargotype.h:47
CONTENT_TYPE_END
@ CONTENT_TYPE_END
Helper to mark the end of the types.
Definition: tcp_content_type.h:28
SetDebugString
void SetDebugString(const char *s, void(*error_func)(const char *))
Set debugging levels by parsing the text in s.
Definition: debug.cpp:164
MAX_DAY
#define MAX_DAY
The number of days till the last day.
Definition: date_type.h:98
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
CC_PASSENGERS
@ CC_PASSENGERS
Passengers.
Definition: cargotype.h:41
_network_game_info
NetworkServerGameInfo _network_game_info
Information about our game.
Definition: game_info.cpp:37
_redirect_console_to_client
ClientID _redirect_console_to_client
If not invalid, redirect the console output to a client.
Definition: network.cpp:65
gamelog.h
fios.h
StartupEngines
void StartupEngines()
Start/initialise all our engines.
Definition: engine.cpp:719
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
CalculateCompanyValue
Money CalculateCompanyValue(const Company *c, bool including_loan=true)
Calculate the value of the company.
Definition: economy.cpp:115
GUISettings::zoom_max
ZoomLevel zoom_max
maximum zoom out level
Definition: settings_type.h:135
FileList
List of file information.
Definition: fios.h:96
ConsoleFileList::InvalidateFileList
void InvalidateFileList()
Declare the file storage cache as being invalid, also clears all stored files.
Definition: console_cmds.cpp:65
ConstContentIterator
const typedef ContentInfo *const * ConstContentIterator
Iterator for the constant content vector.
Definition: network_content.h:25
IConsoleAlias::cmdline
std::string cmdline
command(s) that is/are being aliased
Definition: console_internal.h:60
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
INVALID_ADMIN_ID
static const AdminIndex INVALID_ADMIN_ID
An invalid admin marker.
Definition: network_type.h:62
GENERATE_NEW_SEED
static const uint32 GENERATE_NEW_SEED
Create a new random seed.
Definition: genworld.h:24
genworld.h
ContentType
ContentType
The values in the enum are important; they are used as database 'keys'.
Definition: tcp_content_type.h:16
FontCacheSubSetting::size
uint size
The (requested) size of the font.
Definition: fontcache.h:205
_redirect_console_to_admin
AdminIndex _redirect_console_to_admin
Redirection of the (remote) console to the admin.
Definition: network_admin.cpp:31
CC_DEFAULT
static const TextColour CC_DEFAULT
Default colour of the console.
Definition: console_type.h:23
CargoSpec::bitnum
uint8 bitnum
Cargo bit number, is INVALID_CARGO for a non-used spec.
Definition: cargotype.h:58
IConsoleCmd::hook
IConsoleHook * hook
any special trigger action that needs executing
Definition: console_internal.h:41
network_base.h
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:587
ai.hpp
NetworkChangeCompanyPassword
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password)
Change the company password of a given company.
Definition: network.cpp:157
IConsoleCmd::name
std::string name
name of command
Definition: console_internal.h:39
screenshot.h
PM_UNPAUSED
@ PM_UNPAUSED
A normal unpaused game.
Definition: openttd.h:61
MapSizeX
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:72
RailtypeInfo::name
StringID name
Name of this rail type.
Definition: rail.h:173
ClientNetworkContentSocketHandler::RequestContentList
void RequestContentList(ContentType type)
Request the content list for the given type.
Definition: network_content.cpp:190
Pool::MAX_SIZE
static constexpr size_t MAX_SIZE
Make template parameter accessible from outside.
Definition: pool_type.hpp:85
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:114
company_cmd.h
ZOOM_LVL_MIN
@ ZOOM_LVL_MIN
Minimum zoom level.
Definition: zoom_type.h:45
_company_colours
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
Definition: company_cmd.cpp:48
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:73
BASE_DIR
@ BASE_DIR
Base directory for all subdirectories.
Definition: fileio_type.h:109
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
IConsole::CmdRegister
static void CmdRegister(const std::string &name, IConsoleCmdProc *proc, IConsoleHook *hook=nullptr)
Register a new command to be used in the console.
Definition: console.cpp:169
COMPANY_NEW_COMPANY
@ COMPANY_NEW_COMPANY
The client wants a new company.
Definition: company_type.h:34
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
SLO_LOAD
@ SLO_LOAD
File is being loaded.
Definition: fileio_type.h:49
_script_current_depth
static uint _script_current_depth
Depth of scripts running (used to abort execution when #ConReturn is encountered).
Definition: console_cmds.cpp:54
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
walltime_func.h
RTF_CATENARY
@ RTF_CATENARY
Bit number for drawing a catenary.
Definition: rail.h:26
AI::GetConsoleLibraryList
static std::string GetConsoleLibraryList()
Wrapper function for AIScanner::GetAIConsoleLibraryList.
Definition: ai_core.cpp:310
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
CC_SPECIAL
@ CC_SPECIAL
Special bit used for livery refit tricks instead of normal cargoes.
Definition: cargotype.h:51
ConsoleContentCallback::OnDownloadComplete
void OnDownloadComplete(ContentID cid)
We have finished downloading a file.
Definition: console_cmds.cpp:1879
NetworkSettings::last_joined
std::string last_joined
Last joined server.
Definition: settings_type.h:305
FontCache::HasParent
bool HasParent()
Check whether the font cache has a parent.
Definition: fontcache.h:151
SLO_SAVE
@ SLO_SAVE
File is being saved.
Definition: fileio_type.h:50
settings_func.h
ROTF_HIDDEN
@ ROTF_HIDDEN
Bit number for hidden from construction.
Definition: road.h:42
CC_HELP
static const TextColour CC_HELP
Colour for help lines.
Definition: console_type.h:26
RTF_HIDDEN
@ RTF_HIDDEN
Bit number for hiding from selection.
Definition: rail.h:28
AI_DIR
@ AI_DIR
Subdirectory for all AI files.
Definition: fileio_type.h:119
YearMonthDay::month
Month month
Month (0..11)
Definition: date_type.h:106
ClientNetworkGameSocketHandler::IsConnected
static bool IsConnected()
Check whether the client is actually connected (and in the game).
Definition: network_client.cpp:520
CargoSpec::IsValid
bool IsValid() const
Tests for validity of this cargospec.
Definition: cargotype.h:99
FioFOpenFile
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
Definition: fileio.cpp:245
console_internal.h
StrTrimInPlace
void StrTrimInPlace(std::string &str)
Trim the spaces from given string in place, i.e.
Definition: string.cpp:373
ClientNetworkContentSocketHandler::UnselectAll
void UnselectAll()
Unselect everything that we've not downloaded so far.
Definition: network_content.cpp:913
CC_PIECE_GOODS
@ CC_PIECE_GOODS
Piece goods (Livestock, Wood, Steel, Paper)
Definition: cargotype.h:46
FontCacheSubSetting::font
std::string font
The name of the font, or path to the font.
Definition: fontcache.h:204
FileList::BuildFileList
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop)
Construct a file list with the given kind of files, for the stated purpose.
Definition: fios.cpp:72
ContentInfo
Container for all important information about a piece of content.
Definition: tcp_content_type.h:50
FileExists
bool FileExists(const std::string &filename)
Test whether the given filename exists.
Definition: fileio.cpp:122
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:47
ConsoleContentCallback::OnDisconnect
void OnDisconnect()
Callback for when the connection got disconnected.
Definition: console_cmds.cpp:1874
RTF_DISALLOW_90DEG
@ RTF_DISALLOW_90DEG
Bit number for never allowed 90 degree turns, regardless of setting.
Definition: rail.h:31
InitFontCache
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
Definition: fontcache.cpp:128
ShowFramerateWindow
void ShowFramerateWindow()
Open the general framerate window.
Definition: framerate_gui.cpp:1028
CC_BULK
@ CC_BULK
Bulk cargo (Coal, Grain etc., Ores, Fruit)
Definition: cargotype.h:45
AIConfig::GetConfig
static AIConfig * GetConfig(CompanyID company, ScriptSettingSource source=SSS_DEFAULT)
Get the config of a company.
Definition: ai_config.cpp:45
IConsoleCmd
Definition: console_internal.h:36
CargoSpec::grffile
const struct GRFFile * grffile
NewGRF where #group belongs to.
Definition: cargotype.h:80
FiosItem
Deals with finding savegames.
Definition: fios.h:87
_pause_mode
PauseMode _pause_mode
The current pause mode.
Definition: gfx.cpp:50
ContentInfo::md5sum
byte md5sum[16]
The MD5 checksum.
Definition: tcp_content_type.h:70
ClientNetworkContentSocketHandler::Unselect
void Unselect(ContentID cid)
Unselect a specific content id.
Definition: network_content.cpp:881
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
CHR_ALLOW
@ CHR_ALLOW
Allow command execution.
Definition: console_internal.h:21
GetFontCacheSubSetting
static FontCacheSubSetting * GetFontCacheSubSetting(FontSize fs)
Get the settings of a given font size.
Definition: fontcache.h:226
GetArgumentInteger
bool GetArgumentInteger(uint32 *value, const char *arg)
Change a string into its number representation.
Definition: console.cpp:136
ConvertDateToYMD
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Definition: date.cpp:94
NetworkPrintClients
void NetworkPrintClients()
Print all the clients to the console.
Definition: network_server.cpp:2047
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
FiosBrowseTo
const char * FiosBrowseTo(const FiosItem *item)
Browse to a new path based on the passed item, starting at #_fios_path.
Definition: fios.cpp:150
safeguards.h
FileList::FindItem
const FiosItem * FindItem(const char *file)
Find file information of a file by its name from the file list.
Definition: fios.cpp:104
ROTF_NO_HOUSES
@ ROTF_NO_HOUSES
Bit number for setting this roadtype as not house friendly.
Definition: road.h:41
NetworkCompanyState::password
std::string password
The password for the company.
Definition: network_type.h:73
GAME_DIR
@ GAME_DIR
Subdirectory for all game scripts.
Definition: fileio_type.h:121
SCENARIO_DIR
@ SCENARIO_DIR
Base directory for all scenarios.
Definition: fileio_type.h:112
NetworkServerChangeClientName
bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_name)
Change the client name of the given client.
Definition: network_server.cpp:1627
CLIENT_ID_SERVER
@ CLIENT_ID_SERVER
Servers always have this ID.
Definition: network_type.h:49
ScriptConfig::StringToSettings
void StringToSettings(const std::string &value)
Convert a string which is stored in the config file or savegames to custom settings of this Script.
Definition: script_config.cpp:185
_network_company_states
NetworkCompanyState * _network_company_states
Statistics about some companies.
Definition: network.cpp:63
ContentInfo::SELECTED
@ SELECTED
The content has been manually selected.
Definition: tcp_content_type.h:54
CC_DEBUG
static const TextColour CC_DEBUG
Colour for debug output.
Definition: console_type.h:28
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:58
rail.h
GamelogPrintConsole
void GamelogPrintConsole()
Print the gamelog data to the console.
Definition: gamelog.cpp:350
Time::Format
static size_t Format(char *buffer, const char *last, const char *format) NOACCESS(2) WARN_TIME_FORMAT(3)
Format the current time with the given strftime format specifiers.
Definition: walltime_func.h:58
NetworkServerKickOrBanIP
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const std::string &reason)
Ban, or kick, everyone joined from the given client's IP.
Definition: network_server.cpp:1973
road.h
network_client.h
RTSG_GROUND
@ RTSG_GROUND
Main group of ground images.
Definition: rail.h:49
ConsoleFileList::ValidateFileList
void ValidateFileList(bool force_reload=false)
(Re-)validate the file storage cache.
Definition: console_cmds.cpp:75
RoadTypeInfo::name
StringID name
Name of this rail type.
Definition: road.h:101
MapSizeY
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:82
CRR_MANUAL
@ CRR_MANUAL
The company is manually removed.
Definition: company_type.h:57
NewGRFProfiler::active
bool active
Is this profiler collecting data.
Definition: newgrf_profiling.h:54
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:61
date_func.h
stdafx.h
ClientNetworkContentSocketHandler::DownloadSelectedContent
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
Definition: network_content.cpp:310
Company::IsHumanID
static bool IsHumanID(size_t index)
Is this company a company not controlled by a NoAI program?
Definition: company_base.h:162
FT_SAVEGAME
@ FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:18
landscape.h
CC_COMMAND
static const TextColour CC_COMMAND
Colour for the console's commands.
Definition: console_type.h:29
BSWAP32
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Definition: bitmath_func.hpp:390
NEWGRF_DIR
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
Definition: fileio_type.h:117
ConsoleFileList::file_list_valid
bool file_list_valid
If set, the file list is valid.
Definition: console_cmds.cpp:83
viewport_func.h
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:213
StartNewGameWithoutGUI
void StartNewGameWithoutGUI(uint32 seed)
Start a normal game without the GUI.
Definition: genworld_gui.cpp:1099
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
CCA_NEW_AI
@ CCA_NEW_AI
Create a new AI company.
Definition: company_type.h:69
ConsoleFileList
File list storage for the console, for caching the last 'ls' command.
Definition: console_cmds.cpp:57
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:64
IConsoleAlias::name
std::string name
name of the alias
Definition: console_internal.h:59
NetworkClientSendChat
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data)
Send a chat message.
Definition: network_client.cpp:1292
GUISettings::zoom_min
ZoomLevel zoom_min
minimum zoom out level
Definition: settings_type.h:134
GameSettings::ai
AISettings ai
what may the AI do?
Definition: settings_type.h:589
YearMonthDay::year
Year year
Year (0...)
Definition: date_type.h:105
_network_content_client
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
Definition: network_content.cpp:35
RoadTypeInfo::grffile
const GRFFile * grffile[ROTSG_END]
NewGRF providing the Action3 for the roadtype.
Definition: road.h:185
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
ConsoleContentCallback::OnConnect
void OnConnect(bool success)
Callback for when the connection has finished.
Definition: console_cmds.cpp:1869
RailtypeInfo::flags
RailTypeFlags flags
Bit mask of rail type flags.
Definition: rail.h:208
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
strings_func.h
NewGRFProfiler
Callback profiler for NewGRF development.
Definition: newgrf_profiling.h:26
IConsoleListSettings
void IConsoleListSettings(const char *prefilter)
List all settings and their value to the console.
Definition: settings.cpp:1731
FontCache::GetFontName
virtual std::string GetFontName()=0
Get the name of this font.
SC_WORLD
@ SC_WORLD
World screenshot.
Definition: screenshot.h:23
FontCache
Font cache for basic fonts.
Definition: fontcache.h:21
CC_ARMOURED
@ CC_ARMOURED
Armoured cargo (Valuables, Gold, Diamonds)
Definition: cargotype.h:44
Pool::PoolItem<&_company_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:367
TileXY
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition: map_func.h:163
RoadTypeInfo::label
RoadTypeLabel label
Unique 32 bit road type identifier.
Definition: road.h:145
str_fmt
char *CDECL str_fmt(const char *str,...)
Format, "printf", into a newly allocated string.
Definition: string.cpp:151
GameCreationSettings::map_x
uint8 map_x
X size of map.
Definition: settings_type.h:315
ContentInfo::AUTOSELECTED
@ AUTOSELECTED
The content has been selected as dependency.
Definition: tcp_content_type.h:55
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
CC_REFRIGERATED
@ CC_REFRIGERATED
Refrigerated cargo (Food, Fruit)
Definition: cargotype.h:48
DEF_CONSOLE_CMD
DEF_CONSOLE_CMD(ConResetEngines)
Reset status of all engines.
Definition: console_cmds.cpp:197
WC_CONSOLE
@ WC_CONSOLE
Console; Window numbers:
Definition: window_type.h:631
GetDebugString
const char * GetDebugString()
Print out the current debug-level.
Definition: debug.cpp:229
_file_to_saveload
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:63
ContentID
ContentID
Unique identifier for the content.
Definition: tcp_content_type.h:45
IConsole::AliasRegister
static void AliasRegister(const std::string &name, const std::string &cmd)
Register a an alias for an already existing command in the console.
Definition: console.cpp:191
PM_PAUSED_NORMAL
@ PM_PAUSED_NORMAL
A game normally paused.
Definition: openttd.h:62
IConsoleAlias
–Aliases– Aliases are like shortcuts for complex functions, variable assignments, etc.
Definition: console_internal.h:56
CargoSpec::classes
uint16 classes
Classes of this cargo type.
Definition: cargotype.h:79
newgrf.h
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
RTF_ALLOW_90DEG
@ RTF_ALLOW_90DEG
Bit number for always allowed 90 degree turns, regardless of setting.
Definition: rail.h:30
RailtypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition: rail.h:233
CONTENT_TYPE_BEGIN
@ CONTENT_TYPE_BEGIN
Helper to mark the begin of the types.
Definition: tcp_content_type.h:17
FontCache::GetFontSize
virtual int GetFontSize() const
Get the nominal font size of the font.
Definition: fontcache.h:72
StringToContentType
static ContentType StringToContentType(const char *str)
Resolve a string to a content type.
Definition: console_cmds.cpp:1858
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:225
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:554
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
ClientNetworkContentSocketHandler::Select
void Select(ContentID cid)
Select a specific content id.
Definition: network_content.cpp:868
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
game_info.h
CargoSpec::name
StringID name
Name of this type of cargo.
Definition: cargotype.h:71
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition: screenshot.h:22
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
RTF_NO_SPRITE_COMBINE
@ RTF_NO_SPRITE_COMBINE
Bit number for using non-combined junctions.
Definition: rail.h:29
company_func.h
CC_ERROR
static const TextColour CC_ERROR
Colour for error lines.
Definition: console_type.h:24
SM_RELOADGAME
@ SM_RELOADGAME
Reload the savegame / scenario / heightmap you started the game with.
Definition: openttd.h:29
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:32
MakeScreenshot
bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height)
Schedule making a screenshot.
Definition: screenshot.cpp:990
ClientNetworkContentSocketHandler::AddCallback
void AddCallback(ContentCallback *cb)
Add a callback to this class.
Definition: network_content.h:143
stredup
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Definition: string.cpp:138
NetworkAvailable
static bool NetworkAvailable(bool echo)
Check network availability and inform in console about failure of detection.
Definition: console_cmds.cpp:101
CHR_DISALLOW
@ CHR_DISALLOW
Disallow command execution.
Definition: console_internal.h:22
IConsoleGetSetting
void IConsoleGetSetting(const char *name, bool force_newgame)
Output value of a specific setting to the console.
Definition: settings.cpp:1693
network.h
ContentInfo::state
State state
Whether the content info is selected (for download)
Definition: tcp_content_type.h:73
CommandHelper
Definition: command_func.h:94
NetworkClientConnectGame
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password, const std::string &join_company_password)
Join a client to the server at with the given connection string.
Definition: network.cpp:764
ContentInfo::unique_id
uint32 unique_id
Unique ID; either GRF ID or shortname.
Definition: tcp_content_type.h:69
window_func.h
AI_LIBRARY_DIR
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
Definition: fileio_type.h:120
AI::GetConsoleList
static std::string GetConsoleList(bool newest_only=false)
Wrapper function for AIScanner::GetAIConsoleList.
Definition: ai_core.cpp:305
RTF_NO_LEVEL_CROSSING
@ RTF_NO_LEVEL_CROSSING
Bit number for disallowing level crossings.
Definition: rail.h:27
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
YearMonthDay
Data structure to convert between Date and triplet (year, month, and day).
Definition: date_type.h:104
_network_ban_list
StringList _network_ban_list
The banned clients.
Definition: network.cpp:69
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:605
IConsoleClose
void IConsoleClose()
Close the in-game console.
Definition: console_gui.cpp:412
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition: screenshot.h:19
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
DESTTYPE_BROADCAST
@ DESTTYPE_BROADCAST
Send message/notice to all clients (All)
Definition: network_type.h:90
CHR_HIDE
@ CHR_HIDE
Hide the existence of the command.
Definition: console_internal.h:23
FS_MONO
@ FS_MONO
Index of the monospaced font in the font tables.
Definition: gfx_type.h:206
GetAbstractFileType
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
Definition: fileio_type.h:90
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
engine_base.h
DEF_CONSOLE_HOOK
DEF_CONSOLE_HOOK(ConHookServerOnly)
Check whether we are a server.
Definition: console_cmds.cpp:114
fontcache.h
IConsoleCmdExec
void IConsoleCmdExec(const char *cmdstr, const uint recurse_count)
Execute a given command passed to us.
Definition: console.cpp:303
ScriptConfig::Change
void Change(const char *name, int version=-1, bool force_exact_match=false, bool is_random=false)
Set another Script to be loaded in this slot.
Definition: script_config.cpp:19
ConsoleContentCallback
Asynchronous callback.
Definition: console_cmds.cpp:1868
NetworkServerKickClient
void NetworkServerKickClient(ClientID client_id, const std::string &reason)
Kick a single client.
Definition: network_server.cpp:1961
DESTTYPE_CLIENT
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
Definition: network_type.h:92
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:202
Window
Data structure for an opened window.
Definition: window_gui.h:213
md5sumToString
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Definition: string.cpp:572
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
network_admin.h
console_func.h
SC_MINIMAP
@ SC_MINIMAP
Minimap screenshot.
Definition: screenshot.h:25
NetworkServerGameInfo::clients_on
byte clients_on
Current count of clients on server.
Definition: game_info.h:103
_network_available
bool _network_available
is network mode available?
Definition: network.cpp:60
ClientNetworkContentSocketHandler::SelectUpgrade
void SelectUpgrade()
Select everything that's an update for something we've got.
Definition: network_content.cpp:902
CC_WARNING
static const TextColour CC_WARNING
Colour for warning lines.
Definition: console_type.h:25
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:470
FileToSaveLoad::SetMode
void SetMode(FiosType ft)
Set the mode and file type of the file to save or load based on the type of file entry at the file sy...
Definition: saveload.cpp:3387
ContentInfo::id
ContentID id
Unique (server side) ID for the content.
Definition: tcp_content_type.h:62
AI::Rescan
static void Rescan()
Rescans all searchpaths for available AIs.
Definition: ai_core.cpp:335
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
newgrf_profiling.h
PM_PAUSED_ERROR
@ PM_PAUSED_ERROR
A game paused because a (critical) error.
Definition: openttd.h:65
Company
Definition: company_base.h:117
CC_MAIL
@ CC_MAIL
Mail.
Definition: cargotype.h:42
_network_server_invite_code
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
Definition: network_coordinator.cpp:32
CC_WHITE
static const TextColour CC_WHITE
White console lines for various things such as the welcome.
Definition: console_type.h:30
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
SL_OK
@ SL_OK
completed successfully
Definition: saveload.h:353
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
network_func.h
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
ScriptConfig::HasScript
bool HasScript() const
Is this config attached to an Script? In other words, is there a Script that is assigned to this slot...
Definition: script_config.cpp:165
NetworkIsValidClientName
bool NetworkIsValidClientName(const std::string_view client_name)
Check whether the given client name is deemed valid for use in network games.
Definition: network_client.cpp:1216
AISettings::ai_in_multiplayer
bool ai_in_multiplayer
so we allow AIs in multiplayer
Definition: settings_type.h:370
IConsole::CmdGet
static IConsoleCmd * CmdGet(const std::string &name)
Find the command pointed to by its string.
Definition: console.cpp:179
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:106
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
FioFCloseFile
void FioFCloseFile(FILE *f)
Close a file in a safe way.
Definition: fileio.cpp:130
debug.h
FontCache::Get
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.
Definition: fontcache.h:142
ClientNetworkContentSocketHandler::Begin
ConstContentIterator Begin() const
Get the begin of the content inf iterator.
Definition: network_content.h:134
ai_config.hpp
engine_func.h
NetworkSettings::max_companies
uint8 max_companies
maximum amount of companies
Definition: settings_type.h:300
PrintLineByLine
static void PrintLineByLine(const std::string &full_string)
Print a text buffer line by line to the console.
Definition: console_cmds.cpp:1168
RoadTypeInfo::strings
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
SM_RESTARTGAME
@ SM_RESTARTGAME
Restart --> 'Random game' with current settings.
Definition: openttd.h:28
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition: rail_type.h:28
IConsolePrint
void IConsolePrint(TextColour colour_code, const std::string &string)
Handle the printing of text entered into the console or redirected there by any other means.
Definition: console.cpp:94