equal
deleted
inserted
replaced
1 /* $Id$ */ |
1 /* $Id$ */ |
|
2 |
|
3 /** @file console_cmds.cpp */ |
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "console.h" |
7 #include "console.h" |
6 #include "debug.h" |
8 #include "debug.h" |
224 for (i = 0; i < _fios_num; i++) { |
226 for (i = 0; i < _fios_num; i++) { |
225 if (strcmp(file, _fios_list[i].name) == 0) break; |
227 if (strcmp(file, _fios_list[i].name) == 0) break; |
226 if (strcmp(file, _fios_list[i].title) == 0) break; |
228 if (strcmp(file, _fios_list[i].title) == 0) break; |
227 } |
229 } |
228 |
230 |
229 if (i == _fios_num) { /* If no name matches, try to parse it as number */ |
231 if (i == _fios_num) { // If no name matches, try to parse it as number |
230 char* endptr; |
232 char* endptr; |
231 |
233 |
232 i = strtol(file, &endptr, 10); |
234 i = strtol(file, &endptr, 10); |
233 if (file == endptr || *endptr != '\0') i = -1; |
235 if (file == endptr || *endptr != '\0') i = -1; |
234 } |
236 } |
612 return true; |
614 return true; |
613 } |
615 } |
614 |
616 |
615 DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount) |
617 DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount) |
616 { |
618 { |
617 /* XXX @see ConHookValidateMaxClientsCount */ |
619 /* XXX see ConHookValidateMaxClientsCount */ |
618 if (_network_game_info.spectators_max > 10) { |
620 if (_network_game_info.spectators_max > 10) { |
619 _network_game_info.spectators_max = 10; |
621 _network_game_info.spectators_max = 10; |
620 IConsoleError("Maximum spectators out of bounds, truncating to limit."); |
622 IConsoleError("Maximum spectators out of bounds, truncating to limit."); |
621 } |
623 } |
622 |
624 |
1340 { |
1342 { |
1341 NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index); |
1343 NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index); |
1342 |
1344 |
1343 if (ci == NULL) return false; |
1345 if (ci == NULL) return false; |
1344 |
1346 |
1345 // Don't change the name if it is the same as the old name |
1347 /* Don't change the name if it is the same as the old name */ |
1346 if (strcmp(ci->client_name, _network_player_name) != 0) { |
1348 if (strcmp(ci->client_name, _network_player_name) != 0) { |
1347 if (!_network_server) { |
1349 if (!_network_server) { |
1348 SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_network_player_name); |
1350 SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_network_player_name); |
1349 } else { |
1351 } else { |
1350 if (NetworkFindName(_network_player_name)) { |
1352 if (NetworkFindName(_network_player_name)) { |
1439 /* debug commands and variables */ |
1441 /* debug commands and variables */ |
1440 /* ****************************************** */ |
1442 /* ****************************************** */ |
1441 |
1443 |
1442 static void IConsoleDebugLibRegister(void) |
1444 static void IConsoleDebugLibRegister(void) |
1443 { |
1445 { |
1444 // debugging variables and functions |
1446 /* debugging variables and functions */ |
1445 extern bool _stdlib_con_developer; /* XXX extern in .c */ |
1447 extern bool _stdlib_con_developer; // XXX extern in .cpp |
1446 |
1448 |
1447 IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN, "Enable/disable console debugging information (internal)"); |
1449 IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN, "Enable/disable console debugging information (internal)"); |
1448 IConsoleCmdRegister("resettile", ConResetTile); |
1450 IConsoleCmdRegister("resettile", ConResetTile); |
1449 IConsoleCmdRegister("stopall", ConStopAllVehicles); |
1451 IConsoleCmdRegister("stopall", ConStopAllVehicles); |
1450 IConsoleAliasRegister("dbg_echo", "echo %A; echo %B"); |
1452 IConsoleAliasRegister("dbg_echo", "echo %A; echo %B"); |
1456 /* console command and variable registration */ |
1458 /* console command and variable registration */ |
1457 /* ****************************************** */ |
1459 /* ****************************************** */ |
1458 |
1460 |
1459 void IConsoleStdLibRegister(void) |
1461 void IConsoleStdLibRegister(void) |
1460 { |
1462 { |
1461 // stdlib |
1463 /* stdlib */ |
1462 extern byte _stdlib_developer; /* XXX extern in .c */ |
1464 extern byte _stdlib_developer; // XXX extern in .cpp |
1463 |
1465 |
1464 // default variables and functions |
1466 /* default variables and functions */ |
1465 IConsoleCmdRegister("debug_level", ConDebugLevel); |
1467 IConsoleCmdRegister("debug_level", ConDebugLevel); |
1466 IConsoleCmdRegister("dump_vars", ConListDumpVariables); |
1468 IConsoleCmdRegister("dump_vars", ConListDumpVariables); |
1467 IConsoleCmdRegister("echo", ConEcho); |
1469 IConsoleCmdRegister("echo", ConEcho); |
1468 IConsoleCmdRegister("echoc", ConEchoC); |
1470 IConsoleCmdRegister("echoc", ConEchoC); |
1469 IConsoleCmdRegister("exec", ConExec); |
1471 IConsoleCmdRegister("exec", ConExec); |