Mercurial > hg > openttd
annotate src/command.cpp @ 18769:7af05225a1dc draft
(svn r23617) -Add: ScriptTown::ExpandTown, to grow a town (GameScript only)
author | truebrain <truebrain@openttd.org> |
---|---|
date | Mon, 19 Dec 2011 20:57:51 +0000 |
parents | 10757b027360 |
children | ac0ceb4bc5f0 |
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:
12552
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12552
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12552
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:
12552
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:
12552
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:
12552
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12552
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:
9061
diff
changeset
|
10 /** @file command.cpp Handling of commands. */ |
6123
595dc16a6fd8
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6012
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" |
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:
6444
diff
changeset
|
13 #include "landscape.h" |
18627
1972f6346144
(svn r23474) -Codechange: move the declaration error related functions to error.h
rubidium <rubidium@openttd.org>
parents:
18379
diff
changeset
|
14 #include "error.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
|
15 #include "gui.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
|
16 #include "command_func.h" |
15860
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
17 #include "network/network_type.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
|
18 #include "network/network.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 #include "genworld.h" |
7609
9e4c3b886ccb
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium <rubidium@openttd.org>
parents:
7559
diff
changeset
|
20 #include "newgrf_storage.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8108
diff
changeset
|
21 #include "strings_func.h" |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
22 #include "gfx_func.h" |
17275
9efba2c3774d
(svn r22015) -Codechange: move yet another pair of methods from functions.h
rubidium <rubidium@openttd.org>
parents:
17152
diff
changeset
|
23 #include "texteff.hpp" |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
24 #include "town.h" |
8247
c0449b1df5e1
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium <rubidium@openttd.org>
parents:
8232
diff
changeset
|
25 #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
|
26 #include "company_func.h" |
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
27 #include "company_base.h" |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8275
diff
changeset
|
28 #include "signal_func.h" |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
29 #include "core/backup_type.hpp" |
16036
86c457462b35
(svn r20729) -Fix [FS#4107]: assert when overbuilding object
yexo <yexo@openttd.org>
parents:
15944
diff
changeset
|
30 #include "object_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
|
31 |
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
|
32 #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
|
33 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
34 CommandProc CmdBuildRailroadTrack; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
35 CommandProc CmdRemoveRailroadTrack; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
36 CommandProc CmdBuildSingleRail; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
37 CommandProc CmdRemoveSingleRail; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
38 |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
39 CommandProc CmdLandscapeClear; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
40 |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
41 CommandProc CmdBuildBridge; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
42 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
43 CommandProc CmdBuildRailStation; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
44 CommandProc CmdRemoveFromRailStation; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
45 CommandProc CmdConvertRail; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
46 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
47 CommandProc CmdBuildSingleSignal; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
48 CommandProc CmdRemoveSingleSignal; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
50 CommandProc CmdTerraformLand; |
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 |
15744
f9e8032ac213
(svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents:
15663
diff
changeset
|
52 CommandProc CmdBuildObject; |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
53 CommandProc CmdSellLandArea; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
54 |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
55 CommandProc CmdBuildTunnel; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
57 CommandProc CmdBuildTrainDepot; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
58 CommandProc CmdBuildRailWaypoint; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
59 CommandProc CmdRenameWaypoint; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
60 CommandProc CmdRemoveFromRailWaypoint; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
61 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
62 CommandProc CmdBuildRoadStop; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
63 CommandProc CmdRemoveRoadStop; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
65 CommandProc CmdBuildLongRoad; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
66 CommandProc CmdRemoveLongRoad; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
67 CommandProc CmdBuildRoad; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
68 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
69 CommandProc CmdBuildRoadDepot; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
70 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
71 CommandProc CmdBuildAirport; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
72 |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
73 CommandProc CmdBuildDock; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
75 CommandProc CmdBuildShipDepot; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
77 CommandProc CmdBuildBuoy; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
78 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
79 CommandProc CmdPlantTree; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
80 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
81 CommandProc CmdMoveRailVehicle; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 |
15849
f4ed8e905fee
(svn r20531) -Codechange: unify quite a bit of the vehicle building commands
rubidium <rubidium@openttd.org>
parents:
15744
diff
changeset
|
83 CommandProc CmdBuildVehicle; |
15850
efc03d77eb93
(svn r20532) -Codechange: unify selling of vehicles a bit
rubidium <rubidium@openttd.org>
parents:
15849
diff
changeset
|
84 CommandProc CmdSellVehicle; |
15854
43d172eac154
(svn r20536) -Codechange: unify the refitting of vehicles
rubidium <rubidium@openttd.org>
parents:
15850
diff
changeset
|
85 CommandProc CmdRefitVehicle; |
16075
ab8c26c4d456
(svn r20768) -Codechange: unify send-to-depot commands
rubidium <rubidium@openttd.org>
parents:
16053
diff
changeset
|
86 CommandProc CmdSendVehicleToDepot; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
88 CommandProc CmdForceTrainProceed; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
89 CommandProc CmdReverseTrainDirection; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
90 |
15865
270f9b0689cc
(svn r20547) -Change: the way order backups are performed. Now restoring an order doesn't require up to 765 commands.
rubidium <rubidium@openttd.org>
parents:
15864
diff
changeset
|
91 CommandProc CmdClearOrderBackup; |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
92 CommandProc CmdModifyOrder; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
93 CommandProc CmdSkipToOrder; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
94 CommandProc CmdDeleteOrder; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
95 CommandProc CmdInsertOrder; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
96 CommandProc CmdChangeServiceInt; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
97 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
98 CommandProc CmdBuildIndustry; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
99 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
100 CommandProc CmdSetCompanyManagerFace; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
101 CommandProc CmdSetCompanyColour; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
103 CommandProc CmdIncreaseLoan; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
104 CommandProc CmdDecreaseLoan; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
106 CommandProc CmdWantEnginePreview; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
108 CommandProc CmdRenameVehicle; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
109 CommandProc CmdRenameEngine; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
111 CommandProc CmdRenameCompany; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
112 CommandProc CmdRenamePresident; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
114 CommandProc CmdRenameStation; |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15046
diff
changeset
|
115 CommandProc CmdRenameDepot; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
117 CommandProc CmdPlaceSign; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
118 CommandProc CmdRenameSign; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
119 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
120 CommandProc CmdTurnRoadVeh; |
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 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
122 CommandProc CmdPause; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
123 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
124 CommandProc CmdBuyShareInCompany; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
125 CommandProc CmdSellShareInCompany; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
126 CommandProc CmdBuyCompany; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
128 CommandProc CmdFoundTown; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
129 CommandProc CmdRenameTown; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
130 CommandProc CmdDoTownAction; |
15657
ddfeab1a0a88
(svn r20322) -Codechange: Move Expand town code to a command.
terkhen <terkhen@openttd.org>
parents:
15370
diff
changeset
|
131 CommandProc CmdExpandTown; |
15658
52010e085f5e
(svn r20323) -Codechange: Move Delete town code to a command.
terkhen <terkhen@openttd.org>
parents:
15657
diff
changeset
|
132 CommandProc CmdDeleteTown; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
134 CommandProc CmdChangeSetting; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
135 CommandProc CmdChangeCompanySetting; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
137 CommandProc CmdOrderRefit; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
138 CommandProc CmdCloneOrder; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
139 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
140 CommandProc CmdClearArea; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
141 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
142 CommandProc CmdGiveMoney; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
143 CommandProc CmdMoneyCheat; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
144 CommandProc CmdBuildCanal; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
145 CommandProc CmdBuildLock; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
147 CommandProc CmdCompanyCtrl; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
149 CommandProc CmdLevelLand; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
151 CommandProc CmdBuildSignalTrack; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
152 CommandProc CmdRemoveSignalTrack; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
154 CommandProc CmdSetAutoReplace; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
156 CommandProc CmdCloneVehicle; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
157 CommandProc CmdStartStopVehicle; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
158 CommandProc CmdMassStartStopVehicle; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
159 CommandProc CmdAutoreplaceVehicle; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
160 CommandProc CmdDepotSellAllVehicles; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
161 CommandProc CmdDepotMassAutoReplace; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
162 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
163 CommandProc CmdCreateGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
164 CommandProc CmdRenameGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
165 CommandProc CmdDeleteGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
166 CommandProc CmdAddVehicleGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
167 CommandProc CmdAddSharedVehicleGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
168 CommandProc CmdRemoveAllVehiclesGroup; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
169 CommandProc CmdSetGroupReplaceProtection; |
6667
12d521513434
(svn r9898) -Fix (r9874): Many...
peter1138 <peter1138@openttd.org>
parents:
6643
diff
changeset
|
170 |
14237
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
171 CommandProc CmdMoveOrder; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
172 CommandProc CmdChangeTimetable; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
173 CommandProc CmdSetVehicleOnTime; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
174 CommandProc CmdAutofillTimetable; |
eb3340ea843f
(svn r18788) -Codechange: replace macro as without macro it's shorter than with the macro.
rubidium <rubidium@openttd.org>
parents:
14234
diff
changeset
|
175 CommandProc CmdSetTimetableStart; |
6832
17319fb8c1c3
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium <rubidium@openttd.org>
parents:
6794
diff
changeset
|
176 |
18379
1e02b7afbe01
(svn r23215) -Codechange: stricter type safety for CommandFlags
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
177 #define DEF_CMD(proc, flags, type) {proc, #proc, (CommandFlags)flags, type} |
14991
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
178 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
179 /** |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
180 * The master command table |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
181 * |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
182 * This table contains all possible CommandProc functions with |
14823
a6fd991f209d
(svn r19414) -Doc: Several doxygen additions and corrections.
alberth <alberth@openttd.org>
parents:
14645
diff
changeset
|
183 * the flags which belongs to it. The indices are the same |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
184 * as the value from the CMD_* enums. |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
185 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
186 static const Command _command_proc_table[] = { |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
187 DEF_CMD(CmdBuildRailroadTrack, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAILROAD_TRACK |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
188 DEF_CMD(CmdRemoveRailroadTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_RAILROAD_TRACK |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
189 DEF_CMD(CmdBuildSingleRail, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SINGLE_RAIL |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
190 DEF_CMD(CmdRemoveSingleRail, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SINGLE_RAIL |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
191 DEF_CMD(CmdLandscapeClear, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LANDSCAPE_CLEAR |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
192 DEF_CMD(CmdBuildBridge, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_BRIDGE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
193 DEF_CMD(CmdBuildRailStation, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_STATION |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
194 DEF_CMD(CmdBuildTrainDepot, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TRAIN_DEPOT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
195 DEF_CMD(CmdBuildSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SIGNALS |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
196 DEF_CMD(CmdRemoveSingleSignal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SIGNALS |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
197 DEF_CMD(CmdTerraformLand, CMD_ALL_TILES | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_TERRAFORM_LAND |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
198 DEF_CMD(CmdBuildObject, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_OBJECT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
199 DEF_CMD(CmdBuildTunnel, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_TUNNEL |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
200 DEF_CMD(CmdRemoveFromRailStation, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_STATION |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
201 DEF_CMD(CmdConvertRail, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CONVERT_RAILD |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
202 DEF_CMD(CmdBuildRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_RAIL_WAYPOINT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
203 DEF_CMD(CmdRenameWaypoint, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_WAYPOINT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
204 DEF_CMD(CmdRemoveFromRailWaypoint, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_FROM_RAIL_WAYPOINT |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
205 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
206 DEF_CMD(CmdBuildRoadStop, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_STOP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
207 DEF_CMD(CmdRemoveRoadStop, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_ROAD_STOP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
208 DEF_CMD(CmdBuildLongRoad, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_LONG_ROAD |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
209 DEF_CMD(CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
210 DEF_CMD(CmdBuildRoad, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
211 DEF_CMD(CmdBuildRoadDepot, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_ROAD_DEPOT |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
212 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
213 DEF_CMD(CmdBuildAirport, CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_AIRPORT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
214 DEF_CMD(CmdBuildDock, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_DOCK |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
215 DEF_CMD(CmdBuildShipDepot, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SHIP_DEPOT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
216 DEF_CMD(CmdBuildBuoy, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_BUOY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
217 DEF_CMD(CmdPlantTree, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_PLANT_TREE |
15854
43d172eac154
(svn r20536) -Codechange: unify the refitting of vehicles
rubidium <rubidium@openttd.org>
parents:
15850
diff
changeset
|
218 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
219 DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_BUILD_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
220 DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID, CMDT_VEHICLE_CONSTRUCTION ), // CMD_SELL_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
221 DEF_CMD(CmdRefitVehicle, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_REFIT_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
222 DEF_CMD(CmdSendVehicleToDepot, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_SEND_VEHICLE_TO_DEPOT |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
224 DEF_CMD(CmdMoveRailVehicle, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_MOVE_RAIL_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
225 DEF_CMD(CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_FORCE_TRAIN_PROCEED |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
226 DEF_CMD(CmdReverseTrainDirection, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_REVERSE_TRAIN_DIRECTION |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
227 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
228 DEF_CMD(CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_ROUTE_MANAGEMENT ), // CMD_CLEAR_ORDER_BACKUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
229 DEF_CMD(CmdModifyOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MODIFY_ORDER |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
230 DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
231 DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
232 DEF_CMD(CmdInsertOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_INSERT_ORDER |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
233 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
234 DEF_CMD(CmdChangeServiceInt, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_CHANGE_SERVICE_INT |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
235 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
236 DEF_CMD(CmdBuildIndustry, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_INDUSTRY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
237 DEF_CMD(CmdSetCompanyManagerFace, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_MANAGER_FACE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
238 DEF_CMD(CmdSetCompanyColour, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_COLOUR |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
239 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
240 DEF_CMD(CmdIncreaseLoan, 0, CMDT_MONEY_MANAGEMENT ), // CMD_INCREASE_LOAN |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
241 DEF_CMD(CmdDecreaseLoan, 0, CMDT_MONEY_MANAGEMENT ), // CMD_DECREASE_LOAN |
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 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
243 DEF_CMD(CmdWantEnginePreview, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_WANT_ENGINE_PREVIEW |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
245 DEF_CMD(CmdRenameVehicle, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
246 DEF_CMD(CmdRenameEngine, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_ENGINE |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
248 DEF_CMD(CmdRenameCompany, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_COMPANY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
249 DEF_CMD(CmdRenamePresident, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_PRESIDENT |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
250 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
251 DEF_CMD(CmdRenameStation, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_STATION |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
252 DEF_CMD(CmdRenameDepot, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_DEPOT |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
253 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
254 DEF_CMD(CmdPlaceSign, 0, CMDT_OTHER_MANAGEMENT ), // CMD_PLACE_SIGN |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
255 DEF_CMD(CmdRenameSign, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_SIGN |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
257 DEF_CMD(CmdTurnRoadVeh, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_TURN_ROADVEH |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
259 DEF_CMD(CmdPause, CMD_SERVER, CMDT_SERVER_SETTING ), // CMD_PAUSE |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
260 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
261 DEF_CMD(CmdBuyShareInCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_BUY_SHARE_IN_COMPANY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
262 DEF_CMD(CmdSellShareInCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_SELL_SHARE_IN_COMPANY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
263 DEF_CMD(CmdBuyCompany, 0, CMDT_MONEY_MANAGEMENT ), // CMD_BUY_COMANY |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
264 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
265 DEF_CMD(CmdFoundTown, CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_FOUND_TOWN; founding random town can fail only in exec run |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
266 DEF_CMD(CmdRenameTown, CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
267 DEF_CMD(CmdDoTownAction, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DO_TOWN_ACTION |
18769
7af05225a1dc
(svn r23617) -Add: ScriptTown::ExpandTown, to grow a town (GameScript only)
truebrain <truebrain@openttd.org>
parents:
18763
diff
changeset
|
268 DEF_CMD(CmdExpandTown, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_EXPAND_TOWN |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
269 DEF_CMD(CmdDeleteTown, CMD_OFFLINE, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DELETE_TOWN |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
270 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
271 DEF_CMD(CmdOrderRefit, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ORDER_REFIT |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
272 DEF_CMD(CmdCloneOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CLONE_ORDER |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
273 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
274 DEF_CMD(CmdClearArea, CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_CLEAR_AREA; destroying multi-tile houses makes town rating differ between test and execution |
8500
83450457346b
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138 <peter1138@openttd.org>
parents:
8486
diff
changeset
|
275 |
17276
6a57b4737132
(svn r22016) -Fix [FS#4479]: when paused and having the allowed actions while paused setting on "no actions" cheating money would fail
rubidium <rubidium@openttd.org>
parents:
17275
diff
changeset
|
276 DEF_CMD(CmdMoneyCheat, CMD_OFFLINE, CMDT_CHEAT ), // CMD_MONEY_CHEAT |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
277 DEF_CMD(CmdBuildCanal, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_CANAL |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
278 DEF_CMD(CmdCompanyCtrl, CMD_SPECTATOR | CMD_CLIENT_ID, CMDT_SERVER_SETTING ), // CMD_COMPANY_CTRL |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
279 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
280 DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
282 DEF_CMD(CmdBuildLock, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_LOCK |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
284 DEF_CMD(CmdBuildSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_SIGNAL_TRACK |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
285 DEF_CMD(CmdRemoveSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_REMOVE_SIGNAL_TRACK |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 |
16693
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
287 DEF_CMD(CmdGiveMoney, 0, CMDT_MONEY_MANAGEMENT ), // CMD_GIVE_MONEY |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
288 DEF_CMD(CmdChangeSetting, CMD_SERVER, CMDT_SERVER_SETTING ), // CMD_CHANGE_SETTING |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
289 DEF_CMD(CmdChangeCompanySetting, 0, CMDT_COMPANY_SETTING ), // CMD_CHANGE_COMPANY_SETTING |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
290 DEF_CMD(CmdSetAutoReplace, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_SET_AUTOREPLACE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
291 DEF_CMD(CmdCloneVehicle, CMD_NO_TEST, CMDT_VEHICLE_CONSTRUCTION ), // CMD_CLONE_VEHICLE; NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
292 DEF_CMD(CmdStartStopVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_START_STOP_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
293 DEF_CMD(CmdMassStartStopVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_MASS_START_STOP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
294 DEF_CMD(CmdAutoreplaceVehicle, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_AUTOREPLACE_VEHICLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
295 DEF_CMD(CmdDepotSellAllVehicles, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_DEPOT_SELL_ALL_VEHICLES |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
296 DEF_CMD(CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION ), // CMD_DEPOT_MASS_AUTOREPLACE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
297 DEF_CMD(CmdCreateGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CREATE_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
298 DEF_CMD(CmdDeleteGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
299 DEF_CMD(CmdRenameGroup, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
300 DEF_CMD(CmdAddVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_VEHICLE_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
301 DEF_CMD(CmdAddSharedVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_SHARE_VEHICLE_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
302 DEF_CMD(CmdRemoveAllVehiclesGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_REMOVE_ALL_VEHICLES_GROUP |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
303 DEF_CMD(CmdSetGroupReplaceProtection, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_REPLACE_PROTECTION |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
304 DEF_CMD(CmdMoveOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MOVE_ORDER |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
305 DEF_CMD(CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CHANGE_TIMETABLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
306 DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
307 DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE |
4088e343b147
(svn r21425) -Codechange: add "command types" to all commands
rubidium <rubidium@openttd.org>
parents:
16628
diff
changeset
|
308 DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
311 /*! |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
312 * This function range-checks a cmd, and checks if the cmd is not NULL |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
313 * |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
314 * @param cmd The integervalue of a command |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
315 * @return true if the command is valid (and got a CommandProc function) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
316 */ |
10237
d39d46dc7057
(svn r14465) -Codechange: minor code style of command.cpp.
rubidium <rubidium@openttd.org>
parents:
10225
diff
changeset
|
317 bool IsValidCommand(uint32 cmd) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 { |
10604
ec12a7f3eef8
(svn r14889) -Codechange: replace some magic numbers with constants.
rubidium <rubidium@openttd.org>
parents:
10515
diff
changeset
|
319 cmd &= CMD_ID_MASK; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 |
16547
a11cd939c335
(svn r21273) -Codechange: Return values should start at the same line.
alberth <alberth@openttd.org>
parents:
16075
diff
changeset
|
321 return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != 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
|
322 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
323 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
324 /*! |
10604
ec12a7f3eef8
(svn r14889) -Codechange: replace some magic numbers with constants.
rubidium <rubidium@openttd.org>
parents:
10515
diff
changeset
|
325 * This function mask the parameter with CMD_ID_MASK and returns |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
326 * the flags which belongs to the given command. |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
327 * |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
328 * @param cmd The integer value of the command |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
329 * @return The flags for this command |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
330 */ |
18379
1e02b7afbe01
(svn r23215) -Codechange: stricter type safety for CommandFlags
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
331 CommandFlags GetCommandFlags(uint32 cmd) |
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 { |
10237
d39d46dc7057
(svn r14465) -Codechange: minor code style of command.cpp.
rubidium <rubidium@openttd.org>
parents:
10225
diff
changeset
|
333 assert(IsValidCommand(cmd)); |
d39d46dc7057
(svn r14465) -Codechange: minor code style of command.cpp.
rubidium <rubidium@openttd.org>
parents:
10225
diff
changeset
|
334 |
10604
ec12a7f3eef8
(svn r14889) -Codechange: replace some magic numbers with constants.
rubidium <rubidium@openttd.org>
parents:
10515
diff
changeset
|
335 return _command_proc_table[cmd & CMD_ID_MASK].flags; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
336 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 |
14991
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
338 /*! |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
339 * This function mask the parameter with CMD_ID_MASK and returns |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
340 * the name which belongs to the given command. |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
341 * |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
342 * @param cmd The integer value of the command |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
343 * @return The name for this command |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
344 */ |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
345 const char *GetCommandName(uint32 cmd) |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
346 { |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
347 assert(IsValidCommand(cmd)); |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
348 |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
349 return _command_proc_table[cmd & CMD_ID_MASK].name; |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
350 } |
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
351 |
16695
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
352 /** |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
353 * Returns whether the command is allowed while the game is paused. |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
354 * @param cmd The command to check. |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
355 * @return True if the command is allowed while paused, false otherwise. |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
356 */ |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
357 bool IsCommandAllowedWhilePaused(uint32 cmd) |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
358 { |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
359 /* Lookup table for the command types that are allowed for a given pause level setting. */ |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
360 static const int command_type_lookup[] = { |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
361 CMDPL_ALL_ACTIONS, ///< CMDT_LANDSCAPE_CONSTRUCTION |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
362 CMDPL_NO_LANDSCAPING, ///< CMDT_VEHICLE_CONSTRUCTION |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
363 CMDPL_NO_LANDSCAPING, ///< CMDT_MONEY_MANAGEMENT |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
364 CMDPL_NO_CONSTRUCTION, ///< CMDT_VEHICLE_MANAGEMENT |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
365 CMDPL_NO_CONSTRUCTION, ///< CMDT_ROUTE_MANAGEMENT |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
366 CMDPL_NO_CONSTRUCTION, ///< CMDT_OTHER_MANAGEMENT |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
367 CMDPL_NO_CONSTRUCTION, ///< CMDT_COMPANY_SETTING |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
368 CMDPL_NO_ACTIONS, ///< CMDT_SERVER_SETTING |
17276
6a57b4737132
(svn r22016) -Fix [FS#4479]: when paused and having the allowed actions while paused setting on "no actions" cheating money would fail
rubidium <rubidium@openttd.org>
parents:
17275
diff
changeset
|
369 CMDPL_NO_ACTIONS, ///< CMDT_CHEAT |
16695
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
370 }; |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
371 assert_compile(lengthof(command_type_lookup) == CMDT_END); |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
372 |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
373 assert(IsValidCommand(cmd)); |
16698
857a686bb953
(svn r21430) -Feature [FS#1521]: building while paused always works in the scenario editor
rubidium <rubidium@openttd.org>
parents:
16696
diff
changeset
|
374 return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd & CMD_ID_MASK].type] <= _settings_game.construction.command_pause_level; |
16695
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
375 } |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
376 |
867a49c71d12
(svn r21427) -Add: helper function to determine whether a command may be executed
rubidium <rubidium@openttd.org>
parents:
16693
diff
changeset
|
377 |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
378 static int _docommand_recursive = 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
|
379 |
10624
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
380 /** |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
381 * Shorthand for calling the long DoCommand with a container. |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
382 * |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
383 * @param container Container with (almost) all information |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
384 * @param flags Flags for the command and how to execute the command |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
385 * @see CommandProc |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
386 * @return the cost |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
387 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
388 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags) |
10624
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
389 { |
10626
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10624
diff
changeset
|
390 return DoCommand(container->tile, container->p1, container->p2, flags, container->cmd & CMD_ID_MASK, container->text); |
10624
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
391 } |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
392 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
393 /*! |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
394 * This function executes a given command with the parameters from the #CommandProc parameter list. |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
395 * Depending on the flags parameter it execute or test a command. |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
396 * |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
397 * @param tile The tile to apply the command on (for the #CommandProc) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
398 * @param p1 Additional data for the command (for the #CommandProc) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
399 * @param p2 Additional data for the command (for the #CommandProc) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
400 * @param flags Flags for the command and how to execute the command |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
401 * @param cmd The command-id to execute (a value of the CMD_* enums) |
13067
082cdb4504ac
(svn r17567) -Fix: some doxygen warnings
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
402 * @param text The text to pass |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
403 * @see CommandProc |
10624
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
404 * @return the cost |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
405 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
406 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 { |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6832
diff
changeset
|
408 CommandCost res; |
5584
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 /* Do not even think about executing out-of-bounds tile-commands */ |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10707
diff
changeset
|
411 if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
412 |
12485
cf4a59021c9d
(svn r16922) -Codechange: unduplicate some vehicle CMD_*s and move the setting of the error message to a single place
rubidium <rubidium@openttd.org>
parents:
12094
diff
changeset
|
413 /* Chop of any CMD_MSG or other flags; we don't need those here */ |
cf4a59021c9d
(svn r16922) -Codechange: unduplicate some vehicle CMD_*s and move the setting of the error message to a single place
rubidium <rubidium@openttd.org>
parents:
12094
diff
changeset
|
414 CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].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
|
415 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
416 _docommand_recursive++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 |
6123
595dc16a6fd8
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6012
diff
changeset
|
418 /* only execute the test call if it's toplevel, or we're not execing. */ |
8486
99f058177c49
(svn r12061) -Cleanup: since r12060, DC_FORCETEST is not used anymore
smatz <smatz@openttd.org>
parents:
8442
diff
changeset
|
419 if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) { |
16036
86c457462b35
(svn r20729) -Fix [FS#4107]: assert when overbuilding object
yexo <yexo@openttd.org>
parents:
15944
diff
changeset
|
420 if (_docommand_recursive == 1) _cleared_object_areas.Clear(); |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
421 SetTownRatingTestMode(true); |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
422 res = proc(tile, flags & ~DC_EXEC, p1, p2, text); |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
423 SetTownRatingTestMode(false); |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
424 if (res.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
|
425 goto error; |
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 if (_docommand_recursive == 1 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 !(flags & DC_QUERY_COST) && |
8519
0e4b2a37af1f
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz <smatz@openttd.org>
parents:
8500
diff
changeset
|
430 !(flags & DC_BANKRUPT) && |
14824
fa89f804ec0f
(svn r19415) -Codechange: Forward CommandCost with an error back to the caller.
alberth <alberth@openttd.org>
parents:
14823
diff
changeset
|
431 !CheckCompanyHasMoney(res)) { // CheckCompanyHasMoney() modifies 'res' to an error if it fails. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 goto error; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
433 } |
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 if (!(flags & DC_EXEC)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 _docommand_recursive--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 return res; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
438 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
439 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 /* Execute the command here. All cost-relevant functions set the expenses type |
8230
5b61305fcdd4
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium <rubidium@openttd.org>
parents:
8199
diff
changeset
|
442 * themselves to the cost object at some point */ |
16036
86c457462b35
(svn r20729) -Fix [FS#4107]: assert when overbuilding object
yexo <yexo@openttd.org>
parents:
15944
diff
changeset
|
443 if (_docommand_recursive == 1) _cleared_object_areas.Clear(); |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
444 res = proc(tile, flags, p1, p2, text); |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
445 if (res.Failed()) { |
14232
860ea22258ba
(svn r18783) -Codechange: make CheckCompanyHasMoney set an error on the CommandCost it tests when you don't have enough money instead of setting a global variable.
rubidium <rubidium@openttd.org>
parents:
14230
diff
changeset
|
446 error: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 _docommand_recursive--; |
14824
fa89f804ec0f
(svn r19415) -Codechange: Forward CommandCost with an error back to the caller.
alberth <alberth@openttd.org>
parents:
14823
diff
changeset
|
448 return res; |
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 |
6123
595dc16a6fd8
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6012
diff
changeset
|
451 /* if toplevel, subtract the money. */ |
8519
0e4b2a37af1f
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz <smatz@openttd.org>
parents:
8500
diff
changeset
|
452 if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) { |
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:
10151
diff
changeset
|
453 SubtractMoneyFromCompany(res); |
5584
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
456 return res; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
457 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
458 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
459 /*! |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
460 * This functions returns the money which can be used to execute a command. |
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:
10151
diff
changeset
|
461 * This is either the money of the current company or INT64_MAX if there |
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:
10151
diff
changeset
|
462 * is no such a company "at the moment" like the server itself. |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
463 * |
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:
10151
diff
changeset
|
464 * @return The available money of a company or INT64_MAX |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
465 */ |
6990
a19700261804
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents:
6980
diff
changeset
|
466 Money GetAvailableMoneyForCommand() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
467 { |
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:
10151
diff
changeset
|
468 CompanyID company = _current_company; |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
469 if (!Company::IsValidID(company)) return INT64_MAX; |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11730
diff
changeset
|
470 return Company::Get(company)->money; |
5584
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 |
10624
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
473 /** |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
474 * Shortcut for the long DoCommandP when having a container with the data. |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
475 * @param container the container with information. |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
476 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
477 * @return true if the command succeeded, else false |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
478 */ |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
479 bool DoCommandP(const CommandContainer *container, bool my_cmd) |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
480 { |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
481 return DoCommandP(container->tile, container->p1, container->p2, container->cmd, container->callback, container->text, my_cmd); |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
482 } |
2f1e024c151f
(svn r14916) -Codechange: make it possible to send CommandContainers directly to DoCommand(P).
rubidium <rubidium@openttd.org>
parents:
10608
diff
changeset
|
483 |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
484 /*! |
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:
10151
diff
changeset
|
485 * Toplevel network safe docommand function for the current company. Must not be called recursively. |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
486 * The callback is called when the command succeeded or failed. The parameters |
14823
a6fd991f209d
(svn r19414) -Doc: Several doxygen additions and corrections.
alberth <alberth@openttd.org>
parents:
14645
diff
changeset
|
487 * \a tile, \a p1, and \a p2 are from the #CommandProc function. The parameter \a cmd is the command to execute. |
a6fd991f209d
(svn r19414) -Doc: Several doxygen additions and corrections.
alberth <alberth@openttd.org>
parents:
14645
diff
changeset
|
488 * The parameter \a my_cmd is used to indicate if the command is from a company or the server. |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
489 * |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
490 * @param tile The tile to perform a command on (see #CommandProc) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
491 * @param p1 Additional data for the command (see #CommandProc) |
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
492 * @param p2 Additional data for the command (see #CommandProc) |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
493 * @param cmd The command to execute (a CMD_* value) |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
494 * @param callback A callback function to call after the command is finished |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
495 * @param text The text to pass |
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:
10151
diff
changeset
|
496 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) |
14823
a6fd991f209d
(svn r19414) -Doc: Several doxygen additions and corrections.
alberth <alberth@openttd.org>
parents:
14645
diff
changeset
|
497 * @return \c true if the command succeeded, else \c false. |
7559
ad850ff2c61a
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7521
diff
changeset
|
498 */ |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
499 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
500 { |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
501 /* Cost estimation is generally only done when the |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
502 * local user presses shift while doing somthing. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
503 * However, in case of incoming network commands, |
17976
776acb0fd15e
(svn r22785) -Codechange: rename IsGeneratingWorld to HasModalProgress
rubidium <rubidium@openttd.org>
parents:
17838
diff
changeset
|
504 * map generation or the pause button we do want |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
505 * to execute. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
506 bool estimate_only = _shift_pressed && IsLocalCompany() && |
17976
776acb0fd15e
(svn r22785) -Codechange: rename IsGeneratingWorld to HasModalProgress
rubidium <rubidium@openttd.org>
parents:
17838
diff
changeset
|
507 !_generating_world && |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
508 !(cmd & CMD_NETWORK_COMMAND) && |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
509 (cmd & CMD_ID_MASK) != CMD_PAUSE; |
10605
32ba3eb6d7c9
(svn r14890) -Codechange: move the notest information into the command table.
rubidium <rubidium@openttd.org>
parents:
10604
diff
changeset
|
510 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
511 /* We're only sending the command, so don't do |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
512 * fancy things for 'success'. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
513 bool only_sending = _networking && !(cmd & CMD_NETWORK_COMMAND); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
514 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
515 /* Where to show the message? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
516 int x = TileX(tile) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
517 int y = TileY(tile) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
518 |
16696
5e2e046a1886
(svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting
rubidium <rubidium@openttd.org>
parents:
16695
diff
changeset
|
519 if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd)) { |
5e2e046a1886
(svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting
rubidium <rubidium@openttd.org>
parents:
16695
diff
changeset
|
520 ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y); |
5e2e046a1886
(svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting
rubidium <rubidium@openttd.org>
parents:
16695
diff
changeset
|
521 return false; |
5e2e046a1886
(svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting
rubidium <rubidium@openttd.org>
parents:
16695
diff
changeset
|
522 } |
5e2e046a1886
(svn r21428) -Fix [FS#4021]: vehicles could be built while the game it paused. Now you can enable or disable that with a setting
rubidium <rubidium@openttd.org>
parents:
16695
diff
changeset
|
523 |
15860
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
524 #ifdef ENABLE_NETWORK |
15864
1ce9c097ee89
(svn r20546) -Fix (r20542): starting AIs shouldn't cause an assertion to trigger
rubidium <rubidium@openttd.org>
parents:
15860
diff
changeset
|
525 /* Only set p2 when the command does not come from the network. */ |
15865
270f9b0689cc
(svn r20547) -Change: the way order backups are performed. Now restoring an order doesn't require up to 765 commands.
rubidium <rubidium@openttd.org>
parents:
15864
diff
changeset
|
526 if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER; |
15860
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
527 #endif |
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
528 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
529 CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only); |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
530 if (res.Failed()) { |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
531 /* Only show the error when it's for us. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
532 StringID error_part1 = GB(cmd, 16, 16); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
533 if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) { |
17838
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
534 ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackSize(), res.GetTextRefStack()); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
535 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
536 } else if (estimate_only) { |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
537 ShowEstimatedCostOrIncome(res.GetCost(), x, y); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
538 } else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) { |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
539 /* Only show the cost animation when we did actually |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
540 * execute the command, i.e. we're not sending it to |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
541 * the server, when it has cost the local company |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
542 * something. Furthermore in the editor there is no |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
543 * concept of cost, so don't show it there either. */ |
18255
b3cb40aab91b
(svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents:
18167
diff
changeset
|
544 ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost()); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
545 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
546 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
547 if (!estimate_only && !only_sending && callback != NULL) { |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
548 callback(res, tile, p1, p2); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
549 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
550 |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
551 return res.Succeeded(); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
552 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
553 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
554 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
555 /** |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
556 * Helper to deduplicate the code for returning. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
557 * @param cmd the command cost to return. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
558 * @param clear whether to keep the storage changes or not. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
559 */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
560 #define return_dcpi(cmd, clear) { _docommand_recursive = 0; ClearStorageChanges(clear); return cmd; } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
561 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
562 /*! |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
563 * Helper function for the toplevel network safe docommand function for the current company. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
564 * |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
565 * @param tile The tile to perform a command on (see #CommandProc) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
566 * @param p1 Additional data for the command (see #CommandProc) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
567 * @param p2 Additional data for the command (see #CommandProc) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
568 * @param cmd The command to execute (a CMD_* value) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
569 * @param callback A callback function to call after the command is finished |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
570 * @param text The text to pass |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
571 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
572 * @param estimate_only whether to give only the estimate or also execute the command |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
573 * @return the command cost of this function. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
574 */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
575 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
576 { |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
577 /* Prevent recursion; it gives a mess over the network */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
578 assert(_docommand_recursive == 0); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
579 _docommand_recursive = 1; |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
580 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
581 /* Reset the state. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 _additional_cash_required = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
583 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
584 /* Get pointer to command handler */ |
10604
ec12a7f3eef8
(svn r14889) -Codechange: replace some magic numbers with constants.
rubidium <rubidium@openttd.org>
parents:
10515
diff
changeset
|
585 byte cmd_id = cmd & CMD_ID_MASK; |
ec12a7f3eef8
(svn r14889) -Codechange: replace some magic numbers with constants.
rubidium <rubidium@openttd.org>
parents:
10515
diff
changeset
|
586 assert(cmd_id < lengthof(_command_proc_table)); |
10605
32ba3eb6d7c9
(svn r14890) -Codechange: move the notest information into the command table.
rubidium <rubidium@openttd.org>
parents:
10604
diff
changeset
|
587 |
32ba3eb6d7c9
(svn r14890) -Codechange: move the notest information into the command table.
rubidium <rubidium@openttd.org>
parents:
10604
diff
changeset
|
588 CommandProc *proc = _command_proc_table[cmd_id].proc; |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
589 /* Shouldn't happen, but you never know when someone adds |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
590 * NULLs to the _command_proc_table. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
591 assert(proc != 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
|
592 |
10605
32ba3eb6d7c9
(svn r14890) -Codechange: move the notest information into the command table.
rubidium <rubidium@openttd.org>
parents:
10604
diff
changeset
|
593 /* Command flags are used internally */ |
18379
1e02b7afbe01
(svn r23215) -Codechange: stricter type safety for CommandFlags
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
594 CommandFlags cmd_flags = GetCommandFlags(cmd); |
10692
0b7e235f99df
(svn r15014) -Codechange: Add a helper function to get the needed DC_xxx flags from the result of GetCommandFlags().
frosch <frosch@openttd.org>
parents:
10626
diff
changeset
|
595 /* Flags get send to the DoCommand */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
596 DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags); |
7521
f5b39ff47e0e
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium <rubidium@openttd.org>
parents:
7506
diff
changeset
|
597 |
15860
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
598 #ifdef ENABLE_NETWORK |
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
599 /* Make sure p2 is properly set to a ClientID. */ |
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
600 assert(!(cmd_flags & CMD_CLIENT_ID) || p2 != 0); |
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
601 #endif |
bb167d01deb9
(svn r20542) -Codechange: generalise the setting of "p2" to the ClientID.
rubidium <rubidium@openttd.org>
parents:
15854
diff
changeset
|
602 |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10707
diff
changeset
|
603 /* Do not even think about executing out-of-bounds tile-commands */ |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
604 if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR, false); |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10707
diff
changeset
|
605 |
12029
e54c72d34d74
(svn r16436) -Codechange: always execute 'spectator'/'server' commands as spectator. This to reduce the difference between dedicated and non-dedicated servers and normal clients.
rubidium <rubidium@openttd.org>
parents:
12028
diff
changeset
|
606 /* Always execute server and spectator commands as spectator */ |
15370
a7ff8375c2c4
(svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents:
15294
diff
changeset
|
607 bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0; |
12031
34d22b1974a4
(svn r16438) -Fix (r16436): set 'old_company' after modifying '_current_company'
smatz <smatz@openttd.org>
parents:
12029
diff
changeset
|
608 |
12028
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
609 /* If the company isn't valid it may only do server command or start a new company! |
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
610 * The server will ditch any server commands a client sends to it, so effectively |
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
611 * this guards the server from executing functions for an invalid company. */ |
18754
114868c40989
(svn r23602) -Add: support for DEITY commands, commands where no real company was involved in (Rubidium)
truebrain <truebrain@openttd.org>
parents:
18627
diff
changeset
|
612 if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) { |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
613 return_dcpi(CMD_ERROR, false); |
12028
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
614 } |
10997
0692d0966f52
(svn r15337) -Fix: don't allow a spectating server to build stuff.
rubidium <rubidium@openttd.org>
parents:
10995
diff
changeset
|
615 |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
616 Backup<CompanyByte> cur_company(_current_company, FILE_LINE); |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
617 if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR); |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
618 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
619 bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0; |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
620 bool skip_test = _networking && (cmd & CMD_NO_TEST_IF_IN_NETWORK) != 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
|
621 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
622 /* Do we need to do a test run? |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
623 * Basically we need to always do this, except when |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
624 * the no-test-in-network flag is giving and we're |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
625 * in a network game (e.g. restoring orders would |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
626 * fail this test because the first order does not |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
627 * exist yet when inserting the second, giving that |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
628 * a wrong insert location and ignoring the command |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
629 * and thus breaking restoring). However, when we |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
630 * just want to do cost estimation we don't care |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
631 * because it's only done once anyway. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
632 CommandCost res; |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
633 if (estimate_only || !skip_test) { |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
634 /* Test the command. */ |
16036
86c457462b35
(svn r20729) -Fix [FS#4107]: assert when overbuilding object
yexo <yexo@openttd.org>
parents:
15944
diff
changeset
|
635 _cleared_object_areas.Clear(); |
8442
1a90922472a6
(svn r12012) -Fix (r11795): Enable TownRatingTestMode during cost estimation with 'shift'-key.
frosch <frosch@openttd.org>
parents:
8306
diff
changeset
|
636 SetTownRatingTestMode(true); |
18167
9c82695de33e
(svn r22996) -Fix: make sure temporary storage is cleared before test and exec runs for DoCommands so NewGRF callbacks can't change the result between the runs
yexo <yexo@openttd.org>
parents:
17976
diff
changeset
|
637 ClearStorageChanges(false); |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10237
diff
changeset
|
638 res = proc(tile, flags, p1, p2, text); |
8442
1a90922472a6
(svn r12012) -Fix (r11795): Enable TownRatingTestMode during cost estimation with 'shift'-key.
frosch <frosch@openttd.org>
parents:
8306
diff
changeset
|
639 SetTownRatingTestMode(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
|
640 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
641 /* Make sure we're not messing things up here. */ |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
642 assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify()); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
643 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
644 /* If the command fails, we're doing an estimate |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
645 * or the player does not have enough money |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
646 * (unless it's a command where the test and |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
647 * execution phase might return different costs) |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
648 * we bail out here. */ |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
649 if (res.Failed() || estimate_only || |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
650 (!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) { |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
651 cur_company.Restore(); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
652 return_dcpi(res, false); |
14232
860ea22258ba
(svn r18783) -Codechange: make CheckCompanyHasMoney set an error on the CommandCost it tests when you don't have enough money instead of setting a global variable.
rubidium <rubidium@openttd.org>
parents:
14230
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 } |
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 #ifdef ENABLE_NETWORK |
12028
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
657 /* |
1a9da6452071
(svn r16435) -Codechange: don't require the 'user company 0' hack for commands.
rubidium <rubidium@openttd.org>
parents:
12022
diff
changeset
|
658 * If we are in network, and the command is not from the network |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
659 * send it to the command-queue and abort execution |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
660 */ |
18763
10757b027360
(svn r23611) -Add: run the begin of the script already while generating, and don't sleep on DoCommand while doing so
truebrain <truebrain@openttd.org>
parents:
18754
diff
changeset
|
661 if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) { |
16628
20d6e821aaad
(svn r21358) -Codechange: make some network function names conform to coding style
rubidium <rubidium@openttd.org>
parents:
16547
diff
changeset
|
662 NetworkSendCommand(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company); |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
663 cur_company.Restore(); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
664 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
665 /* Don't return anything special here; no error, no costs. |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
666 * This way it's not handled by DoCommand and only the |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
667 * actual execution of the command causes messages. Also |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
668 * reset the storages as we've not executed the command. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
669 return_dcpi(CommandCost(), 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
|
670 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
671 #endif /* ENABLE_NETWORK */ |
14991
6790e0d0f93d
(svn r19602) -Codechange: add the name of the command to the desync logs
rubidium <rubidium@openttd.org>
parents:
14990
diff
changeset
|
672 DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd)); |
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 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
674 /* Actually try and execute the command. If no cost-type is given |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
675 * use the construction one */ |
16036
86c457462b35
(svn r20729) -Fix [FS#4107]: assert when overbuilding object
yexo <yexo@openttd.org>
parents:
15944
diff
changeset
|
676 _cleared_object_areas.Clear(); |
18167
9c82695de33e
(svn r22996) -Fix: make sure temporary storage is cleared before test and exec runs for DoCommands so NewGRF callbacks can't change the result between the runs
yexo <yexo@openttd.org>
parents:
17976
diff
changeset
|
677 ClearStorageChanges(false); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
678 CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
679 |
15294
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
680 if (cmd_id == CMD_COMPANY_CTRL) { |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
681 cur_company.Trash(); |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
682 /* We are a new company -> Switch to new local company. |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
683 * We were closed down -> Switch to spectator |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
684 * Some other company opened/closed down -> The outside function will switch back */ |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
685 _current_company = _local_company; |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
686 } else { |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
687 /* Make sure nothing bad happened, like changing the current company. */ |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
688 assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify()); |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
689 cur_company.Restore(); |
c3d64c33d3d4
(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in sync during GUI operation.
frosch <frosch@openttd.org>
parents:
15172
diff
changeset
|
690 } |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
691 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
692 /* If the test and execution can differ, or we skipped the test |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
693 * we have to check the return of the command. Otherwise we can |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
694 * check whether the test and execution have yielded the same |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
695 * result, i.e. cost and error state are the same. */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
696 if (!test_and_exec_can_differ && !skip_test) { |
14314
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
697 assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check |
60d313b887b8
(svn r18866) -Codechange: remove the CmdFailed(ret)/CmdSucceeded(ret) wrapper functions
rubidium <rubidium@openttd.org>
parents:
14237
diff
changeset
|
698 } else if (res2.Failed()) { |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
699 return_dcpi(res2, false); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
700 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
701 |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
702 /* If we're needing more money and we haven't done |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
703 * anything yet, ask for the money! */ |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
704 if (_additional_cash_required != 0 && res2.GetCost() == 0) { |
15046
01f8db5ece32
(svn r19663) -Fix: in rare cases, update of signals could be missed
smatz <smatz@openttd.org>
parents:
14991
diff
changeset
|
705 /* It could happen we removed rail, thus gained money, and deleted something else. |
01f8db5ece32
(svn r19663) -Fix: in rare cases, update of signals could be missed
smatz <smatz@openttd.org>
parents:
14991
diff
changeset
|
706 * So make sure the signal buffer is empty even in this case */ |
01f8db5ece32
(svn r19663) -Fix: in rare cases, update of signals could be missed
smatz <smatz@openttd.org>
parents:
14991
diff
changeset
|
707 UpdateSignalsInBuffer(); |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
708 SetDParam(0, _additional_cash_required); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
709 return_dcpi(CommandCost(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY), false); |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
710 } |
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
711 |
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:
10151
diff
changeset
|
712 /* update last build coordinate of company. */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
713 if (tile != 0) { |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
714 Company *c = Company::GetIfValid(_current_company); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
715 if (c != NULL) c->last_build_coordinate = tile; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 |
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:
10151
diff
changeset
|
718 SubtractMoneyFromCompany(res2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8275
diff
changeset
|
720 /* update signals if needed */ |
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8275
diff
changeset
|
721 UpdateSignalsInBuffer(); |
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8275
diff
changeset
|
722 |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
723 return_dcpi(res2, 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
|
724 } |
14234
81d35fec0dca
(svn r18785) -Codechange: rewrite/rework DoCommandP in order to simplify it, reduce duplication and remove gotos.
rubidium <rubidium@openttd.org>
parents:
14233
diff
changeset
|
725 #undef return_dcpi |
8854
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
726 |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
727 |
14557
b1b3804dd055
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
alberth <alberth@openttd.org>
parents:
14418
diff
changeset
|
728 /** |
b1b3804dd055
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
alberth <alberth@openttd.org>
parents:
14418
diff
changeset
|
729 * Adds the cost of the given command return value to this cost. |
b1b3804dd055
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
alberth <alberth@openttd.org>
parents:
14418
diff
changeset
|
730 * Also takes a possible error message when it is set. |
b1b3804dd055
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
alberth <alberth@openttd.org>
parents:
14418
diff
changeset
|
731 * @param ret The command to add the cost of. |
b1b3804dd055
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
alberth <alberth@openttd.org>
parents:
14418
diff
changeset
|
732 */ |
14559
14735f06c670
(svn r19130) -Codechange: Use references and inlining in CommandCost.
alberth <alberth@openttd.org>
parents:
14557
diff
changeset
|
733 void CommandCost::AddCost(const CommandCost &ret) |
8854
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
734 { |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
735 this->AddCost(ret.cost); |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
736 if (this->success && !ret.success) { |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
737 this->message = ret.message; |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
738 this->success = false; |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
739 } |
855ce528445f
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz <smatz@openttd.org>
parents:
8841
diff
changeset
|
740 } |
17838
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
741 |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
742 /** |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
743 * Values to put on the #TextRefStack for the error message. |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
744 * There is only one static instance of the array, just like there is only one |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
745 * instance of normal DParams. |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
746 */ |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
747 uint32 CommandCost::textref_stack[16]; |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
748 |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
749 /** |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
750 * Activate usage of the NewGRF #TextRefStack for the error message. |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
751 * @param number of entries to copy from the temporary NewGRF registers |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
752 */ |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
753 void CommandCost::UseTextRefStack(uint num_registers) |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
754 { |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
755 extern TemporaryStorageArray<int32, 0x110> _temp_store; |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
756 |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
757 assert(num_registers < lengthof(textref_stack)); |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
758 this->textref_stack_size = num_registers; |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
759 for (uint i = 0; i < num_registers; i++) { |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
760 textref_stack[i] = _temp_store.GetValue(0x100 + i); |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
761 } |
8d2357ed5379
(svn r22629) -Fix [FS#4599]: Remove all usages of the ErrorRefStack. It was continuously overwritten by e.g. industry prospection without closing the old error window; also StopTextRefStackUsage() was not called for errors returned by commands (which caused FS#4599). Now return in the CommandCost result whether the textref stack needs to be used, and store a copy of the stack values in the error window just like for the normal string parameters.
frosch <frosch@openttd.org>
parents:
17276
diff
changeset
|
762 } |