annotate src/console_cmds.cpp @ 17564:d5ff867052a5 draft

(svn r22328) -Add: a flag to GroundVehicles to disable insertion and removal of automatic orders until the next real order is reached.
author frosch <frosch@openttd.org>
date Sat, 16 Apr 2011 16:45:35 +0000
parents 98f9e9b40aa3
children 0a51450014d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
5 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
6 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
7 * 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/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12645
diff changeset
9
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
10 /** @file console_cmds.cpp Implementation of the console hooks. */
6123
595dc16a6fd8 (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 5624
diff changeset
11
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
9336
5287277c4972 (svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents: 9271
diff changeset
13 #include "console_internal.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "debug.h"
8786
e2d4956b7251 (svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium <rubidium@openttd.org>
parents: 8504
diff changeset
15 #include "engine_func.h"
6453
666fc3ef3174 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros <maedhros@openttd.org>
parents: 6429
diff changeset
16 #include "landscape.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents: 10499
diff changeset
17 #include "saveload/saveload.h"
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
18 #include "network/network.h"
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
19 #include "network/network_func.h"
10468
0edf9b619634 (svn r14723) -Codechange: shuffling some stuff around to reduce indirect #include dependencies.
rubidium <rubidium@openttd.org>
parents: 10462
diff changeset
20 #include "network/network_base.h"
16273
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
21 #include "network/network_admin.h"
17323
1f1269635087 (svn r22063) -Change: make the "has network" check also check whether the client is actually fully connected
rubidium <rubidium@openttd.org>
parents: 17235
diff changeset
22 #include "network/network_client.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
23 #include "command_func.h"
8208
ddc34919158f (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents: 8144
diff changeset
24 #include "settings_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
25 #include "fios.h"
10039
6301378f3e0f (svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium <rubidium@openttd.org>
parents: 9893
diff changeset
26 #include "fileio_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
27 #include "screenshot.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
28 #include "genworld.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 7999
diff changeset
29 #include "strings_func.h"
8225
0e48dd14a0d8 (svn r11788) -Fix (11787): makedepend doesn't mark delete files as changed...
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
30 #include "viewport_func.h"
8131
e300ac8001ae (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents: 8121
diff changeset
31 #include "window_func.h"
8140
fb8a05d579da (svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents: 8139
diff changeset
32 #include "date_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
33 #include "company_func.h"
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
34 #include "gamelog.h"
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
35 #include "ai/ai.hpp"
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
36 #include "ai/ai_config.hpp"
14918
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
37 #include "newgrf.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 14065
diff changeset
38 #include "console_func.h"
17235
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
39 #include "engine_base.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
41 #ifdef ENABLE_NETWORK
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
42 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
43 #endif /* ENABLE_NETWORK */
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
44
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
45 /* scriptfile handling */
15379
46202127b446 (svn r20022) -Doc: Add some doxygen comments.
alberth <alberth@openttd.org>
parents: 15378
diff changeset
46 static bool _script_running; ///< Script is running (used to abort execution when #ConReturn is encountered).
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
48 /* console command defines */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 #define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
50 #define DEF_CONSOLE_HOOK(function) static ConsoleHookResult function(bool echo)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
52
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
53 /****************
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
54 * command hooks
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
55 ****************/
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
59 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
60 * Check network availability and inform in console about failure of detection.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
61 * @return Network availability.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
62 */
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
63 static inline bool NetworkAvailable(bool echo)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 if (!_network_available) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
66 if (echo) IConsoleError("You cannot use this command because there is no network available.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
72 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
73 * Check whether we are a server.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
74 * @return Are we a server? True when yes, false otherwise.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
75 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 DEF_CONSOLE_HOOK(ConHookServerOnly)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
78 if (!NetworkAvailable(echo)) return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80 if (!_network_server) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
81 if (echo) IConsoleError("This command is only available to a network server.");
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
82 return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83 }
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
84 return CHR_ALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
87 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
88 * Check whether we are a client in a network game.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
89 * @return Are we a client in a network game? True when yes, false otherwise.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
90 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91 DEF_CONSOLE_HOOK(ConHookClientOnly)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
93 if (!NetworkAvailable(echo)) return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 if (_network_server) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
96 if (echo) IConsoleError("This command is not available to a network server.");
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
97 return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
98 }
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
99 return CHR_ALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
102 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
103 * Check whether we are in a multiplayer game.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
104 * @return True when we are client or server in a network game.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
105 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106 DEF_CONSOLE_HOOK(ConHookNeedNetwork)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
108 if (!NetworkAvailable(echo)) return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109
17323
1f1269635087 (svn r22063) -Change: make the "has network" check also check whether the client is actually fully connected
rubidium <rubidium@openttd.org>
parents: 17235
diff changeset
110 if (!_networking || (!_network_server && !MyClient::IsConnected())) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
111 if (echo) IConsoleError("Not connected. This command is only available in multiplayer.");
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
112 return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
113 }
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
114 return CHR_ALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
116
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
117 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
118 * Check whether we are in single player mode.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
119 * @return True when no network is active.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
120 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121 DEF_CONSOLE_HOOK(ConHookNoNetwork)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
123 if (_networking) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
124 if (echo) IConsoleError("This command is forbidden in multiplayer.");
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
125 return CHR_DISALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
126 }
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
127 return CHR_ALLOW;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
130 #else
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
131 # define ConHookNoNetwork NULL
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
133
14918
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
134 DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
135 {
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
136 if (_settings_client.gui.newgrf_developer_tools) {
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
137 if (_game_mode == GM_MENU) {
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
138 if (echo) IConsoleError("This command is only available in game and editor.");
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
139 return CHR_DISALLOW;
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
140 }
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
141 #ifdef ENABLE_NETWORK
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
142 return ConHookNoNetwork(echo);
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
143 #else
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
144 return CHR_ALLOW;
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
145 #endif
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
146 }
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
147 return CHR_HIDE;
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
148 }
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
149
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
150 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
151 * Show help for the console.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
152 * @param str String to print in the console.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
153 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 static void IConsoleHelp(const char *str)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
156 IConsolePrintF(CC_WARNING, "- %s", str);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
159 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
160 * Reset status of all engines.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
161 * @return Will always succeed.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
162 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163 DEF_CONSOLE_CMD(ConResetEngines)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166 IConsoleHelp("Reset status data of all engines. This might solve some issues with 'lost' engines. Usage: 'resetengines'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
169
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 StartupEngines();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
172 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
174 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
175 * Reset status of the engine pool.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
176 * @return Will always return true.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
177 * @note Resetting the pool only succeeds when there are no vehicles ingame.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
178 */
17235
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
179 DEF_CONSOLE_CMD(ConResetEnginePool)
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
180 {
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
181 if (argc == 0) {
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
182 IConsoleHelp("Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again.");
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
183 return true;
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
184 }
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
185
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
186 if (_game_mode == GM_MENU) {
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
187 IConsoleError("This command is only available in game and editor.");
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
188 return true;
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
189 }
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
190
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
191 if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) {
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
192 IConsoleError("This can only be done when there are no vehicles in the game.");
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
193 return true;
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
194 }
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
195
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
196 return true;
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
197 }
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
198
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
199 #ifdef _DEBUG
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
200 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
201 * Reset a tile to bare land in debug mode.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
202 * param tile number.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
203 * @return True when the tile is reset or the help on usage was printed (0 or two parameters).
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
204 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
205 DEF_CONSOLE_CMD(ConResetTile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
206 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
207 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
208 IConsoleHelp("Reset a tile to bare land. Usage: 'resettile <tile>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209 IConsoleHelp("Tile can be either decimal (34161) or hexadecimal (0x4a5B)");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
213 if (argc == 2) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
214 uint32 result;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215 if (GetArgumentInteger(&result, argv[1])) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216 DoClearSquare((TileIndex)result);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
217 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
218 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
219 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
222 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
223 #endif /* _DEBUG */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
224
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
225 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
226 * Scroll to a tile on the map.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
227 * @param arg1 tile tile number or tile x coordinate.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
228 * @param arg2 optionally tile y coordinate.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
229 * @note When only one argument is given it is intepreted as the tile number.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
230 * When two arguments are given, they are interpreted as the tile's x
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
231 * and y coordinates.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
232 * @return True when either console help was shown or a proper amount of parameters given.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
233 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
234 DEF_CONSOLE_CMD(ConScrollToTile)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
235 {
12025
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
236 switch (argc) {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
237 case 0:
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
238 IConsoleHelp("Center the screen on a given tile.");
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
239 IConsoleHelp("Usage: 'scrollto <tile>' or 'scrollto <x> <y>'");
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
240 IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B).");
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
241 return true;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
242
12025
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
243 case 2: {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
244 uint32 result;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
245 if (GetArgumentInteger(&result, argv[1])) {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
246 if (result >= MapSize()) {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
247 IConsolePrint(CC_ERROR, "Tile does not exist");
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
248 return true;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
249 }
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
250 ScrollMainWindowToTile((TileIndex)result);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
251 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
252 }
12025
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
253 break;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
254 }
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
255
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
256 case 3: {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
257 uint32 x, y;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
258 if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
259 if (x >= MapSizeX() || y >= MapSizeY()) {
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
260 IConsolePrint(CC_ERROR, "Tile does not exist");
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
261 return true;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
262 }
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
263 ScrollMainWindowToTile(TileXY(x, y));
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
264 return true;
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
265 }
1eceb7d6fb2f (svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
smatz <smatz@openttd.org>
parents: 12014
diff changeset
266 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
272
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
273 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
274 * Save the map to a file.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
275 * @param filename the filename to save the map to.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
276 * @return True when help was displayed or the file attempted to be saved.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
277 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
278 DEF_CONSOLE_CMD(ConSave)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281 IConsoleHelp("Save the current game. Usage: 'save <filename>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
284
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
285 if (argc == 2) {
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6890
diff changeset
286 char *filename = str_fmt("%s.sav", argv[1]);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
287 IConsolePrint(CC_DEFAULT, "Saving map...");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
288
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6890
diff changeset
289 if (SaveOrLoad(filename, SL_SAVE, SAVE_DIR) != SL_OK) {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
290 IConsolePrint(CC_ERROR, "Saving map failed");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291 } else {
14422
65de2573b474 (svn r18979) -Fix: Typo in console save command output.
matthijs <matthijs@openttd.org>
parents: 14387
diff changeset
292 IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
293 }
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6890
diff changeset
294 free(filename);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
295 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
296 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
297
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
298 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
299 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
300
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
301 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
302 * Explicitly save the configuration.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
303 * @return True.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
304 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
305 DEF_CONSOLE_CMD(ConSaveConfig)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
306 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
307 if (argc == 0) {
15505
dd28864682e7 (svn r20157) -Fix [FS#3950]: make it *very* clear that saveconfig doesn't save the configuration of a running savegame to openttd.cfg, but the one that would be used for new games
rubidium <rubidium@openttd.org>
parents: 15379
diff changeset
308 IConsoleHelp("Saves the configuration for new games to the configuration file, typically 'openttd.cfg'.");
dd28864682e7 (svn r20157) -Fix [FS#3950]: make it *very* clear that saveconfig doesn't save the configuration of a running savegame to openttd.cfg, but the one that would be used for new games
rubidium <rubidium@openttd.org>
parents: 15379
diff changeset
309 IConsoleHelp("It does not save the configuration of the current game to the configuration file.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
310 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
311 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
312
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
313 SaveToConfig();
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
314 IConsolePrint(CC_DEFAULT, "Saved config.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
315 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
316 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
317
17340
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
318 /**
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
319 * Get savegame file informations.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
320 * @param file The savegame filename to return information about. Can be the actual name
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
321 * or a numbered entry into the filename list.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
322 * @return FiosItem The information on the file.
ed1445ee6e5f (svn r22080) -Doc: Add doxygen comments to a few functions and improve a few existing comments
planetmaker <planetmaker@openttd.org>
parents: 17323
diff changeset
323 */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10594
diff changeset
324 static const FiosItem *GetFiosItem(const char *file)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
325 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
326 _saveload_mode = SLD_LOAD_GAME;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
327 BuildFileList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
328
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
329 for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
330 if (strcmp(file, item->name) == 0) return item;
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
331 if (strcmp(file, item->title) == 0) return item;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
332 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
333
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
334 /* If no name matches, try to parse it as number */
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
335 char *endptr;
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
336 int i = strtol(file, &endptr, 10);
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
337 if (file == endptr || *endptr != '\0') i = -1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
338
15250
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
339 if (IsInsideMM(i, 0, _fios_items.Length())) return _fios_items.Get(i);
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
340
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
341 /* As a last effort assume it is an OpenTTD savegame and
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
342 * that the ".sav" part was not given. */
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
343 char long_file[MAX_PATH];
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
344 seprintf(long_file, lastof(long_file), "%s.sav", file);
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
345 for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
346 if (strcmp(long_file, item->name) == 0) return item;
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
347 if (strcmp(long_file, item->title) == 0) return item;
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
348 }
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
349
91e0e573c069 (svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
rubidium <rubidium@openttd.org>
parents: 15189
diff changeset
350 return NULL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
351 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
352
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
354 DEF_CONSOLE_CMD(ConLoad)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
356 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 IConsoleHelp("Load a game by name or index. Usage: 'load <file | number>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
358 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
359 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
361 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
362
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
363 const char *file = argv[1];
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
364 const FiosItem *item = GetFiosItem(file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
365 if (item != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
366 switch (item->type) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
367 case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
368 _switch_mode = SM_LOAD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
369 SetFiosType(item->type);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
370
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10208
diff changeset
371 strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10208
diff changeset
372 strecpy(_file_to_saveload.title, item->title, lastof(_file_to_saveload.title));
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15552
diff changeset
373 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15552
diff changeset
374 }
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
375 default: IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
376 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
377 } else {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
378 IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
379 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
380
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
381 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
386 DEF_CONSOLE_CMD(ConRemove)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
389 IConsoleHelp("Remove a savegame by name or index. Usage: 'rm <file | number>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
392
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
393 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
395 const char *file = argv[1];
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
396 const FiosItem *item = GetFiosItem(file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
397 if (item != NULL) {
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15505
diff changeset
398 if (!FiosDelete(item->name)) {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
399 IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file);
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15505
diff changeset
400 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
401 } else {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
402 IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
406 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
407 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
409
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 /* List all the files in the current dir via console */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411 DEF_CONSOLE_CMD(ConListFiles)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
412 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
413 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
414 IConsoleHelp("List all loadable savegames and directories in the current dir via console. Usage: 'ls | dir'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
415 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
416 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
417
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
418 BuildFileList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
419
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
420 for (uint i = 0; i < _fios_items.Length(); i++) {
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
421 IConsolePrintF(CC_DEFAULT, "%d) %s", i, _fios_items[i].title);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
426 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 /* Change the dir via console */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429 DEF_CONSOLE_CMD(ConChangeDirectory)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
430 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
431 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
432 IConsoleHelp("Change the dir via console. Usage: 'cd <directory | number>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
433 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
436 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
437
9441
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
438 const char *file = argv[1];
e899ed594e7c (svn r13359) -Codechange: convert _fios_items to a SmallVector
skidd13 <skidd13@openttd.org>
parents: 9428
diff changeset
439 const FiosItem *item = GetFiosItem(file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 if (item != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
441 switch (item->type) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
443 FiosBrowseTo(item);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
444 break;
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
445 default: IConsolePrintF(CC_ERROR, "%s: Not a directory.", file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
446 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
447 } else {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
448 IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
450
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
451 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
452 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
453 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455 DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 const char *path;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
458
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
459 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
460 IConsoleHelp("Print out the current working directory. Usage: 'pwd'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
461 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
462 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
463
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
464 /* XXX - Workaround for broken file handling */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
465 FiosGetSavegameList(SLD_LOAD_GAME);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 FiosFreeSavegameList();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
468 FiosGetDescText(&path, NULL);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
469 IConsolePrint(CC_DEFAULT, path);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
470 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
471 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
473 DEF_CONSOLE_CMD(ConClearBuffer)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
474 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
475 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476 IConsoleHelp("Clear the console buffer. Usage: 'clear'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
477 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
478 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
479
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
480 IConsoleClearBuffer();
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12972
diff changeset
481 SetWindowDirty(WC_CONSOLE, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
482 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
483 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
484
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
485
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
486 /**********************************
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
487 * Network Core Console Commands
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
488 **********************************/
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
489 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
490
15189
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
491 static bool ConKickOrBan(const char *argv, bool ban)
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
492 {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
493 const char *ip = argv;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
494
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
495 if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
496 ClientID client_id = (ClientID)atoi(argv);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
497
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
498 if (client_id == CLIENT_ID_SERVER) {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
499 IConsolePrintF(CC_ERROR, "ERROR: Silly boy, you can not %s yourself!", ban ? "ban" : "kick");
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
500 return true;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
501 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
502
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
503 NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
504 if (ci == NULL) {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
505 IConsoleError("Invalid client");
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
506 return true;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
507 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
508
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
509 if (!ban) {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
510 /* Kick only this client, not all clients with that IP */
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
511 NetworkServerKickClient(client_id);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
512 return true;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
513 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
514
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
515 /* When banning, kick+ban all clients with that IP */
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
516 ip = GetClientIP(ci);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
517 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
518
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
519 uint n = NetworkServerKickOrBanIP(ip, ban);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
520 if (n == 0) {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
521 IConsolePrint(CC_DEFAULT, ban ? "Client not online, address added to banlist" : "Client not found");
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
522 } else {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
523 IConsolePrintF(CC_DEFAULT, "%sed %u client(s)", ban ? "Bann" : "Kick", n);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
524 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
525
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
526 return true;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
527 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
528
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
529 DEF_CONSOLE_CMD(ConKick)
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
530 {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
531 if (argc == 0) {
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
532 IConsoleHelp("Kick a client from a network game. Usage: 'kick <ip | client-id>'");
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
533 IConsoleHelp("For client-id's, see the command 'clients'");
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
534 return true;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
535 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
536
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
537 if (argc != 2) return false;
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
538
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
539 return ConKickOrBan(argv[1], false);
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
540 }
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
541
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
542 DEF_CONSOLE_CMD(ConBan)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
543 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
544 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
545 IConsoleHelp("Ban a client from a network game. Usage: 'ban <ip | client-id>'");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
546 IConsoleHelp("For client-id's, see the command 'clients'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
547 IConsoleHelp("If the client is no longer online, you can still ban his/her IP");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
548 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
549 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
550
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
551 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552
15189
185fd61182ab (svn r19818) -Fix [FS#3784](r16004): kicking clients by IP didn't work
smatz <smatz@openttd.org>
parents: 15096
diff changeset
553 return ConKickOrBan(argv[1], true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
554 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
555
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
556 DEF_CONSOLE_CMD(ConUnBan)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
557 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
558
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
559 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
560 IConsoleHelp("Unban a client from a network game. Usage: 'unban <ip | client-id>'");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
561 IConsoleHelp("For a list of banned IP's, see the command 'banlist'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
563 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
565 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566
11565
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
567 uint index = (strchr(argv[1], '.') == NULL) ? atoi(argv[1]) : 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568 index--;
11565
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
569 uint i = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570
11565
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
571 for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572 if (strcmp(_network_ban_list[i], argv[1]) == 0 || index == i) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
573 free(_network_ban_list[i]);
11565
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
574 _network_ban_list.Erase(iter);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
575 IConsolePrint(CC_DEFAULT, "IP unbanned.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
577 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
578 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
580 IConsolePrint(CC_DEFAULT, "IP not in ban-list.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584 DEF_CONSOLE_CMD(ConBanList)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
585 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
587 IConsoleHelp("List the IP's of banned clients: Usage 'banlist'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
588 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
589 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
591 IConsolePrint(CC_DEFAULT, "Banlist: ");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592
11565
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
593 uint i = 1;
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
594 for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++, i++) {
cf37aec7c469 (svn r15931) -Codechange: let the host and ban lists use of SmallVector.
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
595 IConsolePrintF(CC_DEFAULT, " %d) %s", i, *iter);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
596 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
597
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
598 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
599 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
600
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
601 DEF_CONSOLE_CMD(ConPauseGame)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
602 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
603 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
604 IConsoleHelp("Pause a network game. Usage: 'pause'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
605 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
606 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
607
13532
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
608 if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11786
diff changeset
609 DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
13532
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
610 if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
611 } else {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
612 IConsolePrint(CC_DEFAULT, "Game is already paused.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
613 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
614
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
615 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
616 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
617
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
618 DEF_CONSOLE_CMD(ConUnPauseGame)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
619 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
620 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
621 IConsoleHelp("Unpause a network game. Usage: 'unpause'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
622 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
623 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
624
13532
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
625 if ((_pause_mode & PM_PAUSED_NORMAL) != PM_UNPAUSED) {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11786
diff changeset
626 DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
13532
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
627 if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused.");
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
628 } else if ((_pause_mode & PM_PAUSED_ERROR) != PM_UNPAUSED) {
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
629 IConsolePrint(CC_DEFAULT, "Game is in error state and cannot be unpaused via console.");
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
630 } else if (_pause_mode != PM_UNPAUSED) {
6386a541e470 (svn r18053) -Codechange: remove the manual pause/unpause limitation with min_active_clients
rubidium <rubidium@openttd.org>
parents: 13432
diff changeset
631 IConsolePrint(CC_DEFAULT, "Game cannot be unpaused manually; disable pause_on_join/min_active_clients.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
632 } else {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
633 IConsolePrint(CC_DEFAULT, "Game is already unpaused.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
634 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
635
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
636 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
637 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
638
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
639 DEF_CONSOLE_CMD(ConRcon)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
640 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
641 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
642 IConsoleHelp("Remote control the server from another client. Usage: 'rcon <password> <command>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
643 IConsoleHelp("Remember to enclose the command in quotes, otherwise only the first parameter is sent");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
644 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
645 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
646
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
647 if (argc < 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
648
9271
8da6eb0664f0 (svn r13137) -Fix: do not send rcon commands of the server to the first client but do directly execute those on the server.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
649 if (_network_server) {
8da6eb0664f0 (svn r13137) -Fix: do not send rcon commands of the server to the first client but do directly execute those on the server.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
650 IConsoleCmdExec(argv[2]);
8da6eb0664f0 (svn r13137) -Fix: do not send rcon commands of the server to the first client but do directly execute those on the server.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
651 } else {
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
652 NetworkClientSendRcon(argv[1], argv[2]);
9271
8da6eb0664f0 (svn r13137) -Fix: do not send rcon commands of the server to the first client but do directly execute those on the server.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
653 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
654 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
655 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
656
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
657 DEF_CONSOLE_CMD(ConStatus)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
658 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
659 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
660 IConsoleHelp("List the status of all clients connected to the server. Usage 'status'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
661 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
662 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
663
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
664 NetworkServerShowStatusToConsole();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
665 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
666 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
667
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
668 DEF_CONSOLE_CMD(ConServerInfo)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
669 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
670 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
671 IConsoleHelp("List current and maximum client/company limits. Usage 'server_info'");
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
672 IConsoleHelp("You can change these values by modifying settings 'network.max_clients', 'network.max_companies' and 'network.max_spectators'");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
673 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
674 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
675
9451
49dffcace617 (svn r13369) -Codechange: remove duplication of network configuration settings between NetworkSettings and NetworkGameInfo.
rubidium <rubidium@openttd.org>
parents: 9441
diff changeset
676 IConsolePrintF(CC_DEFAULT, "Current/maximum clients: %2d/%2d", _network_game_info.clients_on, _settings_client.network.max_clients);
11973
e17a54c88806 (svn r16379) -Codechange: remove GetNumTowns(), GetNumIndustries() and GetActiveCompanyCount(), use PoolItem::GetNumItems() instead
smatz <smatz@openttd.org>
parents: 11956
diff changeset
677 IConsolePrintF(CC_DEFAULT, "Current/maximum companies: %2d/%2d", (int)Company::GetNumItems(), _settings_client.network.max_companies);
9451
49dffcace617 (svn r13369) -Codechange: remove duplication of network configuration settings between NetworkSettings and NetworkGameInfo.
rubidium <rubidium@openttd.org>
parents: 9441
diff changeset
678 IConsolePrintF(CC_DEFAULT, "Current/maximum spectators: %2d/%2d", NetworkSpectatorCount(), _settings_client.network.max_spectators);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
679
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
680 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
681 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682
10865
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
683 DEF_CONSOLE_CMD(ConClientNickChange)
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
684 {
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
685 if (argc != 3) {
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
686 IConsoleHelp("Change the nickname of a connected client. Usage: 'client_name <client-id> <new-name>'");
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
687 IConsoleHelp("For client-id's, see the command 'clients'");
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
688 return true;
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
689 }
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
690
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
691 ClientID client_id = (ClientID)atoi(argv[1]);
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
692
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
693 if (client_id == CLIENT_ID_SERVER) {
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
694 IConsoleError("Please use the command 'name' to change your own name!");
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
695 return true;
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
696 }
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
697
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
698 if (NetworkFindClientInfoFromClientID(client_id) == NULL) {
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
699 IConsoleError("Invalid client");
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
700 return true;
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
701 }
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
702
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
703 if (!NetworkServerChangeClientName(client_id, argv[2])) {
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
704 IConsoleError("Cannot give a client a duplicate name");
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
705 }
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
706
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
707 return true;
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
708 }
31495869734e (svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)
rubidium <rubidium@openttd.org>
parents: 10858
diff changeset
709
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
710 DEF_CONSOLE_CMD(ConJoinCompany)
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
711 {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
712 if (argc < 2) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
713 IConsoleHelp("Request joining another company. Usage: join <company-id> [<password>]");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
714 IConsoleHelp("For valid company-id see company list, use 255 for spectator");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
715 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
716 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
717
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
718 CompanyID company_id = (CompanyID)(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
719
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
720 /* Check we have a valid company id! */
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
721 if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
722 IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
723 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
724 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
725
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
726 if (NetworkFindClientInfoFromClientID(_network_own_client_id)->client_playas == company_id) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
727 IConsoleError("You are already there!");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
728 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
729 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
730
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
731 if (company_id == COMPANY_SPECTATOR && NetworkMaxSpectatorsReached()) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
732 IConsoleError("Cannot join spectators, maximum number of spectators reached.");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
733 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
734 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
735
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
736 if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
11786
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
737 IConsoleError("Cannot join AI company.");
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
738 return true;
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
739 }
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
740
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
741 /* Check if the company requires a password */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
742 if (NetworkCompanyIsPassworded(company_id) && argc < 3) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
743 IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
744 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
745 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
746
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
747 /* non-dedicated server may just do the move! */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
748 if (_network_server) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
749 NetworkServerDoMove(CLIENT_ID_SERVER, company_id);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
750 } else {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
751 NetworkClientRequestMove(company_id, NetworkCompanyIsPassworded(company_id) ? argv[2] : "");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
752 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
753
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
754 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
755 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
756
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
757 DEF_CONSOLE_CMD(ConMoveClient)
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
758 {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
759 if (argc < 3) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
760 IConsoleHelp("Move a client to another company. Usage: move <client-id> <company-id>");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
761 IConsoleHelp("For valid client-id see 'clients', for valid company-id see 'companies', use 255 for moving to spectators");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
762 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
763 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
764
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
765 const NetworkClientInfo *ci = NetworkFindClientInfoFromClientID((ClientID)atoi(argv[1]));
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
766 CompanyID company_id = (CompanyID)(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
767
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
768 /* check the client exists */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
769 if (ci == NULL) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
770 IConsoleError("Invalid client-id, check the command 'clients' for valid client-id's.");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
771 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
772 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
773
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
774 if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
775 IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
776 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
777 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
778
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
779 if (company_id != COMPANY_SPECTATOR && !Company::IsHumanID(company_id)) {
11786
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
780 IConsoleError("You cannot move clients to AI companies.");
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
781 return true;
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
782 }
1eba81c7bdf5 (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands.
yexo <yexo@openttd.org>
parents: 11730
diff changeset
783
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
784 if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
785 IConsoleError("Silly boy, you cannot move the server!");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
786 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
787 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
788
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
789 if (ci->client_playas == company_id) {
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
790 IConsoleError("You cannot move someone to where he/she already is!");
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
791 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
792 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
793
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
794 /* we are the server, so force the update */
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
795 NetworkServerDoMove(ci->client_id, company_id);
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
796
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
797 return true;
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
798 }
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
799
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800 DEF_CONSOLE_CMD(ConResetCompany)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
801 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
802 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
803 IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'");
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
804 IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
805 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
806 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
807
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
808 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
809
11949
c89301974eb8 (svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents: 11924
diff changeset
810 CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
811
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812 /* Check valid range */
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
813 if (!Company::IsValidID(index)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
814 IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
815 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
818 if (!Company::IsHumanID(index)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
819 IConsoleError("Company is owned by an AI.");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
820 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
821 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
822
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
823 if (NetworkCompanyHasClients(index)) {
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
824 IConsoleError("Cannot remove company: a client is connected to that company.");
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
825 return false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
826 }
10462
435b95d3074d (svn r14717) -Change: more 'Index' -> ClientID to not confuse ClientID and ClientIndex
rubidium <rubidium@openttd.org>
parents: 10461
diff changeset
827 const NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
828 if (ci->client_playas == index) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
829 IConsoleError("Cannot remove company: the server is connected to that company.");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
830 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
831 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
832
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833 /* It is safe to remove this company */
15860
bb167d01deb9 (svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents: 15836
diff changeset
834 DoCommandP(0, 2 | index << 16, 0, CMD_COMPANY_CTRL);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
835 IConsolePrint(CC_DEFAULT, "Company deleted.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
837 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
838 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
839
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
840 DEF_CONSOLE_CMD(ConNetworkClients)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
841 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
842 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
843 IConsoleHelp("Get a list of connected clients including their ID, name, company-id, and IP. Usage: 'clients'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
844 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
845 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
846
10461
ad508142ce42 (svn r14716) -Codechange: move more network core querying to the network files.
rubidium <rubidium@openttd.org>
parents: 10457
diff changeset
847 NetworkPrintClients();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
848
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
849 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
850 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
851
12972
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
852 DEF_CONSOLE_CMD(ConNetworkReconnect)
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
853 {
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
854 if (argc == 0) {
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
855 IConsoleHelp("Reconnect to server to which you were connected last time. Usage: 'reconnect [<company>]'");
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
856 IConsoleHelp("Company 255 is spectator (default, if not specified), 0 means creating new company.");
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
857 IConsoleHelp("All others are a certain company with Company 1 being #1");
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
858 return true;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
859 }
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
860
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
861 CompanyID playas = (argc >= 2) ? (CompanyID)atoi(argv[1]) : COMPANY_SPECTATOR;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
862 switch (playas) {
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
863 case 0: playas = COMPANY_NEW_COMPANY; break;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
864 case COMPANY_SPECTATOR: /* nothing to do */ break;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
865 default:
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
866 /* From a user pov 0 is a new company, internally it's different and all
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
867 * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
868 playas--;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
869 if (playas < COMPANY_FIRST || playas >= MAX_COMPANIES) return false;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
870 break;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
871 }
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
872
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
873 if (StrEmpty(_settings_client.network.last_host)) {
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
874 IConsolePrint(CC_DEFAULT, "No server for reconnecting.");
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
875 return true;
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
876 }
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
877
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
878 /* Don't resolve the address first, just print it directly as it comes from the config file. */
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
879 IConsolePrintF(CC_DEFAULT, "Reconnecting to %s:%d...", _settings_client.network.last_host, _settings_client.network.last_port);
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
880
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
881 NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), playas);
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
882 return true;
14912
ec975dc25575 (svn r19509) -Codechange: remove superfluous semicolons after function definitions
smatz <smatz@openttd.org>
parents: 14786
diff changeset
883 }
12972
f7c10e2e95a2 (svn r17466) -Feature: reconnect console command (based on patch of bilbo)
rubidium <rubidium@openttd.org>
parents: 12810
diff changeset
884
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
885 DEF_CONSOLE_CMD(ConNetworkConnect)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
886 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
887 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
888 IConsoleHelp("Connect to a remote OTTD server and join the game. Usage: 'connect <ip>'");
14786
597a9e9c7620 (svn r19374) -Change: Update documentation for console command connect to use ip:port#company parameter format, in line with command line help.
peter1138 <peter1138@openttd.org>
parents: 14514
diff changeset
889 IConsoleHelp("IP can contain port and company: 'IP[:Port][#Company]', eg: 'server.ottd.org:443#2'");
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
890 IConsoleHelp("Company #255 is spectator all others are a certain company with Company 1 being #1");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
891 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
892 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
893
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
894 if (argc < 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
895 if (_networking) NetworkDisconnect(); // we are in network-mode, first close it!
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
896
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
897 const char *port = NULL;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
898 const char *company = NULL;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
899 char *ip = argv[1];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
900 /* Default settings: default port and new company */
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
901 uint16 rport = NETWORK_DEFAULT_PORT;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
902 CompanyID join_as = COMPANY_NEW_COMPANY;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
903
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
904 ParseConnectionString(&company, &port, ip);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
905
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
906 IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
907 if (company != NULL) {
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
908 join_as = (CompanyID)atoi(company);
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
909 IConsolePrintF(CC_DEFAULT, " company-no: %d", join_as);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
910
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
911 /* From a user pov 0 is a new company, internally it's different and all
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
912 * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
913 if (join_as != COMPANY_SPECTATOR) {
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
914 if (join_as > MAX_COMPANIES) return false;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
915 join_as--;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
916 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
917 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
918 if (port != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
919 rport = atoi(port);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
920 IConsolePrintF(CC_DEFAULT, " port: %s", port);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
921 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
922
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11949
diff changeset
923 NetworkClientConnectGame(NetworkAddress(ip, rport), join_as);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
924
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
925 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
926 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
927
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
928 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
929
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
930 /*********************************
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
931 * script file console commands
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
932 *********************************/
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
933
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
934 DEF_CONSOLE_CMD(ConExec)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
935 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
936 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
937 IConsoleHelp("Execute a local script file. Usage: 'exec <script> <?>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
938 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
939 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
940
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
941 if (argc < 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
942
15377
bee601f0754c (svn r20020) -Codechange: _script_file is used in only one function.
alberth <alberth@openttd.org>
parents: 15298
diff changeset
943 FILE *script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
944
15377
bee601f0754c (svn r20020) -Codechange: _script_file is used in only one function.
alberth <alberth@openttd.org>
parents: 15298
diff changeset
945 if (script_file == NULL) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
946 if (argc == 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
947 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
948 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
950 _script_running = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
951
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
952 char cmdline[ICON_CMDLN_SIZE];
15377
bee601f0754c (svn r20020) -Codechange: _script_file is used in only one function.
alberth <alberth@openttd.org>
parents: 15298
diff changeset
953 while (_script_running && fgets(cmdline, sizeof(cmdline), script_file) != NULL) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
954 /* Remove newline characters from the executing script */
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
955 for (char *cmdptr = cmdline; *cmdptr != '\0'; cmdptr++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
956 if (*cmdptr == '\n' || *cmdptr == '\r') {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957 *cmdptr = '\0';
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
959 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961 IConsoleCmdExec(cmdline);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
963
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15505
diff changeset
964 if (ferror(script_file)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
965 IConsoleError("Encountered errror while trying to read from script file");
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15505
diff changeset
966 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
967
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
968 _script_running = false;
15377
bee601f0754c (svn r20020) -Codechange: _script_file is used in only one function.
alberth <alberth@openttd.org>
parents: 15298
diff changeset
969 FioFCloseFile(script_file);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
970 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
971 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
972
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
973 DEF_CONSOLE_CMD(ConReturn)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
974 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
975 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
976 IConsoleHelp("Stop executing a running script. Usage: 'return'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
977 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
978 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
979
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
980 _script_running = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
981 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
982 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
983
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
984 /*****************************
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
985 * default console commands
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
986 ******************************/
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6235
diff changeset
987 extern bool CloseConsoleLogIfActive();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
988
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
989 DEF_CONSOLE_CMD(ConScript)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
990 {
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10594
diff changeset
991 extern FILE *_iconsole_output_file;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
993 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
994 IConsoleHelp("Start or stop logging console output to a file. Usage: 'script <filename>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
995 IConsoleHelp("If filename is omitted, a running log is stopped if it is active");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
996 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
997 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
998
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
999 if (!CloseConsoleLogIfActive()) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1000 if (argc < 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1001
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1002 IConsolePrintF(CC_DEFAULT, "file output started to: %s", argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1003 _iconsole_output_file = fopen(argv[1], "ab");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1004 if (_iconsole_output_file == NULL) IConsoleError("could not open file");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1005 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1006
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1007 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1008 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1009
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1010
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1011 DEF_CONSOLE_CMD(ConEcho)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1012 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1013 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014 IConsoleHelp("Print back the first argument to the console. Usage: 'echo <arg>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1015 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1016 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1017
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1018 if (argc < 2) return false;
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1019 IConsolePrint(CC_DEFAULT, argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1020 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1021 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1022
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1023 DEF_CONSOLE_CMD(ConEchoC)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1024 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1025 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1026 IConsoleHelp("Print back the first argument to the console in a given colour. Usage: 'echoc <colour> <arg2>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1027 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1028 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1029
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1030 if (argc < 3) return false;
16966
8d278efe19c8 (svn r21702) -Fix: make sure the colour argument of echoc is properly validated to be a text colour
rubidium <rubidium@openttd.org>
parents: 16965
diff changeset
1031 IConsolePrint((TextColour)Clamp(atoi(argv[1]), TC_BEGIN, TC_END - 1), argv[2]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1032 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1033 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1034
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035 DEF_CONSOLE_CMD(ConNewGame)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1036 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038 IConsoleHelp("Start a new game. Usage: 'newgame [seed]'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1039 IConsoleHelp("The server can force a new game using 'newgame'; any client joined will rejoin after the server is done generating the new game.");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1040 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1042
15833
dd2a8b5d9b6e (svn r20512) -Fix [FS#4036]: Generation seed is unsigned.
frosch <frosch@openttd.org>
parents: 15829
diff changeset
1043 StartNewGameWithoutGUI((argc == 2) ? strtoul(argv[1], NULL, 10) : GENERATE_NEW_SEED);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1044 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1045 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1046
11223
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11164
diff changeset
1047 extern void SwitchToMode(SwitchMode new_mode);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1049 DEF_CONSOLE_CMD(ConRestart)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1050 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1051 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1052 IConsoleHelp("Restart game. Usage: 'restart'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053 IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
12645
b9f1e5ce4831 (svn r17097) -Fix [FS#3092] (r13256): make restart command work again and make the help show how it works and how it doesn't work
rubidium <rubidium@openttd.org>
parents: 12352
diff changeset
1054 IConsoleHelp("However:");
b9f1e5ce4831 (svn r17097) -Fix [FS#3092] (r13256): make restart command work again and make the help show how it works and how it doesn't work
rubidium <rubidium@openttd.org>
parents: 12352
diff changeset
1055 IConsoleHelp(" * restarting games started in another version might create another map due to difference in map generation");
b9f1e5ce4831 (svn r17097) -Fix [FS#3092] (r13256): make restart command work again and make the help show how it works and how it doesn't work
rubidium <rubidium@openttd.org>
parents: 12352
diff changeset
1056 IConsoleHelp(" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1057 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1058 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1059
11223
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11164
diff changeset
1060 /* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1061 _settings_game.game_creation.map_x = MapLogX();
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1062 _settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
15096
2189809c14cd (svn r19722) -Fix: crash when using restart via rcon.
rubidium <rubidium@openttd.org>
parents: 14918
diff changeset
1063 _switch_mode = SM_RESTARTGAME;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1064 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1065 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1066
14510
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1067 #ifdef ENABLE_AI
16967
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1068 /**
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1069 * Print a text buffer line by line to the console. Lines are seperated by '\n'.
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1070 * @param buf The buffer to print.
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1071 * @note All newlines are replace by '\0' characters.
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1072 */
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1073 static void PrintLineByLine(char *buf)
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1074 {
16967
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1075 char *p = buf;
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1076 /* Print output line by line */
16967
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1077 for (char *p2 = buf; *p2 != '\0'; p2++) {
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1078 if (*p2 == '\n') {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1079 *p2 = '\0';
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1080 IConsolePrintF(CC_DEFAULT, "%s", p);
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1081 p = p2 + 1;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1082 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1083 }
16967
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1084 }
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1085
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1086 DEF_CONSOLE_CMD(ConListAILibs)
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1087 {
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1088 char buf[4096];
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1089 AI::GetConsoleLibraryList(buf, lastof(buf));
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1090
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1091 PrintLineByLine(buf);
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1092
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1093 return true;
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1094 }
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1095
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1096 DEF_CONSOLE_CMD(ConListAI)
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1097 {
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1098 char buf[4096];
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1099 AI::GetConsoleList(buf, lastof(buf));
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1100
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1101 PrintLineByLine(buf);
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1102
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1103 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1104 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1105
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1106 DEF_CONSOLE_CMD(ConStartAI)
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1107 {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1108 if (argc == 0 || argc > 3) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1109 IConsoleHelp("Start a new AI. Usage: 'start_ai [<AI>] [<settings>]'");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1110 IConsoleHelp("Start a new AI. If <AI> is given, it starts that specific AI (if found).");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1111 IConsoleHelp("If <settings> is given, it is parsed and the AI settings are set to that.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1112 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1113 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1114
10719
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1115 if (_game_mode != GM_NORMAL) {
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1116 IConsoleWarning("AIs can only be managed in a game.");
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1117 return true;
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1118 }
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1119
11973
e17a54c88806 (svn r16379) -Codechange: remove GetNumTowns(), GetNumIndustries() and GetActiveCompanyCount(), use PoolItem::GetNumItems() instead
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1120 if (Company::GetNumItems() == CompanyPool::MAX_SIZE) {
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1121 IConsoleWarning("Can't start a new AI (no more free slots).");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1122 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1123 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1124 if (_networking && !_network_server) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1125 IConsoleWarning("Only the server can start a new AI.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1126 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1127 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1128 if (_networking && !_settings_game.ai.ai_in_multiplayer) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1129 IConsoleWarning("AIs are not allowed in multiplayer by configuration.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1130 IConsoleWarning("Switch AI -> AI in multiplayer to True.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1131 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1132 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1133 if (!AI::CanStartNew()) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1134 IConsoleWarning("Can't start a new AI.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1135 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1136 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1137
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1138 int n = 0;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1139 Company *c;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1140 /* Find the next free slot */
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1141 FOR_ALL_COMPANIES(c) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1142 if (c->index != n) break;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1143 n++;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1144 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1145
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1146 AIConfig *config = AIConfig::GetConfig((CompanyID)n);
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1147 if (argc >= 2) {
14387
564d4bfbb911 (svn r18944) -Change [FS#3232]: use the highest version of an AI that can load the AI data from a savegame instead of the exact same version
yexo <yexo@openttd.org>
parents: 14386
diff changeset
1148 config->ChangeAI(argv[1], -1, true);
10711
185f0238d14c (svn r15043) -Fix: just try to change the AI, and see if that succeeded, instead of hoping you understand the internals of a change AI routine (to avoid possible mistakes in the future)
truebrain <truebrain@openttd.org>
parents: 10696
diff changeset
1149 if (!config->HasAI()) {
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1150 IConsoleWarning("Failed to load the specified AI");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1151 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1152 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1153 if (argc == 3) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1154 config->StringToSettings(argv[2]);
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1155 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1156 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1157
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1158 /* Start a new AI company */
15860
bb167d01deb9 (svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents: 15836
diff changeset
1159 DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL);
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1160
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1161 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1162 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1163
10750
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1164 DEF_CONSOLE_CMD(ConReloadAI)
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1165 {
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1166 if (argc != 2) {
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1167 IConsoleHelp("Reload an AI. Usage: 'reload_ai <company-id>'");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1168 IConsoleHelp("Reload the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1169 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1170 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1171
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1172 if (_game_mode != GM_NORMAL) {
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1173 IConsoleWarning("AIs can only be managed in a game.");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1174 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1175 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1176
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1177 if (_networking && !_network_server) {
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1178 IConsoleWarning("Only the server can reload an AI.");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1179 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1180 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1181
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1182 CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1183 if (!Company::IsValidID(company_id)) {
10750
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1184 IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1185 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1186 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1187
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
1188 if (Company::IsHumanID(company_id)) {
10750
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1189 IConsoleWarning("Company is not controlled by an AI.");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1190 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1191 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1192
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1193 /* First kill the company of the AI, then start a new one. This should start the current AI again */
15860
bb167d01deb9 (svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents: 15836
diff changeset
1194 DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
bb167d01deb9 (svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents: 15836
diff changeset
1195 DoCommandP(0, 1 | company_id << 16, 0, CMD_COMPANY_CTRL);
10750
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1196 IConsolePrint(CC_DEFAULT, "AI reloaded.");
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1197
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1198 return true;
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1199 }
498d5364e768 (svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
truebrain <truebrain@openttd.org>
parents: 10725
diff changeset
1200
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1201 DEF_CONSOLE_CMD(ConStopAI)
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1202 {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1203 if (argc != 2) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1204 IConsoleHelp("Stop an AI. Usage: 'stop_ai <company-id>'");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1205 IConsoleHelp("Stop the AI with the given company id. For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1206 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1207 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1208
10719
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1209 if (_game_mode != GM_NORMAL) {
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1210 IConsoleWarning("AIs can only be managed in a game.");
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1211 return true;
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1212 }
d95bdc28b14f (svn r15051) -Fix: Only allow creation or deletion of an AI when in a game.
peter1138 <peter1138@openttd.org>
parents: 10711
diff changeset
1213
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1214 if (_networking && !_network_server) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1215 IConsoleWarning("Only the server can stop an AI.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1216 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1217 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1218
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1219 CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1220 if (!Company::IsValidID(company_id)) {
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1221 IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1222 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1223 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1224
12220
8c5b158f0d40 (svn r16634) -Codechange: use Company::IsHumanID() instead of IsHumanCompany()
smatz <smatz@openttd.org>
parents: 12025
diff changeset
1225 if (Company::IsHumanID(company_id)) {
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1226 IConsoleWarning("Company is not controlled by an AI.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1227 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1228 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1229
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1230 /* Now kill the company of the AI. */
15860
bb167d01deb9 (svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents: 15836
diff changeset
1231 DoCommandP(0, 2 | company_id << 16, 0, CMD_COMPANY_CTRL);
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1232 IConsolePrint(CC_DEFAULT, "AI stopped, company deleted.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1233
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1234 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1235 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1236
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1237 DEF_CONSOLE_CMD(ConRescanAI)
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1238 {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1239 if (argc == 0) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1240 IConsoleHelp("Rescan the AI dir for scripts. Usage: 'rescan_ai'");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1241 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1242 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1243
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1244 if (_networking && !_network_server) {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1245 IConsoleWarning("Only the server can rescan the AI dir for scripts.");
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1246 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1247 }
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1248
16522
fa50c5fffd18 (svn r21248) -Codechange: don't run the tar scanner twice upon startup
rubidium <rubidium@openttd.org>
parents: 16520
diff changeset
1249 TarScanner::DoScan();
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1250 AI::Rescan();
16520
fc7fc1da9931 (svn r21246) -Fix: upon rescanning AIs the new AIs would (after some time) show up in the AI list but you could not select all
rubidium <rubidium@openttd.org>
parents: 16339
diff changeset
1251 InvalidateWindowData(WC_AI_LIST, 0, 1);
16524
b341f0626692 (svn r21250) -Fix [FS#3952]: Rescanning AIs didn't "forget" removed AIs
rubidium <rubidium@openttd.org>
parents: 16522
diff changeset
1252 SetWindowDirty(WC_AI_SETTINGS, 0);
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1253
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1254 return true;
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1255 }
14510
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1256 #endif /* ENABLE_AI */
10696
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10647
diff changeset
1257
15679
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1258 DEF_CONSOLE_CMD(ConRescanNewGRF)
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1259 {
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1260 if (argc == 0) {
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1261 IConsoleHelp("Rescan the data dir for NewGRFs. Usage: 'rescan_newgrf'");
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1262 return true;
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1263 }
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1264
16522
fa50c5fffd18 (svn r21248) -Codechange: don't run the tar scanner twice upon startup
rubidium <rubidium@openttd.org>
parents: 16520
diff changeset
1265 TarScanner::DoScan();
15679
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1266 ScanNewGRFFiles();
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1267 InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1268
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1269 return true;
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1270 }
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1271
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1272 DEF_CONSOLE_CMD(ConGetSeed)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1273 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1274 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1275 IConsoleHelp("Returns the seed used to create this game. Usage: 'getseed'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1276 IConsoleHelp("The seed can be used to reproduce the exact same map as the game started with.");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1277 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1278 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1279
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1280 IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _settings_game.game_creation.generation_seed);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1281 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1282 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1283
6890
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1284 DEF_CONSOLE_CMD(ConGetDate)
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1285 {
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1286 if (argc == 0) {
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1287 IConsoleHelp("Returns the current date (day-month-year) of the game. Usage: 'getdate'");
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1288 return true;
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1289 }
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1290
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1291 YearMonthDay ymd;
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1292 ConvertDateToYMD(_date, &ymd);
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1293 IConsolePrintF(CC_DEFAULT, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
6890
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1294 return true;
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1295 }
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1296
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1297
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1298 DEF_CONSOLE_CMD(ConAlias)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1299 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1300 IConsoleAlias *alias;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1301
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1302 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1303 IConsoleHelp("Add a new alias, or redefine the behaviour of an existing alias . Usage: 'alias <name> <command>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1304 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1305 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1306
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1307 if (argc < 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1308
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1309 alias = IConsoleAliasGet(argv[1]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1310 if (alias == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1311 IConsoleAliasRegister(argv[1], argv[2]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1312 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1313 free(alias->cmdline);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1314 alias->cmdline = strdup(argv[2]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1315 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1316 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1317 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1318
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1319 DEF_CONSOLE_CMD(ConScreenShot)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1320 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1321 if (argc == 0) {
15829
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1322 IConsoleHelp("Create a screenshot of the game. Usage: 'screenshot [big | giant | no_con] [file name]'");
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1323 IConsoleHelp("'big' makes a zoomed-in screenshot of the visible area, 'giant' makes a screenshot of the "
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1324 "whole map, 'no_con' hides the console to create the screenshot. 'big' or 'giant' "
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1325 "screenshots are always drawn without console");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1326 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1327 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1328
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1329 if (argc > 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1330
13429
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1331 ScreenshotType type = SC_VIEWPORT;
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1332 const char *name = NULL;
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1333
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1334 if (argc > 1) {
13429
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1335 if (strcmp(argv[1], "big") == 0) {
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1336 /* screenshot big [filename] */
15829
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1337 type = SC_ZOOMEDIN;
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1338 if (argc > 2) name = argv[2];
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1339 } else if (strcmp(argv[1], "giant") == 0) {
d894e15249fb (svn r20508) -Add [FS#3973]: A new screenshot type that makes a zoomed-in screenshot of the visible viewport. (Eddi)
michi_cc <michi_cc@openttd.org>
parents: 15679
diff changeset
1340 /* screenshot giant [filename] */
13429
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1341 type = SC_WORLD;
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1342 if (argc > 2) name = argv[2];
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1343 } else if (strcmp(argv[1], "no_con") == 0) {
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1344 /* screenshot no_con [filename] */
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1345 IConsoleClose();
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1346 if (argc > 2) name = argv[2];
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1347 } else if (argc == 2) {
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1348 /* screenshot filename */
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1349 name = argv[1];
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1350 } else {
13631
9d22db56efe5 (svn r18155) -Codechange: in MakeScreenshotName(), don't return pointer to local static variable - use global one instead
smatz <smatz@openttd.org>
parents: 13532
diff changeset
1351 /* screenshot argv[1] argv[2] - invalid */
13429
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1352 return false;
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1353 }
abbeb6735538 (svn r17938) -Feature: non-automatic screenshot name can be entered in console
smatz <smatz@openttd.org>
parents: 13186
diff changeset
1354 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1355
14004
96fa151f99f9 (svn r18546) -Codechange: make making the screenshot not asynchronious; just do it at the moment it's requested.
rubidium <rubidium@openttd.org>
parents: 13937
diff changeset
1356 MakeScreenshot(type, name);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1357 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1358 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1359
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1360 DEF_CONSOLE_CMD(ConInfoCmd)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1361 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1362 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1363 IConsoleHelp("Print out debugging information about a command. Usage: 'info_cmd <cmd>'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1364 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1365 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1366
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1367 if (argc < 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1368
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
1369 const IConsoleCmd *cmd = IConsoleCmdGet(argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1370 if (cmd == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1371 IConsoleError("the given command was not found");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1372 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1373 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1374
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1375 IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
11875
86fca539ec7a (svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1376 IConsolePrintF(CC_DEFAULT, "command proc: %p", cmd->proc);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1377
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1378 if (cmd->hook != NULL) IConsoleWarning("command is hooked");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1379
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1380 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1381 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1382
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1383 DEF_CONSOLE_CMD(ConDebugLevel)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1384 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1385 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1386 IConsoleHelp("Get/set the default debugging level for the game. Usage: 'debug_level [<level>]'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1387 IConsoleHelp("Level can be any combination of names, levels. Eg 'net=5 ms=4'. Remember to enclose it in \"'s");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1388 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1389 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1390
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1391 if (argc > 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1392
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1393 if (argc == 1) {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1394 IConsolePrintF(CC_DEFAULT, "Current debug-level: '%s'", GetDebugString());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1395 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1396 SetDebugString(argv[1]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1397 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1398
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1399 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1400 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1401
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1402 DEF_CONSOLE_CMD(ConExit)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1403 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1404 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1405 IConsoleHelp("Exit the game. Usage: 'exit'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1406 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1407 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1408
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
1409 if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave();
7306
c6e2fc0bbd37 (svn r10658) -Add: support for autosave_on_exit in the console, so dedicated servers can use it
glx <glx@openttd.org>
parents: 7047
diff changeset
1410
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1411 _exit_game = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1412 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1413 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1414
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1415 DEF_CONSOLE_CMD(ConPart)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1416 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1417 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1418 IConsoleHelp("Leave the currently joined/running game (only ingame). Usage: 'part'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1419 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1420 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1421
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1422 if (_game_mode != GM_NORMAL) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1423
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1424 _switch_mode = SM_MENU;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1425 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1426 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1427
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1428 DEF_CONSOLE_CMD(ConHelp)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1429 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1430 if (argc == 2) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1431 const IConsoleCmd *cmd;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1432 const IConsoleAlias *alias;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1433
16339
78dff9ac8713 (svn r21050) -Fix (r20515): ignore underscores as well for help messages
rubidium <rubidium@openttd.org>
parents: 16273
diff changeset
1434 RemoveUnderscores(argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1435 cmd = IConsoleCmdGet(argv[1]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1436 if (cmd != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1437 cmd->proc(0, NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1438 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1439 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1440
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1441 alias = IConsoleAliasGet(argv[1]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1442 if (alias != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1443 cmd = IConsoleCmdGet(alias->cmdline);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1444 if (cmd != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1445 cmd->proc(0, NULL);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1446 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1447 }
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1448 IConsolePrintF(CC_ERROR, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1449 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1450 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1451
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1452 IConsoleError("command not found");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1453 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1454 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1455
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1456 IConsolePrint(CC_WARNING, " ---- OpenTTD Console Help ---- ");
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1457 IConsolePrint(CC_DEFAULT, " - commands: [command to list all commands: list_cmds]");
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1458 IConsolePrint(CC_DEFAULT, " call commands with '<command> <arg2> <arg3>...'");
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1459 IConsolePrint(CC_DEFAULT, " - to assign strings, or use them as arguments, enclose it within quotes");
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1460 IConsolePrint(CC_DEFAULT, " like this: '<command> \"string argument with spaces\"'");
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1461 IConsolePrint(CC_DEFAULT, " - use 'help <command>' to get specific information");
17558
98f9e9b40aa3 (svn r22322) -Fix [FS#4593]: Obey the law of conservation of parantheses in the console help
planetmaker <planetmaker@openttd.org>
parents: 17340
diff changeset
1462 IConsolePrint(CC_DEFAULT, " - scroll console output with shift + (up | down | pageup | pagedown)");
98f9e9b40aa3 (svn r22322) -Fix [FS#4593]: Obey the law of conservation of parantheses in the console help
planetmaker <planetmaker@openttd.org>
parents: 17340
diff changeset
1463 IConsolePrint(CC_DEFAULT, " - scroll console input history with the up or down arrows");
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1464 IConsolePrint(CC_DEFAULT, "");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1465 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1466 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1467
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1468 DEF_CONSOLE_CMD(ConListCommands)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1469 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1470 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1471 IConsoleHelp("List all registered commands. Usage: 'list_cmds [<pre-filter>]'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1472 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1473 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1474
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
1475 for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) {
14503
bb294af806bc (svn r19074) -Change: when filtering list of settings and console commands, use strstr() instead of strncmp()
smatz <smatz@openttd.org>
parents: 14422
diff changeset
1476 if (argv[1] == NULL || strstr(cmd->name, argv[1]) != NULL) {
14917
eea6004124b6 (svn r19514) -Codechange: Allow console hooks to deny existance of commands.
frosch <frosch@openttd.org>
parents: 14912
diff changeset
1477 if (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1478 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1479 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1480
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1481 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1482 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1483
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1484 DEF_CONSOLE_CMD(ConListAliases)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1485 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1486 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1487 IConsoleHelp("List all registered aliases. Usage: 'list_aliases [<pre-filter>]'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1488 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1489 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1490
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
1491 for (const IConsoleAlias *alias = _iconsole_aliases; alias != NULL; alias = alias->next) {
14503
bb294af806bc (svn r19074) -Change: when filtering list of settings and console commands, use strstr() instead of strncmp()
smatz <smatz@openttd.org>
parents: 14422
diff changeset
1492 if (argv[1] == NULL || strstr(alias->name, argv[1]) != NULL) {
9337
ee85444554a1 (svn r13229) -Codechange: replace some global variables that are only initialised once and always with the same value with enums.
rubidium <rubidium@openttd.org>
parents: 9336
diff changeset
1493 IConsolePrintF(CC_DEFAULT, "%s => %s", alias->name, alias->cmdline);
14503
bb294af806bc (svn r19074) -Change: when filtering list of settings and console commands, use strstr() instead of strncmp()
smatz <smatz@openttd.org>
parents: 14422
diff changeset
1494 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1495 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1496
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1497 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1498 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1499
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1500 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1501
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1502 DEF_CONSOLE_CMD(ConSay)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1503 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1504 if (argc == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1505 IConsoleHelp("Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1506 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1507 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1508
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1509 if (argc != 2) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1510
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1511 if (!_network_server) {
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
1512 NetworkClientSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1513 } else {
16273
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1514 bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1515 NetworkServerSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], CLIENT_ID_SERVER, from_admin);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1516 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1517
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1518 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1519 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1520
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1521 DEF_CONSOLE_CMD(ConCompanies)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1522 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1523 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1524 IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1525 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1526 }
10457
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1527 NetworkCompanyStats company_stats[MAX_COMPANIES];
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1528 NetworkPopulateCompanyStats(company_stats);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1529
15378
ee826a793259 (svn r20021) -Codechange: Move variable declarations.
alberth <alberth@openttd.org>
parents: 15377
diff changeset
1530 Company *c;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1531 FOR_ALL_COMPANIES(c) {
10457
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1532 /* Grab the company name */
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1533 char company_name[NETWORK_COMPANY_NAME_LENGTH];
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1534 SetDParam(0, c->index);
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1535 GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1536
10457
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1537 char buffer[512];
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1538 const NetworkCompanyStats *stats = &company_stats[c->index];
6566
d1e25124052f (svn r9771) -Feature: (-tte) Add password protected status to 'players' (network server) console command. (mostly dihedral)
peter1138 <peter1138@openttd.org>
parents: 6453
diff changeset
1539
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11710
diff changeset
1540 GetString(buffer, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(buffer));
11875
86fca539ec7a (svn r16269) -Codechange: use gcc's ability to check parameters sent to printf-like functions
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1541 IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %sprotected",
10457
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1542 c->index + 1, buffer, company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1543 /* trains */ stats->num_vehicle[0],
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1544 /* lorry + bus */ stats->num_vehicle[1] + stats->num_vehicle[2],
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1545 /* planes */ stats->num_vehicle[3],
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1546 /* ships */ stats->num_vehicle[4],
7cfe07199455 (svn r14712) -Codechange: split server and client side w.r.t. the storage of network related company information.
rubidium <rubidium@openttd.org>
parents: 10456
diff changeset
1547 /* protected */ StrEmpty(_network_company_states[c->index].password) ? "un" : "");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1548 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1549
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1550 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1551 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1552
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1553 DEF_CONSOLE_CMD(ConSayCompany)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1554 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1555 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1556 IConsoleHelp("Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1557 IConsoleHelp("CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1558 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1559 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1560
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1561 if (argc != 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1562
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1563 CompanyID company_id = (CompanyID)(atoi(argv[1]) - 1);
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1564 if (!Company::IsValidID(company_id)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1565 IConsolePrintF(CC_DEFAULT, "Unknown company. Company range is between 1 and %d.", MAX_COMPANIES);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1566 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1567 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1568
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1569 if (!_network_server) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1570 NetworkClientSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1571 } else {
16273
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1572 bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1573 NetworkServerSendChat(NETWORK_ACTION_CHAT_COMPANY, DESTTYPE_TEAM, company_id, argv[2], CLIENT_ID_SERVER, from_admin);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1574 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1575
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1576 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1577 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1578
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1579 DEF_CONSOLE_CMD(ConSayClient)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1580 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1581 if (argc == 0) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1582 IConsoleHelp("Chat to a certain client in a multiplayer game. Usage: 'say_client <client-no> \"<msg>\"'");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1583 IConsoleHelp("For client-id's, see the command 'clients'");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1584 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1585 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1586
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1587 if (argc != 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1588
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1589 if (!_network_server) {
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9426
diff changeset
1590 NetworkClientSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1591 } else {
16273
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1592 bool from_admin = (_redirect_console_to_admin < INVALID_ADMIN_ID);
2c063c8b61bd (svn r20974) -Add: remote console (rcon) for remote admins (dihedral)
rubidium <rubidium@openttd.org>
parents: 15944
diff changeset
1593 NetworkServerSendChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], CLIENT_ID_SERVER, from_admin);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1594 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1595
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1596 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1597 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1598
14504
95e338145e97 (svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
smatz <smatz@openttd.org>
parents: 14503
diff changeset
1599 DEF_CONSOLE_CMD(ConCompanyPassword)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1600 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1601 if (argc == 0) {
17118
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1602 const char *helpmsg;
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1603
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1604 if (_network_dedicated) {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1605 helpmsg = "Change the password of a company. Usage: 'company_pw <company-no> \"<password>\"";
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1606 } else if (_network_server) {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1607 helpmsg = "Change the password of your or any other company. Usage: 'company_pw [<company-no>] \"<password>\"'";
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1608 } else {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1609 helpmsg = "Change the password of your company. Usage: 'company_pw \"<password>\"'";
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1610 }
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1611
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1612 IConsoleHelp(helpmsg);
10456
06d95041141b (svn r14711) -Codechange: don't misuse the _network_company_info password field for changing the password on clients.
rubidium <rubidium@openttd.org>
parents: 10454
diff changeset
1613 IConsoleHelp("Use \"*\" to disable the password.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1614 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1615 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1616
17118
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1617 CompanyID company_id;
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1618 const char *password;
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1619 const char *errormsg;
14504
95e338145e97 (svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
smatz <smatz@openttd.org>
parents: 14503
diff changeset
1620
17118
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1621 if (argc == 2) {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1622 company_id = _local_company;
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1623 password = argv[1];
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1624 errormsg = "You have to own a company to make use of this command.";
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1625 } else if (argc == 3 && _network_server) {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1626 company_id = (CompanyID)(atoi(argv[1]) - 1);
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1627 password = argv[2];
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1628 errormsg = "You have to specify the ID of a valid human controlled company.";
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1629 } else {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1630 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1631 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1632
17118
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1633 if (!Company::IsValidHumanID(company_id)) {
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1634 IConsoleError(errormsg);
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1635 return false;
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1636 }
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1637
fd7c1739ca1a (svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
rubidium <rubidium@openttd.org>
parents: 17117
diff changeset
1638 password = NetworkChangeCompanyPassword(company_id, password, false);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1639
14504
95e338145e97 (svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
smatz <smatz@openttd.org>
parents: 14503
diff changeset
1640 if (StrEmpty(password)) {
95e338145e97 (svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
smatz <smatz@openttd.org>
parents: 14503
diff changeset
1641 IConsolePrintF(CC_WARNING, "Company password cleared");
7999
86d0c16e7c50 (svn r11557) -Codechange: send and store the passwords a little more secure to/in the servers.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
1642 } else {
14504
95e338145e97 (svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
smatz <smatz@openttd.org>
parents: 14503
diff changeset
1643 IConsolePrintF(CC_WARNING, "Company password changed to: %s", password);
7999
86d0c16e7c50 (svn r11557) -Codechange: send and store the passwords a little more secure to/in the servers.
rubidium <rubidium@openttd.org>
parents: 7954
diff changeset
1644 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1645
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1646 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1647 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1648
12014
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1649 /* Content downloading only is available with ZLIB */
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1650 #if defined(WITH_ZLIB)
10858
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1651 #include "network/network_content.h"
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1652
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1653 /** Resolve a string to a content type. */
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1654 static ContentType StringToContentType(const char *str)
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1655 {
13096
e3e4c1648e0c (svn r17596) -Codechange: constify some tables
smatz <smatz@openttd.org>
parents: 13034
diff changeset
1656 static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
10858
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1657 for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1658 if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1659 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1660 return CONTENT_TYPE_END;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1661 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1662
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1663 /** Asynchronous callback */
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1664 struct ConsoleContentCallback : public ContentCallback {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1665 void OnConnect(bool success)
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1666 {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1667 IConsolePrintF(CC_DEFAULT, "Content server connection %s", success ? "established" : "failed");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1668 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1669
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1670 void OnDisconnect()
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1671 {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1672 IConsolePrintF(CC_DEFAULT, "Content server connection closed");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1673 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1674
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1675 void OnDownloadComplete(ContentID cid)
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1676 {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1677 IConsolePrintF(CC_DEFAULT, "Completed download of %d", cid);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1678 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1679 };
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1680
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1681 DEF_CONSOLE_CMD(ConContent)
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1682 {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1683 static ContentCallback *cb = NULL;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1684 if (cb == NULL) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1685 cb = new ConsoleContentCallback();
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1686 _network_content_client.AddCallback(cb);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1687 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1688
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1689 if (argc <= 1) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1690 IConsoleHelp("Query, select and download content. Usage: 'content update|upgrade|select [all|id]|unselect [all|id]|state|download'");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1691 IConsoleHelp(" update: get a new list of downloadable content; must be run first");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1692 IConsoleHelp(" upgrade: select all items that are upgrades");
10918
3ac2f3aecdc8 (svn r15253) -Fix (r15193): dutch people shouldn't write english :p
truebrain <truebrain@openttd.org>
parents: 10907
diff changeset
1693 IConsoleHelp(" select: select a specific item given by its id or 'all' to select all");
3ac2f3aecdc8 (svn r15253) -Fix (r15193): dutch people shouldn't write english :p
truebrain <truebrain@openttd.org>
parents: 10907
diff changeset
1694 IConsoleHelp(" unselect: unselect a specific item given by its id or 'all' to unselect all");
10858
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1695 IConsoleHelp(" state: show the download/select state of all downloadable content");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1696 IConsoleHelp(" download: download all content you've selected");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1697 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1698 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1699
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1700 if (strcasecmp(argv[1], "update") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1701 _network_content_client.RequestContentList((argc > 2) ? StringToContentType(argv[2]) : CONTENT_TYPE_END);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1702 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1703 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1704
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1705 if (strcasecmp(argv[1], "upgrade") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1706 _network_content_client.SelectUpgrade();
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1707 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1708 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1709
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1710 if (strcasecmp(argv[1], "select") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1711 if (argc <= 2) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1712 IConsoleError("You must enter the id.");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1713 return false;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1714 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1715 if (strcasecmp(argv[2], "all") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1716 _network_content_client.SelectAll();
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1717 } else {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1718 _network_content_client.Select((ContentID)atoi(argv[2]));
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1719 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1720 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1721 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1722
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1723 if (strcasecmp(argv[1], "unselect") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1724 if (argc <= 2) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1725 IConsoleError("You must enter the id.");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1726 return false;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1727 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1728 if (strcasecmp(argv[2], "all") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1729 _network_content_client.UnselectAll();
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1730 } else {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1731 _network_content_client.Unselect((ContentID)atoi(argv[2]));
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1732 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1733 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1734 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1735
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1736 if (strcasecmp(argv[1], "state") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1737 IConsolePrintF(CC_WHITE, "id, type, state, name");
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1738 for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
14065
a5fb37f9f59d (svn r18608) -Change: add the concept of music sets
rubidium <rubidium@openttd.org>
parents: 14004
diff changeset
1739 static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music" };
13937
876df839c647 (svn r18469) -Fix (r17139): possible invalid reads when listing content on the console
rubidium <rubidium@openttd.org>
parents: 13804
diff changeset
1740 assert_compile(lengthof(types) == CONTENT_TYPE_END - CONTENT_TYPE_BEGIN);
13175
3f4cc2986131 (svn r17682) -Codechange: remove erroneous space before some commas
rubidium <rubidium@openttd.org>
parents: 13096
diff changeset
1741 static const char * const states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
16965
db80544f73f9 (svn r21701) -Codechange: ConsoleColour = TextColour, so make it that way and remove some unneeded casts
rubidium <rubidium@openttd.org>
parents: 16956
diff changeset
1742 static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
10858
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1743
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1744 const ContentInfo *ci = *iter;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1745 IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1746 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1747 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1748 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1749
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1750 if (strcasecmp(argv[1], "download") == 0) {
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1751 uint files;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1752 uint bytes;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1753 _network_content_client.DownloadSelectedContent(files, bytes);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1754 IConsolePrintF(CC_DEFAULT, "Downloading %d file(s) (%d bytes)", files, bytes);
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1755 return true;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1756 }
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1757
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1758 return false;
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1759 }
12014
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1760 #endif /* defined(WITH_ZLIB) */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1761 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1762
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1763 DEF_CONSOLE_CMD(ConSetting)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1764 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1765 if (argc == 0) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1766 IConsoleHelp("Change setting for all clients. Usage: 'setting <name> [<value>]'");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1767 IConsoleHelp("Omitting <value> will print out the current value of the setting.");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1768 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1769 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1770
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1771 if (argc == 1 || argc > 3) return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1772
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1773 if (argc == 2) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1774 IConsoleGetSetting(argv[1]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1775 } else {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1776 IConsoleSetSetting(argv[1], argv[2]);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1777 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1778
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1779 return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1780 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1781
14386
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1782 DEF_CONSOLE_CMD(ConSettingNewgame)
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1783 {
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1784 if (argc == 0) {
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1785 IConsoleHelp("Change setting for the next game. Usage: 'setting_newgame <name> [<value>]'");
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1786 IConsoleHelp("Omitting <value> will print out the current value of the setting.");
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1787 return true;
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1788 }
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1789
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1790 if (argc == 1 || argc > 3) return false;
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1791
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1792 if (argc == 2) {
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1793 IConsoleGetSetting(argv[1], true);
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1794 } else {
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1795 IConsoleSetSetting(argv[1], argv[2], true);
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1796 }
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1797
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1798 return true;
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1799 }
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1800
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1801 DEF_CONSOLE_CMD(ConListSettings)
6429
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1802 {
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1803 if (argc == 0) {
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1804 IConsoleHelp("List settings. Usage: 'list_settings [<pre-filter>]'");
6429
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1805 return true;
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1806 }
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1807
9893
b902c0851258 (svn r14041) -Feature(tte): make it possible to filter list_patches output like it's done for other list_* console commands
glx <glx@openttd.org>
parents: 9659
diff changeset
1808 if (argc > 2) return false;
6429
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1809
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1810 IConsoleListSettings((argc == 2) ? argv[1] : NULL);
6429
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1811 return true;
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1812 }
3d078ea3946b (svn r9565) -Feature: Add list_patches console command. This shows all patches along with their current values. Based on patch by madman2003/GrimRC.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
1813
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1814 DEF_CONSOLE_CMD(ConGamelogPrint)
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1815 {
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1816 GamelogPrintConsole();
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1817 return true;
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1818 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1819
14918
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1820 DEF_CONSOLE_CMD(ConNewGRFReload)
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1821 {
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1822 if (argc == 0) {
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1823 IConsoleHelp("Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1824 return true;
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1825 }
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1826
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1827 ReloadNewGRFData();
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1828 return true;
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1829 }
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1830
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1831 #ifdef _DEBUG
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1832 /******************
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1833 * debug commands
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1834 ******************/
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1835
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6235
diff changeset
1836 static void IConsoleDebugLibRegister()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1837 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1838 IConsoleCmdRegister("resettile", ConResetTile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1839 IConsoleAliasRegister("dbg_echo", "echo %A; echo %B");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1840 IConsoleAliasRegister("dbg_echo2", "echo %!");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1841 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1842 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1843
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1844 /*******************************
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1845 * console command registration
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1846 *******************************/
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1847
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6235
diff changeset
1848 void IConsoleStdLibRegister()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1849 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1850 IConsoleCmdRegister("debug_level", ConDebugLevel);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1851 IConsoleCmdRegister("echo", ConEcho);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1852 IConsoleCmdRegister("echoc", ConEchoC);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1853 IConsoleCmdRegister("exec", ConExec);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1854 IConsoleCmdRegister("exit", ConExit);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1855 IConsoleCmdRegister("part", ConPart);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1856 IConsoleCmdRegister("help", ConHelp);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1857 IConsoleCmdRegister("info_cmd", ConInfoCmd);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1858 IConsoleCmdRegister("list_cmds", ConListCommands);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1859 IConsoleCmdRegister("list_aliases", ConListAliases);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1860 IConsoleCmdRegister("newgame", ConNewGame);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1861 IConsoleCmdRegister("restart", ConRestart);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1862 IConsoleCmdRegister("getseed", ConGetSeed);
6890
774ae92da647 (svn r10137) -Add: console command to get the current game date.
rubidium <rubidium@openttd.org>
parents: 6573
diff changeset
1863 IConsoleCmdRegister("getdate", ConGetDate);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1864 IConsoleCmdRegister("quit", ConExit);
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1865 IConsoleCmdRegister("resetengines", ConResetEngines, ConHookNoNetwork);
17235
3f6432af5795 (svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
frosch <frosch@openttd.org>
parents: 17152
diff changeset
1866 IConsoleCmdRegister("reset_enginepool", ConResetEnginePool, ConHookNoNetwork);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1867 IConsoleCmdRegister("return", ConReturn);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1868 IConsoleCmdRegister("screenshot", ConScreenShot);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1869 IConsoleCmdRegister("script", ConScript);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1870 IConsoleCmdRegister("scrollto", ConScrollToTile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1871 IConsoleCmdRegister("alias", ConAlias);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1872 IConsoleCmdRegister("load", ConLoad);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1873 IConsoleCmdRegister("rm", ConRemove);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1874 IConsoleCmdRegister("save", ConSave);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1875 IConsoleCmdRegister("saveconfig", ConSaveConfig);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1876 IConsoleCmdRegister("ls", ConListFiles);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1877 IConsoleCmdRegister("cd", ConChangeDirectory);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1878 IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1879 IConsoleCmdRegister("clear", ConClearBuffer);
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1880 IConsoleCmdRegister("setting", ConSetting);
14386
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1881 IConsoleCmdRegister("setting_newgame", ConSettingNewgame);
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1882 IConsoleCmdRegister("list_settings",ConListSettings);
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9451
diff changeset
1883 IConsoleCmdRegister("gamelog", ConGamelogPrint);
15679
7d5a8cb093f1 (svn r20344) -Feature: add rescan_newgrf console command
yexo <yexo@openttd.org>
parents: 15618
diff changeset
1884 IConsoleCmdRegister("rescan_newgrf", ConRescanNewGRF);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1885
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1886 IConsoleAliasRegister("dir", "ls");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1887 IConsoleAliasRegister("del", "rm %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1888 IConsoleAliasRegister("newmap", "newgame");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1889 IConsoleAliasRegister("patch", "setting %+");
11070
b1754198f43c (svn r15411) -Feature(ttette): make 'set' a alias for the setting/patch console command
rubidium <rubidium@openttd.org>
parents: 11069
diff changeset
1890 IConsoleAliasRegister("set", "setting %+");
14386
a992c2cc9b03 (svn r18943) -Feature [FS#2885]: make it possible to change newgame settings from within a game via the console (use setting_newgame instead of setting)
yexo <yexo@openttd.org>
parents: 14258
diff changeset
1891 IConsoleAliasRegister("set_newgame", "setting_newgame %+");
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1892 IConsoleAliasRegister("list_patches", "list_settings %+");
14511
b755671f7cbb (svn r19082) -Codechange: make 'developer' a regular setting
smatz <smatz@openttd.org>
parents: 14510
diff changeset
1893 IConsoleAliasRegister("developer", "setting developer %+");
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1894
14510
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1895 #ifdef ENABLE_AI
16967
77f2b8f0869d (svn r21703) -Feature [FS#4372]: list_ai_libs console command to get a list of recognized AI libraries (dihedral)
yexo <yexo@openttd.org>
parents: 16966
diff changeset
1896 IConsoleCmdRegister("list_ai_libs", ConListAILibs);
14510
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1897 IConsoleCmdRegister("list_ai", ConListAI);
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1898 IConsoleCmdRegister("reload_ai", ConReloadAI);
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1899 IConsoleCmdRegister("rescan_ai", ConRescanAI);
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1900 IConsoleCmdRegister("start_ai", ConStartAI);
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1901 IConsoleCmdRegister("stop_ai", ConStopAI);
38952764f91f (svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
rubidium <rubidium@openttd.org>
parents: 14508
diff changeset
1902 #endif /* ENABLE_AI */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1903
14512
e53f601a581c (svn r19083) -Cleanup: remove support for modifying variables from console
smatz <smatz@openttd.org>
parents: 14511
diff changeset
1904 /* networking functions */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1905 #ifdef ENABLE_NETWORK
12014
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1906 /* Content downloading is only available with ZLIB */
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1907 #if defined(WITH_ZLIB)
10858
a873c816d34b (svn r15193) -Feature: content server/bananas access via the console
rubidium <rubidium@openttd.org>
parents: 10822
diff changeset
1908 IConsoleCmdRegister("content", ConContent);
12014
47c1a32b550d (svn r16420) -Fix [FS#2919]: don't allow content download via the console when there's no zlib as it's done for the GUI already
rubidium <rubidium@openttd.org>
parents: 11973
diff changeset
1909 #endif /* defined(WITH_ZLIB) */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1910
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1911 /*** Networking commands ***/
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1912 IConsoleCmdRegister("say", ConSay, ConHookNeedNetwork);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1913 IConsoleCmdRegister("companies", ConCompanies, ConHookServerOnly);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1914 IConsoleAliasRegister("players", "companies");
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1915 IConsoleCmdRegister("say_company", ConSayCompany, ConHookNeedNetwork);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10039
diff changeset
1916 IConsoleAliasRegister("say_player", "say_company %+");
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1917 IConsoleCmdRegister("say_client", ConSayClient, ConHookNeedNetwork);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1918
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1919 IConsoleCmdRegister("connect", ConNetworkConnect, ConHookClientOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1920 IConsoleCmdRegister("clients", ConNetworkClients, ConHookNeedNetwork);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1921 IConsoleCmdRegister("status", ConStatus, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1922 IConsoleCmdRegister("server_info", ConServerInfo, ConHookServerOnly);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1923 IConsoleAliasRegister("info", "server_info");
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1924 IConsoleCmdRegister("reconnect", ConNetworkReconnect, ConHookClientOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1925 IConsoleCmdRegister("rcon", ConRcon, ConHookNeedNetwork);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1926
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1927 IConsoleCmdRegister("join", ConJoinCompany, ConHookNeedNetwork);
10907
96ac514d4239 (svn r15242) -Feature: allow moving clients between companies/spectators by the server and the clients themselves (dihedral)
rubidium <rubidium@openttd.org>
parents: 10865
diff changeset
1928 IConsoleAliasRegister("spectate", "join 255");
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1929 IConsoleCmdRegister("move", ConMoveClient, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1930 IConsoleCmdRegister("reset_company", ConResetCompany, ConHookServerOnly);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1931 IConsoleAliasRegister("clean_company", "reset_company %A");
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1932 IConsoleCmdRegister("client_name", ConClientNickChange, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1933 IConsoleCmdRegister("kick", ConKick, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1934 IConsoleCmdRegister("ban", ConBan, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1935 IConsoleCmdRegister("unban", ConUnBan, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1936 IConsoleCmdRegister("banlist", ConBanList, ConHookServerOnly);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1937
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1938 IConsoleCmdRegister("pause", ConPauseGame, ConHookServerOnly);
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1939 IConsoleCmdRegister("unpause", ConUnPauseGame, ConHookServerOnly);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1940
14514
38960c0add73 (svn r19085) -Codechange: simplify hooking of console commands
smatz <smatz@openttd.org>
parents: 14512
diff changeset
1941 IConsoleCmdRegister("company_pw", ConCompanyPassword, ConHookNeedNetwork);
14506
17ae7c02fb5c (svn r19077) -Codechange: remove company_pw from console vars
smatz <smatz@openttd.org>
parents: 14504
diff changeset
1942 IConsoleAliasRegister("company_password", "company_pw %+");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1943
11069
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1944 IConsoleAliasRegister("net_frame_freq", "setting frame_freq %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1945 IConsoleAliasRegister("net_sync_freq", "setting sync_freq %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1946 IConsoleAliasRegister("server_pw", "setting server_password %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1947 IConsoleAliasRegister("server_password", "setting server_password %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1948 IConsoleAliasRegister("rcon_pw", "setting rcon_password %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1949 IConsoleAliasRegister("rcon_password", "setting rcon_password %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1950 IConsoleAliasRegister("name", "setting client_name %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1951 IConsoleAliasRegister("server_name", "setting server_name %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1952 IConsoleAliasRegister("server_port", "setting server_port %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1953 IConsoleAliasRegister("server_advertise", "setting server_advertise %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1954 IConsoleAliasRegister("max_clients", "setting max_clients %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1955 IConsoleAliasRegister("max_companies", "setting max_companies %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1956 IConsoleAliasRegister("max_spectators", "setting max_spectators %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1957 IConsoleAliasRegister("max_join_time", "setting max_join_time %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1958 IConsoleAliasRegister("pause_on_join", "setting pause_on_join %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1959 IConsoleAliasRegister("autoclean_companies", "setting autoclean_companies %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1960 IConsoleAliasRegister("autoclean_protected", "setting autoclean_protected %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1961 IConsoleAliasRegister("autoclean_unprotected", "setting autoclean_unprotected %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1962 IConsoleAliasRegister("restart_game_year", "setting restart_game_year %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1963 IConsoleAliasRegister("min_players", "setting min_active_clients %+");
36d798171bfd (svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1964 IConsoleAliasRegister("reload_cfg", "setting reload_cfg %+");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1965 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1966
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11279
diff changeset
1967 /* debugging stuff */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1968 #ifdef _DEBUG
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1969 IConsoleDebugLibRegister();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1970 #endif
14918
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1971
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1972 /* NewGRF development stuff */
ec91e5febc5d (svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features.
frosch <frosch@openttd.org>
parents: 14917
diff changeset
1973 IConsoleCmdRegister("reload_newgrfs", ConNewGRFReload, ConHookNewGRFDeveloperTool);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1974 }