5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "console.h" |
7 #include "console.h" |
8 #include "debug.h" |
8 #include "debug.h" |
9 #include "engine.h" |
9 #include "engine.h" |
10 #include "functions.h" |
|
11 #include "landscape.h" |
10 #include "landscape.h" |
12 #include "saveload.h" |
11 #include "saveload.h" |
13 #include "string.h" |
|
14 #include "variables.h" |
12 #include "variables.h" |
15 #include "network/network_data.h" |
13 #include "network/network_data.h" |
16 #include "network/network_client.h" |
14 #include "network/network_client.h" |
17 #include "network/network_server.h" |
15 #include "network/network_server.h" |
18 #include "network/network_udp.h" |
16 #include "network/network_udp.h" |
19 #include "command.h" |
17 #include "command_func.h" |
20 #include "settings.h" |
18 #include "settings_func.h" |
21 #include "fios.h" |
19 #include "fios.h" |
22 #include "fileio.h" |
20 #include "fileio.h" |
23 #include "vehicle.h" |
|
24 #include "station.h" |
21 #include "station.h" |
25 #include "strings.h" |
|
26 #include "screenshot.h" |
22 #include "screenshot.h" |
27 #include "genworld.h" |
23 #include "genworld.h" |
28 #include "date.h" |
|
29 #include "network/network.h" |
24 #include "network/network.h" |
|
25 #include "strings_func.h" |
|
26 #include "viewport_func.h" |
|
27 #include "window_func.h" |
|
28 #include "functions.h" |
|
29 #include "map_func.h" |
|
30 #include "date_func.h" |
|
31 #include "vehicle_func.h" |
|
32 #include "string_func.h" |
30 |
33 |
31 // ** scriptfile handling ** // |
34 // ** scriptfile handling ** // |
32 static FILE *_script_file; |
35 static FILE *_script_file; |
33 static bool _script_running; |
36 static bool _script_running; |
34 |
37 |
132 return false; |
135 return false; |
133 } |
136 } |
134 |
137 |
135 DEF_CONSOLE_CMD(ConStopAllVehicles) |
138 DEF_CONSOLE_CMD(ConStopAllVehicles) |
136 { |
139 { |
137 Vehicle* v; |
|
138 if (argc == 0) { |
140 if (argc == 0) { |
139 IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'"); |
141 IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'"); |
140 return true; |
142 return true; |
141 } |
143 } |
142 |
144 |
143 FOR_ALL_VEHICLES(v) { |
145 StopAllVehicles(); |
144 /* Code ripped from CmdStartStopTrain. Can't call it, because of |
|
145 * ownership problems, so we'll duplicate some code, for now */ |
|
146 v->vehstatus |= VS_STOPPED; |
|
147 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
|
148 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
|
149 } |
|
150 return true; |
146 return true; |
151 } |
147 } |
152 #endif /* _DEBUG */ |
148 #endif /* _DEBUG */ |
153 |
149 |
154 DEF_CONSOLE_CMD(ConScrollToTile) |
150 DEF_CONSOLE_CMD(ConScrollToTile) |
231 |
227 |
232 i = strtol(file, &endptr, 10); |
228 i = strtol(file, &endptr, 10); |
233 if (file == endptr || *endptr != '\0') i = -1; |
229 if (file == endptr || *endptr != '\0') i = -1; |
234 } |
230 } |
235 |
231 |
236 return IS_INT_INSIDE(i, 0, _fios_num) ? &_fios_list[i] : NULL; |
232 return IsInsideMM(i, 0, _fios_num) ? &_fios_list[i] : NULL; |
237 } |
233 } |
238 |
234 |
239 |
235 |
240 DEF_CONSOLE_CMD(ConLoad) |
236 DEF_CONSOLE_CMD(ConLoad) |
241 { |
237 { |
1324 ttd_strlcpy(_network_game_info.rcon_password, _network_rcon_password, sizeof(_network_game_info.rcon_password)); |
1320 ttd_strlcpy(_network_game_info.rcon_password, _network_rcon_password, sizeof(_network_game_info.rcon_password)); |
1325 |
1321 |
1326 return true; |
1322 return true; |
1327 } |
1323 } |
1328 |
1324 |
|
1325 extern void HashCurrentCompanyPassword(); |
|
1326 |
1329 /* Also use from within player_gui to change the password graphically */ |
1327 /* Also use from within player_gui to change the password graphically */ |
1330 bool NetworkChangeCompanyPassword(byte argc, char *argv[]) |
1328 bool NetworkChangeCompanyPassword(byte argc, char *argv[]) |
1331 { |
1329 { |
1332 if (argc == 0) { |
1330 if (argc == 0) { |
1333 if (!IsValidPlayer(_local_player)) return true; // dedicated server |
1331 if (!IsValidPlayer(_local_player)) return true; // dedicated server |
1344 |
1342 |
1345 if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0'; |
1343 if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0'; |
1346 |
1344 |
1347 ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password)); |
1345 ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password)); |
1348 |
1346 |
1349 if (!_network_server) |
1347 if (!_network_server) { |
1350 SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password); |
1348 SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password); |
|
1349 } else { |
|
1350 HashCurrentCompanyPassword(); |
|
1351 } |
1351 |
1352 |
1352 IConsolePrintF(_icolour_warn, "'company_pw' changed to: %s", _network_player_info[_local_player].password); |
1353 IConsolePrintF(_icolour_warn, "'company_pw' changed to: %s", _network_player_info[_local_player].password); |
1353 |
1354 |
1354 return true; |
1355 return true; |
1355 } |
1356 } |