equal
deleted
inserted
replaced
82 |
82 |
83 #endif /* ENABLE_NETWORK */ |
83 #endif /* ENABLE_NETWORK */ |
84 |
84 |
85 static void IConsoleHelp(const char *str) |
85 static void IConsoleHelp(const char *str) |
86 { |
86 { |
87 IConsolePrintF(_iconsole_color_warning, "- %s", str); |
87 IConsolePrintF(_icolour_warn, "- %s", str); |
88 } |
88 } |
89 |
89 |
90 DEF_CONSOLE_CMD(ConResetEngines) |
90 DEF_CONSOLE_CMD(ConResetEngines) |
91 { |
91 { |
92 if (argc == 0) { |
92 if (argc == 0) { |
152 |
152 |
153 if (argc == 2) { |
153 if (argc == 2) { |
154 char buf[200]; |
154 char buf[200]; |
155 |
155 |
156 snprintf(buf, lengthof(buf), "%s%s%s.sav", _path.save_dir, PATHSEP, argv[1]); |
156 snprintf(buf, lengthof(buf), "%s%s%s.sav", _path.save_dir, PATHSEP, argv[1]); |
157 IConsolePrint(_iconsole_color_default, "Saving map..."); |
157 IConsolePrint(_icolour_def, "Saving map..."); |
158 |
158 |
159 if (SaveOrLoad(buf, SL_SAVE) != SL_OK) { |
159 if (SaveOrLoad(buf, SL_SAVE) != SL_OK) { |
160 IConsolePrint(_iconsole_color_error, "SaveMap failed"); |
160 IConsolePrint(_icolour_err, "SaveMap failed"); |
161 } else |
161 } else |
162 IConsolePrintF(_iconsole_color_default, "Map sucessfully saved to %s", buf); |
162 IConsolePrintF(_icolour_def, "Map sucessfully saved to %s", buf); |
163 return true; |
163 return true; |
164 } |
164 } |
165 |
165 |
166 return false; |
166 return false; |
167 } |
167 } |
207 case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: |
207 case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: |
208 _switch_mode = SM_LOAD; |
208 _switch_mode = SM_LOAD; |
209 SetFiosType(item->type); |
209 SetFiosType(item->type); |
210 strcpy(_file_to_saveload.name, FiosBrowseTo(item)); |
210 strcpy(_file_to_saveload.name, FiosBrowseTo(item)); |
211 break; |
211 break; |
212 default: IConsolePrintF(_iconsole_color_error, "%s: Not a savegame.", file); |
212 default: IConsolePrintF(_icolour_err, "%s: Not a savegame.", file); |
213 } |
213 } |
214 } else |
214 } else |
215 IConsolePrintF(_iconsole_color_error, "%s: No such file or directory.", file); |
215 IConsolePrintF(_icolour_err, "%s: No such file or directory.", file); |
216 |
216 |
217 FiosFreeSavegameList(); |
217 FiosFreeSavegameList(); |
218 return true; |
218 return true; |
219 } |
219 } |
220 |
220 |
230 |
230 |
231 BuildFileList(); |
231 BuildFileList(); |
232 |
232 |
233 for (i = 0; i < _fios_num; i++) { |
233 for (i = 0; i < _fios_num; i++) { |
234 const FiosItem *item = &_fios_list[i]; |
234 const FiosItem *item = &_fios_list[i]; |
235 IConsolePrintF(_iconsole_color_default, "%d) %s", i, (item->title[0] != '\0') ? item->title : item->name); |
235 IConsolePrintF(_icolour_def, "%d) %s", i, (item->title[0] != '\0') ? item->title : item->name); |
236 } |
236 } |
237 |
237 |
238 FiosFreeSavegameList(); |
238 FiosFreeSavegameList(); |
239 return true; |
239 return true; |
240 } |
240 } |
257 if (item != NULL) { |
257 if (item != NULL) { |
258 switch (item->type) { |
258 switch (item->type) { |
259 case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT: |
259 case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT: |
260 FiosBrowseTo(item); |
260 FiosBrowseTo(item); |
261 break; |
261 break; |
262 default: IConsolePrintF(_iconsole_color_error, "%s: Not a directory.", file); |
262 default: IConsolePrintF(_icolour_err, "%s: Not a directory.", file); |
263 } |
263 } |
264 } else |
264 } else |
265 IConsolePrintF(_iconsole_color_error, "%s: No such file or directory.", file); |
265 IConsolePrintF(_icolour_err, "%s: No such file or directory.", file); |
266 |
266 |
267 FiosFreeSavegameList(); |
267 FiosFreeSavegameList(); |
268 return true; |
268 return true; |
269 } |
269 } |
270 |
270 |
281 // XXX - Workaround for broken file handling |
281 // XXX - Workaround for broken file handling |
282 FiosGetSavegameList(&_fios_num, SLD_LOAD_GAME); |
282 FiosGetSavegameList(&_fios_num, SLD_LOAD_GAME); |
283 FiosFreeSavegameList(); |
283 FiosFreeSavegameList(); |
284 |
284 |
285 FiosGetDescText(&path, NULL); |
285 FiosGetDescText(&path, NULL); |
286 IConsolePrint(_iconsole_color_default, path); |
286 IConsolePrint(_icolour_def, path); |
287 return true; |
287 return true; |
288 } |
288 } |
289 |
289 |
290 |
290 |
291 // ********************************* // |
291 // ********************************* // |
307 if (argc != 2) return false; |
307 if (argc != 2) return false; |
308 |
308 |
309 index = atoi(argv[1]); |
309 index = atoi(argv[1]); |
310 |
310 |
311 if (index == NETWORK_SERVER_INDEX) { |
311 if (index == NETWORK_SERVER_INDEX) { |
312 IConsolePrint(_iconsole_color_default, "Silly boy, you can not ban yourself!"); |
312 IConsolePrint(_icolour_def, "Silly boy, you can not ban yourself!"); |
313 return true; |
313 return true; |
314 } |
314 } |
315 if (index == 0) { |
315 if (index == 0) { |
316 IConsoleError("Invalid Client-ID"); |
316 IConsoleError("Invalid Client-ID"); |
317 return true; |
317 return true; |
351 if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') |
351 if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') |
352 continue; |
352 continue; |
353 |
353 |
354 if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0) { |
354 if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0) { |
355 _network_ban_list[i][0] = '\0'; |
355 _network_ban_list[i][0] = '\0'; |
356 IConsolePrint(_iconsole_color_default, "IP unbanned."); |
356 IConsolePrint(_icolour_def, "IP unbanned."); |
357 return true; |
357 return true; |
358 } |
358 } |
359 } |
359 } |
360 |
360 |
361 IConsolePrint(_iconsole_color_default, "IP not in ban-list."); |
361 IConsolePrint(_icolour_def, "IP not in ban-list."); |
362 return true; |
362 return true; |
363 } |
363 } |
364 |
364 |
365 DEF_CONSOLE_CMD(ConBanList) |
365 DEF_CONSOLE_CMD(ConBanList) |
366 { |
366 { |
369 if (argc == 0) { |
369 if (argc == 0) { |
370 IConsoleHelp("List the IP's of banned clients: Usage 'banlist'"); |
370 IConsoleHelp("List the IP's of banned clients: Usage 'banlist'"); |
371 return true; |
371 return true; |
372 } |
372 } |
373 |
373 |
374 IConsolePrint(_iconsole_color_default, "Banlist: "); |
374 IConsolePrint(_icolour_def, "Banlist: "); |
375 |
375 |
376 for (i = 0; i < lengthof(_network_ban_list); i++) { |
376 for (i = 0; i < lengthof(_network_ban_list); i++) { |
377 if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') |
377 if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') |
378 continue; |
378 continue; |
379 |
379 |
380 IConsolePrintF(_iconsole_color_default, " %d) %s", i + 1, _network_ban_list[i]); |
380 IConsolePrintF(_icolour_def, " %d) %s", i + 1, _network_ban_list[i]); |
381 } |
381 } |
382 |
382 |
383 return true; |
383 return true; |
384 } |
384 } |
385 |
385 |
390 return true; |
390 return true; |
391 } |
391 } |
392 |
392 |
393 if (_pause == 0) { |
393 if (_pause == 0) { |
394 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
394 DoCommandP(0, 1, 0, NULL, CMD_PAUSE); |
395 IConsolePrint(_iconsole_color_default, "Game paused."); |
395 IConsolePrint(_icolour_def, "Game paused."); |
396 } else |
396 } else |
397 IConsolePrint(_iconsole_color_default, "Game is already paused."); |
397 IConsolePrint(_icolour_def, "Game is already paused."); |
398 |
398 |
399 return true; |
399 return true; |
400 } |
400 } |
401 |
401 |
402 DEF_CONSOLE_CMD(ConUnPauseGame) |
402 DEF_CONSOLE_CMD(ConUnPauseGame) |
406 return true; |
406 return true; |
407 } |
407 } |
408 |
408 |
409 if (_pause != 0) { |
409 if (_pause != 0) { |
410 DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
410 DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
411 IConsolePrint(_iconsole_color_default, "Game unpaused."); |
411 IConsolePrint(_icolour_def, "Game unpaused."); |
412 } else |
412 } else |
413 IConsolePrint(_iconsole_color_default, "Game is already unpaused."); |
413 IConsolePrint(_icolour_def, "Game is already unpaused."); |
414 |
414 |
415 return true; |
415 return true; |
416 } |
416 } |
417 |
417 |
418 DEF_CONSOLE_CMD(ConRcon) |
418 DEF_CONSOLE_CMD(ConRcon) |
465 |
465 |
466 if (argc != 2) return false; |
466 if (argc != 2) return false; |
467 |
467 |
468 index = atoi(argv[1]); |
468 index = atoi(argv[1]); |
469 if (index == NETWORK_SERVER_INDEX) { |
469 if (index == NETWORK_SERVER_INDEX) { |
470 IConsolePrint(_iconsole_color_default, "Silly boy, you can not kick yourself!"); |
470 IConsolePrint(_icolour_def, "Silly boy, you can not kick yourself!"); |
471 return true; |
471 return true; |
472 } |
472 } |
473 if (index == 0) { |
473 if (index == 0) { |
474 IConsoleError("Invalid client-id"); |
474 IConsoleError("Invalid client-id"); |
475 return true; |
475 return true; |
502 |
502 |
503 index = atoi(argv[1]); |
503 index = atoi(argv[1]); |
504 |
504 |
505 /* Check valid range */ |
505 /* Check valid range */ |
506 if (index < 1 || index > MAX_PLAYERS) { |
506 if (index < 1 || index > MAX_PLAYERS) { |
507 IConsolePrintF(_iconsole_color_error, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS); |
507 IConsolePrintF(_icolour_err, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS); |
508 return true; |
508 return true; |
509 } |
509 } |
510 |
510 |
511 /* Check if company does exist */ |
511 /* Check if company does exist */ |
512 index--; |
512 index--; |
535 return true; |
535 return true; |
536 } |
536 } |
537 |
537 |
538 /* It is safe to remove this company */ |
538 /* It is safe to remove this company */ |
539 DoCommandP(0, 2, index, NULL, CMD_PLAYER_CTRL); |
539 DoCommandP(0, 2, index, NULL, CMD_PLAYER_CTRL); |
540 IConsolePrint(_iconsole_color_default, "Company deleted."); |
540 IConsolePrint(_icolour_def, "Company deleted."); |
541 |
541 |
542 return true; |
542 return true; |
543 } |
543 } |
544 |
544 |
545 DEF_CONSOLE_CMD(ConNetworkClients) |
545 DEF_CONSOLE_CMD(ConNetworkClients) |
581 ip = argv[1]; |
581 ip = argv[1]; |
582 rport = NETWORK_DEFAULT_PORT; |
582 rport = NETWORK_DEFAULT_PORT; |
583 |
583 |
584 ParseConnectionString(&player, &port, ip); |
584 ParseConnectionString(&player, &port, ip); |
585 |
585 |
586 IConsolePrintF(_iconsole_color_default, "Connecting to %s...", ip); |
586 IConsolePrintF(_icolour_def, "Connecting to %s...", ip); |
587 if (player != NULL) { |
587 if (player != NULL) { |
588 _network_playas = atoi(player); |
588 _network_playas = atoi(player); |
589 IConsolePrintF(_iconsole_color_default, " player-no: %s", player); |
589 IConsolePrintF(_icolour_def, " player-no: %s", player); |
590 } |
590 } |
591 if (port != NULL) { |
591 if (port != NULL) { |
592 rport = atoi(port); |
592 rport = atoi(port); |
593 IConsolePrintF(_iconsole_color_default, " port: %s", port); |
593 IConsolePrintF(_icolour_def, " port: %s", port); |
594 } |
594 } |
595 |
595 |
596 NetworkClientConnectGame(ip, rport); |
596 NetworkClientConnectGame(ip, rport); |
597 |
597 |
598 return true; |
598 return true; |
671 } |
671 } |
672 |
672 |
673 if (!CloseConsoleLogIfActive()) { |
673 if (!CloseConsoleLogIfActive()) { |
674 if (argc < 2) return false; |
674 if (argc < 2) return false; |
675 |
675 |
676 IConsolePrintF(_iconsole_color_default, "file output started to: %s", argv[1]); |
676 IConsolePrintF(_icolour_def, "file output started to: %s", argv[1]); |
677 _iconsole_output_file = fopen(argv[1], "ab"); |
677 _iconsole_output_file = fopen(argv[1], "ab"); |
678 if (_iconsole_output_file == NULL) IConsoleError("could not open file"); |
678 if (_iconsole_output_file == NULL) IConsoleError("could not open file"); |
679 } |
679 } |
680 |
680 |
681 return true; |
681 return true; |
688 IConsoleHelp("Print back the first argument to the console. Usage: 'echo <arg>'"); |
688 IConsoleHelp("Print back the first argument to the console. Usage: 'echo <arg>'"); |
689 return true; |
689 return true; |
690 } |
690 } |
691 |
691 |
692 if (argc < 2) return false; |
692 if (argc < 2) return false; |
693 IConsolePrint(_iconsole_color_default, argv[1]); |
693 IConsolePrint(_icolour_def, argv[1]); |
694 return true; |
694 return true; |
695 } |
695 } |
696 |
696 |
697 DEF_CONSOLE_CMD(ConEchoC) |
697 DEF_CONSOLE_CMD(ConEchoC) |
698 { |
698 { |
779 if (var == NULL) { |
779 if (var == NULL) { |
780 IConsoleError("the given variable was not found"); |
780 IConsoleError("the given variable was not found"); |
781 return true; |
781 return true; |
782 } |
782 } |
783 |
783 |
784 IConsolePrintF(_iconsole_color_default, "variable name: %s", var->name); |
784 IConsolePrintF(_icolour_def, "variable name: %s", var->name); |
785 IConsolePrintF(_iconsole_color_default, "variable type: %s", _icon_vartypes[var->type]); |
785 IConsolePrintF(_icolour_def, "variable type: %s", _icon_vartypes[var->type]); |
786 IConsolePrintF(_iconsole_color_default, "variable addr: 0x%X", var->addr); |
786 IConsolePrintF(_icolour_def, "variable addr: 0x%X", var->addr); |
787 |
787 |
788 if (var->hook.access) IConsoleWarning("variable is access hooked"); |
788 if (var->hook.access) IConsoleWarning("variable is access hooked"); |
789 if (var->hook.pre) IConsoleWarning("variable is pre hooked"); |
789 if (var->hook.pre) IConsoleWarning("variable is pre hooked"); |
790 if (var->hook.post) IConsoleWarning("variable is post hooked"); |
790 if (var->hook.post) IConsoleWarning("variable is post hooked"); |
791 return true; |
791 return true; |
807 if (cmd == NULL) { |
807 if (cmd == NULL) { |
808 IConsoleError("the given command was not found"); |
808 IConsoleError("the given command was not found"); |
809 return true; |
809 return true; |
810 } |
810 } |
811 |
811 |
812 IConsolePrintF(_iconsole_color_default, "command name: %s", cmd->name); |
812 IConsolePrintF(_icolour_def, "command name: %s", cmd->name); |
813 IConsolePrintF(_iconsole_color_default, "command proc: 0x%X", cmd->proc); |
813 IConsolePrintF(_icolour_def, "command proc: 0x%X", cmd->proc); |
814 |
814 |
815 if (cmd->hook.access) IConsoleWarning("command is access hooked"); |
815 if (cmd->hook.access) IConsoleWarning("command is access hooked"); |
816 if (cmd->hook.pre) IConsoleWarning("command is pre hooked"); |
816 if (cmd->hook.pre) IConsoleWarning("command is pre hooked"); |
817 if (cmd->hook.post) IConsoleWarning("command is post hooked"); |
817 if (cmd->hook.post) IConsoleWarning("command is post hooked"); |
818 |
818 |
861 cmd = IConsoleCmdGet(alias->cmdline); |
861 cmd = IConsoleCmdGet(alias->cmdline); |
862 if (cmd != NULL) { |
862 if (cmd != NULL) { |
863 cmd->proc(0, NULL); |
863 cmd->proc(0, NULL); |
864 return true; |
864 return true; |
865 } |
865 } |
866 IConsolePrintF(_iconsole_color_error, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline); |
866 IConsolePrintF(_icolour_err, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline); |
867 return true; |
867 return true; |
868 } |
868 } |
869 |
869 |
870 var = IConsoleVarGet(argv[1]); |
870 var = IConsoleVarGet(argv[1]); |
871 if (var != NULL && var->help != NULL) { |
871 if (var != NULL && var->help != NULL) { |
904 |
904 |
905 if (argv[1] != NULL) l = strlen(argv[1]); |
905 if (argv[1] != NULL) l = strlen(argv[1]); |
906 |
906 |
907 for (cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) { |
907 for (cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) { |
908 if (argv[1] == NULL || strncmp(cmd->name, argv[1], l) == 0) { |
908 if (argv[1] == NULL || strncmp(cmd->name, argv[1], l) == 0) { |
909 IConsolePrintF(_iconsole_color_default, "%s", cmd->name); |
909 IConsolePrintF(_icolour_def, "%s", cmd->name); |
910 } |
910 } |
911 } |
911 } |
912 |
912 |
913 return true; |
913 return true; |
914 } |
914 } |
925 |
925 |
926 if (argv[1] != NULL) l = strlen(argv[1]); |
926 if (argv[1] != NULL) l = strlen(argv[1]); |
927 |
927 |
928 for (var = _iconsole_vars; var != NULL; var = var->next) { |
928 for (var = _iconsole_vars; var != NULL; var = var->next) { |
929 if (argv[1] == NULL || strncmp(var->name, argv[1], l) == 0) |
929 if (argv[1] == NULL || strncmp(var->name, argv[1], l) == 0) |
930 IConsolePrintF(_iconsole_color_default, "%s", var->name); |
930 IConsolePrintF(_icolour_def, "%s", var->name); |
931 } |
931 } |
932 |
932 |
933 return true; |
933 return true; |
934 } |
934 } |
935 |
935 |
945 |
945 |
946 if (argv[1] != NULL) l = strlen(argv[1]); |
946 if (argv[1] != NULL) l = strlen(argv[1]); |
947 |
947 |
948 for (alias = _iconsole_aliases; alias != NULL; alias = alias->next) { |
948 for (alias = _iconsole_aliases; alias != NULL; alias = alias->next) { |
949 if (argv[1] == NULL || strncmp(alias->name, argv[1], l) == 0) |
949 if (argv[1] == NULL || strncmp(alias->name, argv[1], l) == 0) |
950 IConsolePrintF(_iconsole_color_default, "%s => %s", alias->name, alias->cmdline); |
950 IConsolePrintF(_icolour_def, "%s => %s", alias->name, alias->cmdline); |
951 } |
951 } |
952 |
952 |
953 return true; |
953 return true; |
954 } |
954 } |
955 |
955 |
981 } |
981 } |
982 |
982 |
983 if (argc != 3) return false; |
983 if (argc != 3) return false; |
984 |
984 |
985 if (atoi(argv[1]) < 1 || atoi(argv[1]) > MAX_PLAYERS) { |
985 if (atoi(argv[1]) < 1 || atoi(argv[1]) > MAX_PLAYERS) { |
986 IConsolePrintF(_iconsole_color_default, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS); |
986 IConsolePrintF(_icolour_def, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS); |
987 return true; |
987 return true; |
988 } |
988 } |
989 |
989 |
990 if (!_network_server) { |
990 if (!_network_server) { |
991 SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]); |
991 SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]); |
1037 /* Also use from within player_gui to change the password graphically */ |
1037 /* Also use from within player_gui to change the password graphically */ |
1038 bool NetworkChangeCompanyPassword(byte argc, char *argv[]) |
1038 bool NetworkChangeCompanyPassword(byte argc, char *argv[]) |
1039 { |
1039 { |
1040 if (argc == 0) { |
1040 if (argc == 0) { |
1041 if (_local_player >= MAX_PLAYERS) return true; // dedicated server |
1041 if (_local_player >= MAX_PLAYERS) return true; // dedicated server |
1042 IConsolePrintF(_iconsole_color_warning, "Current value for 'company_pw': %s", _network_player_info[_local_player].password); |
1042 IConsolePrintF(_icolour_warn, "Current value for 'company_pw': %s", _network_player_info[_local_player].password); |
1043 return true; |
1043 return true; |
1044 } |
1044 } |
1045 |
1045 |
1046 if (_local_player >= MAX_PLAYERS) { |
1046 if (_local_player >= MAX_PLAYERS) { |
1047 IConsoleError("You have to own a company to make use of this command."); |
1047 IConsoleError("You have to own a company to make use of this command."); |
1098 } |
1098 } |
1099 |
1099 |
1100 DEF_CONSOLE_CMD(ConProcServerIP) |
1100 DEF_CONSOLE_CMD(ConProcServerIP) |
1101 { |
1101 { |
1102 if (argc == 0) { |
1102 if (argc == 0) { |
1103 IConsolePrintF(_iconsole_color_warning, "Current value for 'server_ip': %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip)); |
1103 IConsolePrintF(_icolour_warn, "Current value for 'server_ip': %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip)); |
1104 return true; |
1104 return true; |
1105 } |
1105 } |
1106 |
1106 |
1107 if (argc != 1) return false; |
1107 if (argc != 1) return false; |
1108 |
1108 |