author | rubidium |
Wed, 23 Apr 2008 20:56:08 +0000 | |
changeset 10314 | 9cfcdd5b5ddb |
parent 10080 | e0a9b92ed875 |
child 10372 | 93844492fdd9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
3 |
/** @file command.cpp */ |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1877
diff
changeset
|
6 |
#include "openttd.h" |
6949
72d11a1e1e60
(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
parents:
6940
diff
changeset
|
7 |
#include "landscape.h" |
8604
8afdd9877afd
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
8603
diff
changeset
|
8 |
#include "tile_map.h" |
0 | 9 |
#include "gui.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
10 |
#include "command_func.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5067
diff
changeset
|
11 |
#include "network/network.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
1980
diff
changeset
|
12 |
#include "variables.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4000
diff
changeset
|
13 |
#include "genworld.h" |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8055
diff
changeset
|
14 |
#include "newgrf_storage.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8604
diff
changeset
|
15 |
#include "strings_func.h" |
8619
c2434269c3eb
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8612
diff
changeset
|
16 |
#include "gfx_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8619
diff
changeset
|
17 |
#include "functions.h" |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
18 |
#include "town.h" |
8743
62a558995c35
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium
parents:
8728
diff
changeset
|
19 |
#include "date_func.h" |
62a558995c35
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium
parents:
8728
diff
changeset
|
20 |
#include "debug.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8743
diff
changeset
|
21 |
#include "player_func.h" |
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8743
diff
changeset
|
22 |
#include "player_base.h" |
8802
e08824cdab46
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents:
8771
diff
changeset
|
23 |
#include "signal_func.h" |
0 | 24 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
25 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
26 |
|
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
27 |
const char *_cmd_text = NULL; |
8771
f7ad4dba14bf
(svn r11839) -Codechange: move some variables from variables.h to a more logical location.
rubidium
parents:
8760
diff
changeset
|
28 |
StringID _error_message; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
29 |
|
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
30 |
/** |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
31 |
* Helper macro to define the header of all command handler macros. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
32 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
33 |
* This macro create the function header for a given command handler function, as |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
34 |
* all command handler functions got the parameters from the #CommandProc callback |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
35 |
* type. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
36 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
37 |
* @param yyyy The desired function name of the new command handler function. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
38 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7328
diff
changeset
|
39 |
#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 40 |
|
41 |
DEF_COMMAND(CmdBuildRailroadTrack); |
|
42 |
DEF_COMMAND(CmdRemoveRailroadTrack); |
|
43 |
DEF_COMMAND(CmdBuildSingleRail); |
|
44 |
DEF_COMMAND(CmdRemoveSingleRail); |
|
45 |
||
46 |
DEF_COMMAND(CmdLandscapeClear); |
|
47 |
||
48 |
DEF_COMMAND(CmdBuildBridge); |
|
49 |
||
50 |
DEF_COMMAND(CmdBuildRailroadStation); |
|
51 |
DEF_COMMAND(CmdRemoveFromRailroadStation); |
|
52 |
DEF_COMMAND(CmdConvertRail); |
|
53 |
||
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1217
diff
changeset
|
54 |
DEF_COMMAND(CmdBuildSingleSignal); |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1217
diff
changeset
|
55 |
DEF_COMMAND(CmdRemoveSingleSignal); |
0 | 56 |
|
57 |
DEF_COMMAND(CmdTerraformLand); |
|
58 |
||
59 |
DEF_COMMAND(CmdPurchaseLandArea); |
|
60 |
DEF_COMMAND(CmdSellLandArea); |
|
61 |
||
62 |
DEF_COMMAND(CmdBuildTunnel); |
|
63 |
||
64 |
DEF_COMMAND(CmdBuildTrainDepot); |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
215
diff
changeset
|
65 |
DEF_COMMAND(CmdBuildTrainWaypoint); |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
215
diff
changeset
|
66 |
DEF_COMMAND(CmdRenameWaypoint); |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
215
diff
changeset
|
67 |
DEF_COMMAND(CmdRemoveTrainWaypoint); |
0 | 68 |
|
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
69 |
DEF_COMMAND(CmdBuildRoadStop); |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5838
diff
changeset
|
70 |
DEF_COMMAND(CmdRemoveRoadStop); |
0 | 71 |
|
72 |
DEF_COMMAND(CmdBuildLongRoad); |
|
73 |
DEF_COMMAND(CmdRemoveLongRoad); |
|
74 |
DEF_COMMAND(CmdBuildRoad); |
|
75 |
DEF_COMMAND(CmdRemoveRoad); |
|
76 |
||
77 |
DEF_COMMAND(CmdBuildRoadDepot); |
|
78 |
||
79 |
DEF_COMMAND(CmdBuildAirport); |
|
80 |
||
81 |
DEF_COMMAND(CmdBuildDock); |
|
82 |
||
83 |
DEF_COMMAND(CmdBuildShipDepot); |
|
84 |
||
85 |
DEF_COMMAND(CmdBuildBuoy); |
|
86 |
||
87 |
DEF_COMMAND(CmdPlantTree); |
|
88 |
||
89 |
DEF_COMMAND(CmdBuildRailVehicle); |
|
90 |
DEF_COMMAND(CmdMoveRailVehicle); |
|
91 |
||
92 |
DEF_COMMAND(CmdStartStopTrain); |
|
93 |
||
94 |
DEF_COMMAND(CmdSellRailWagon); |
|
95 |
||
1794
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1786
diff
changeset
|
96 |
DEF_COMMAND(CmdSendTrainToDepot); |
0 | 97 |
DEF_COMMAND(CmdForceTrainProceed); |
98 |
DEF_COMMAND(CmdReverseTrainDirection); |
|
99 |
||
100 |
DEF_COMMAND(CmdModifyOrder); |
|
7290
647d6416cdfe
(svn r10033) -Feature [FS#760]: skip to the selected order in the order list when clicking on the "skip" button while pressing CTRL.
rubidium
parents:
7163
diff
changeset
|
101 |
DEF_COMMAND(CmdSkipToOrder); |
0 | 102 |
DEF_COMMAND(CmdDeleteOrder); |
103 |
DEF_COMMAND(CmdInsertOrder); |
|
2819
710436dd4288
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2809
diff
changeset
|
104 |
DEF_COMMAND(CmdChangeServiceInt); |
0 | 105 |
DEF_COMMAND(CmdRestoreOrderIndex); |
106 |
||
107 |
DEF_COMMAND(CmdBuildIndustry); |
|
108 |
||
109 |
DEF_COMMAND(CmdBuildCompanyHQ); |
|
110 |
DEF_COMMAND(CmdSetPlayerFace); |
|
111 |
DEF_COMMAND(CmdSetPlayerColor); |
|
112 |
||
113 |
DEF_COMMAND(CmdIncreaseLoan); |
|
114 |
DEF_COMMAND(CmdDecreaseLoan); |
|
115 |
||
116 |
DEF_COMMAND(CmdWantEnginePreview); |
|
117 |
||
118 |
DEF_COMMAND(CmdNameVehicle); |
|
119 |
DEF_COMMAND(CmdRenameEngine); |
|
120 |
||
121 |
DEF_COMMAND(CmdChangeCompanyName); |
|
122 |
DEF_COMMAND(CmdChangePresidentName); |
|
123 |
||
124 |
DEF_COMMAND(CmdRenameStation); |
|
125 |
||
126 |
DEF_COMMAND(CmdSellAircraft); |
|
127 |
DEF_COMMAND(CmdStartStopAircraft); |
|
128 |
DEF_COMMAND(CmdBuildAircraft); |
|
129 |
DEF_COMMAND(CmdSendAircraftToHangar); |
|
130 |
DEF_COMMAND(CmdRefitAircraft); |
|
131 |
||
132 |
DEF_COMMAND(CmdPlaceSign); |
|
133 |
DEF_COMMAND(CmdRenameSign); |
|
134 |
||
135 |
DEF_COMMAND(CmdBuildRoadVeh); |
|
136 |
DEF_COMMAND(CmdStartStopRoadVeh); |
|
137 |
DEF_COMMAND(CmdSellRoadVeh); |
|
138 |
DEF_COMMAND(CmdSendRoadVehToDepot); |
|
139 |
DEF_COMMAND(CmdTurnRoadVeh); |
|
3990
d3d23f3bcd34
(svn r5191) - NewGRF: add cargo refit support for road vehicles
peter1138
parents:
3491
diff
changeset
|
140 |
DEF_COMMAND(CmdRefitRoadVeh); |
0 | 141 |
|
142 |
DEF_COMMAND(CmdPause); |
|
143 |
||
144 |
DEF_COMMAND(CmdBuyShareInCompany); |
|
145 |
DEF_COMMAND(CmdSellShareInCompany); |
|
146 |
DEF_COMMAND(CmdBuyCompany); |
|
147 |
||
148 |
DEF_COMMAND(CmdBuildTown); |
|
149 |
||
150 |
DEF_COMMAND(CmdRenameTown); |
|
151 |
DEF_COMMAND(CmdDoTownAction); |
|
152 |
||
153 |
DEF_COMMAND(CmdSetRoadDriveSide); |
|
154 |
||
155 |
DEF_COMMAND(CmdChangeDifficultyLevel); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
156 |
DEF_COMMAND(CmdChangePatchSetting); |
0 | 157 |
|
158 |
DEF_COMMAND(CmdStartStopShip); |
|
159 |
DEF_COMMAND(CmdSellShip); |
|
160 |
DEF_COMMAND(CmdBuildShip); |
|
161 |
DEF_COMMAND(CmdSendShipToDepot); |
|
162 |
DEF_COMMAND(CmdRefitShip); |
|
163 |
||
4712
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4662
diff
changeset
|
164 |
DEF_COMMAND(CmdOrderRefit); |
0 | 165 |
DEF_COMMAND(CmdCloneOrder); |
166 |
||
167 |
DEF_COMMAND(CmdClearArea); |
|
168 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
169 |
DEF_COMMAND(CmdGiveMoney); |
0 | 170 |
DEF_COMMAND(CmdMoneyCheat); |
171 |
DEF_COMMAND(CmdBuildCanal); |
|
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
58
diff
changeset
|
172 |
DEF_COMMAND(CmdBuildLock); |
0 | 173 |
|
174 |
DEF_COMMAND(CmdPlayerCtrl); |
|
175 |
||
176 |
DEF_COMMAND(CmdLevelLand); |
|
177 |
||
178 |
DEF_COMMAND(CmdRefitRailVehicle); |
|
179 |
||
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1217
diff
changeset
|
180 |
DEF_COMMAND(CmdBuildSignalTrack); |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1217
diff
changeset
|
181 |
DEF_COMMAND(CmdRemoveSignalTrack); |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
182 |
|
4661
59492734db06
(svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents:
4659
diff
changeset
|
183 |
DEF_COMMAND(CmdSetAutoReplace); |
812
79c99885ad00
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
679
diff
changeset
|
184 |
|
2244 | 185 |
DEF_COMMAND(CmdCloneVehicle); |
4640
cabffc571e55
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4300
diff
changeset
|
186 |
DEF_COMMAND(CmdMassStartStopVehicle); |
4659
2f99f35d5813
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4640
diff
changeset
|
187 |
DEF_COMMAND(CmdDepotSellAllVehicles); |
4662
a20121e5442b
(svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents:
4661
diff
changeset
|
188 |
DEF_COMMAND(CmdDepotMassAutoReplace); |
2244 | 189 |
|
7139
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
190 |
DEF_COMMAND(CmdCreateGroup); |
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
191 |
DEF_COMMAND(CmdRenameGroup); |
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
192 |
DEF_COMMAND(CmdDeleteGroup); |
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
193 |
DEF_COMMAND(CmdAddVehicleGroup); |
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
194 |
DEF_COMMAND(CmdAddSharedVehicleGroup); |
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
7126
diff
changeset
|
195 |
DEF_COMMAND(CmdRemoveAllVehiclesGroup); |
7163 | 196 |
DEF_COMMAND(CmdSetGroupReplaceProtection); |
197 |
||
7328
8ac64204c17f
(svn r10071) -Feature [FS#828]: moving of orders (skidd13).
rubidium
parents:
7290
diff
changeset
|
198 |
DEF_COMMAND(CmdMoveOrder); |
7476
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
7453
diff
changeset
|
199 |
DEF_COMMAND(CmdChangeTimetable); |
7f086e4b2a76
(svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents:
7453
diff
changeset
|
200 |
DEF_COMMAND(CmdSetVehicleOnTime); |
7562
f6f62814907b
(svn r10331) -Feature: Add the possibility of automatically filling in timetables based on
maedhros
parents:
7498
diff
changeset
|
201 |
DEF_COMMAND(CmdAutofillTimetable); |
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
202 |
#undef DEF_COMMAND |
1804
7810fc0aa941
(svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents:
1802
diff
changeset
|
203 |
|
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
204 |
/** |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
205 |
* The master command table |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
206 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
207 |
* This table contains all possible CommandProc functions with |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
208 |
* the flags which belongs to it. The indizes are the same |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
209 |
* as the value from the CMD_* enums. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
210 |
*/ |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
211 |
static const Command _command_proc_table[] = { |
8996
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
212 |
{CmdBuildRailroadTrack, CMD_AUTO}, /* CMD_BUILD_RAILROAD_TRACK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
213 |
{CmdRemoveRailroadTrack, CMD_AUTO}, /* CMD_REMOVE_RAILROAD_TRACK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
214 |
{CmdBuildSingleRail, CMD_AUTO}, /* CMD_BUILD_SINGLE_RAIL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
215 |
{CmdRemoveSingleRail, CMD_AUTO}, /* CMD_REMOVE_SINGLE_RAIL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
216 |
{CmdLandscapeClear, 0}, /* CMD_LANDSCAPE_CLEAR */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
217 |
{CmdBuildBridge, CMD_AUTO}, /* CMD_BUILD_BRIDGE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
218 |
{CmdBuildRailroadStation, CMD_AUTO}, /* CMD_BUILD_RAILROAD_STATION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
219 |
{CmdBuildTrainDepot, CMD_AUTO}, /* CMD_BUILD_TRAIN_DEPOT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
220 |
{CmdBuildSingleSignal, CMD_AUTO}, /* CMD_BUILD_SIGNALS */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
221 |
{CmdRemoveSingleSignal, CMD_AUTO}, /* CMD_REMOVE_SIGNALS */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
222 |
{CmdTerraformLand, CMD_AUTO}, /* CMD_TERRAFORM_LAND */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
223 |
{CmdPurchaseLandArea, CMD_AUTO}, /* CMD_PURCHASE_LAND_AREA */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
224 |
{CmdSellLandArea, 0}, /* CMD_SELL_LAND_AREA */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
225 |
{CmdBuildTunnel, CMD_AUTO}, /* CMD_BUILD_TUNNEL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
226 |
{CmdRemoveFromRailroadStation, 0}, /* CMD_REMOVE_FROM_RAILROAD_STATION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
227 |
{CmdConvertRail, 0}, /* CMD_CONVERT_RAILD */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
228 |
{CmdBuildTrainWaypoint, 0}, /* CMD_BUILD_TRAIN_WAYPOINT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
229 |
{CmdRenameWaypoint, 0}, /* CMD_RENAME_WAYPOINT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
230 |
{CmdRemoveTrainWaypoint, 0}, /* CMD_REMOVE_TRAIN_WAYPOINT */ |
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
231 |
|
8996
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
232 |
{CmdBuildRoadStop, CMD_AUTO}, /* CMD_BUILD_ROAD_STOP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
233 |
{CmdRemoveRoadStop, 0}, /* CMD_REMOVE_ROAD_STOP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
234 |
{CmdBuildLongRoad, CMD_AUTO}, /* CMD_BUILD_LONG_ROAD */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
235 |
{CmdRemoveLongRoad, CMD_AUTO}, /* CMD_REMOVE_LONG_ROAD */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
236 |
{CmdBuildRoad, 0}, /* CMD_BUILD_ROAD */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
237 |
{CmdRemoveRoad, 0}, /* CMD_REMOVE_ROAD */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
238 |
{CmdBuildRoadDepot, CMD_AUTO}, /* CMD_BUILD_ROAD_DEPOT */ |
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
239 |
|
8996
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
240 |
{CmdBuildAirport, CMD_AUTO}, /* CMD_BUILD_AIRPORT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
241 |
{CmdBuildDock, CMD_AUTO}, /* CMD_BUILD_DOCK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
242 |
{CmdBuildShipDepot, CMD_AUTO}, /* CMD_BUILD_SHIP_DEPOT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
243 |
{CmdBuildBuoy, CMD_AUTO}, /* CMD_BUILD_BUOY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
244 |
{CmdPlantTree, CMD_AUTO}, /* CMD_PLANT_TREE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
245 |
{CmdBuildRailVehicle, 0}, /* CMD_BUILD_RAIL_VEHICLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
246 |
{CmdMoveRailVehicle, 0}, /* CMD_MOVE_RAIL_VEHICLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
247 |
{CmdStartStopTrain, 0}, /* CMD_START_STOP_TRAIN */ |
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
248 |
|
8996
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
249 |
{CmdSellRailWagon, 0}, /* CMD_SELL_RAIL_WAGON */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
250 |
{CmdSendTrainToDepot, 0}, /* CMD_SEND_TRAIN_TO_DEPOT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
251 |
{CmdForceTrainProceed, 0}, /* CMD_FORCE_TRAIN_PROCEED */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
252 |
{CmdReverseTrainDirection, 0}, /* CMD_REVERSE_TRAIN_DIRECTION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
253 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
254 |
{CmdModifyOrder, 0}, /* CMD_MODIFY_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
255 |
{CmdSkipToOrder, 0}, /* CMD_SKIP_TO_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
256 |
{CmdDeleteOrder, 0}, /* CMD_DELETE_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
257 |
{CmdInsertOrder, 0}, /* CMD_INSERT_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
258 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
259 |
{CmdChangeServiceInt, 0}, /* CMD_CHANGE_SERVICE_INT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
260 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
261 |
{CmdBuildIndustry, 0}, /* CMD_BUILD_INDUSTRY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
262 |
{CmdBuildCompanyHQ, CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
263 |
{CmdSetPlayerFace, 0}, /* CMD_SET_PLAYER_FACE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
264 |
{CmdSetPlayerColor, 0}, /* CMD_SET_PLAYER_COLOR */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
265 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
266 |
{CmdIncreaseLoan, 0}, /* CMD_INCREASE_LOAN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
267 |
{CmdDecreaseLoan, 0}, /* CMD_DECREASE_LOAN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
268 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
269 |
{CmdWantEnginePreview, 0}, /* CMD_WANT_ENGINE_PREVIEW */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
270 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
271 |
{CmdNameVehicle, 0}, /* CMD_NAME_VEHICLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
272 |
{CmdRenameEngine, 0}, /* CMD_RENAME_ENGINE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
273 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
274 |
{CmdChangeCompanyName, 0}, /* CMD_CHANGE_COMPANY_NAME */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
275 |
{CmdChangePresidentName, 0}, /* CMD_CHANGE_PRESIDENT_NAME */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
276 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
277 |
{CmdRenameStation, 0}, /* CMD_RENAME_STATION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
278 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
279 |
{CmdSellAircraft, 0}, /* CMD_SELL_AIRCRAFT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
280 |
{CmdStartStopAircraft, 0}, /* CMD_START_STOP_AIRCRAFT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
281 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
282 |
{CmdBuildAircraft, 0}, /* CMD_BUILD_AIRCRAFT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
283 |
{CmdSendAircraftToHangar, 0}, /* CMD_SEND_AIRCRAFT_TO_HANGAR */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
284 |
{CmdRefitAircraft, 0}, /* CMD_REFIT_AIRCRAFT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
285 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
286 |
{CmdPlaceSign, 0}, /* CMD_PLACE_SIGN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
287 |
{CmdRenameSign, 0}, /* CMD_RENAME_SIGN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
288 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
289 |
{CmdBuildRoadVeh, 0}, /* CMD_BUILD_ROAD_VEH */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
290 |
{CmdStartStopRoadVeh, 0}, /* CMD_START_STOP_ROADVEH */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
291 |
{CmdSellRoadVeh, 0}, /* CMD_SELL_ROAD_VEH */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
292 |
{CmdSendRoadVehToDepot, 0}, /* CMD_SEND_ROADVEH_TO_DEPOT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
293 |
{CmdTurnRoadVeh, 0}, /* CMD_TURN_ROADVEH */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
294 |
{CmdRefitRoadVeh, 0}, /* CMD_REFIT_ROAD_VEH */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
295 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
296 |
{CmdPause, CMD_SERVER}, /* CMD_PAUSE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
297 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
298 |
{CmdBuyShareInCompany, 0}, /* CMD_BUY_SHARE_IN_COMPANY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
299 |
{CmdSellShareInCompany, 0}, /* CMD_SELL_SHARE_IN_COMPANY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
300 |
{CmdBuyCompany, 0}, /* CMD_BUY_COMANY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
301 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
302 |
{CmdBuildTown, CMD_OFFLINE}, /* CMD_BUILD_TOWN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
303 |
{CmdRenameTown, CMD_SERVER}, /* CMD_RENAME_TOWN */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
304 |
{CmdDoTownAction, 0}, /* CMD_DO_TOWN_ACTION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
305 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
306 |
{CmdSetRoadDriveSide, CMD_SERVER}, /* CMD_SET_ROAD_DRIVE_SIDE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
307 |
{CmdChangeDifficultyLevel, CMD_SERVER}, /* CMD_CHANGE_DIFFICULTY_LEVEL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
308 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
309 |
{CmdStartStopShip, 0}, /* CMD_START_STOP_SHIP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
310 |
{CmdSellShip, 0}, /* CMD_SELL_SHIP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
311 |
{CmdBuildShip, 0}, /* CMD_BUILD_SHIP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
312 |
{CmdSendShipToDepot, 0}, /* CMD_SEND_SHIP_TO_DEPOT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
313 |
{CmdRefitShip, 0}, /* CMD_REFIT_SHIP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
314 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
315 |
{CmdOrderRefit, 0}, /* CMD_ORDER_REFIT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
316 |
{CmdCloneOrder, 0}, /* CMD_CLONE_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
317 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
318 |
{CmdClearArea, 0}, /* CMD_CLEAR_AREA */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
319 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
320 |
{CmdMoneyCheat, CMD_OFFLINE}, /* CMD_MONEY_CHEAT */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
321 |
{CmdBuildCanal, CMD_AUTO}, /* CMD_BUILD_CANAL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
322 |
{CmdPlayerCtrl, 0}, /* CMD_PLAYER_CTRL */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
323 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
324 |
{CmdLevelLand, CMD_AUTO}, /* CMD_LEVEL_LAND */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
325 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
326 |
{CmdRefitRailVehicle, 0}, /* CMD_REFIT_RAIL_VEHICLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
327 |
{CmdRestoreOrderIndex, 0}, /* CMD_RESTORE_ORDER_INDEX */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
328 |
{CmdBuildLock, CMD_AUTO}, /* CMD_BUILD_LOCK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
329 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
330 |
{CmdBuildSignalTrack, CMD_AUTO}, /* CMD_BUILD_SIGNAL_TRACK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
331 |
{CmdRemoveSignalTrack, CMD_AUTO}, /* CMD_REMOVE_SIGNAL_TRACK */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
332 |
|
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
333 |
{CmdGiveMoney, 0}, /* CMD_GIVE_MONEY */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
334 |
{CmdChangePatchSetting, CMD_SERVER}, /* CMD_CHANGE_PATCH_SETTING */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
335 |
{CmdSetAutoReplace, 0}, /* CMD_SET_AUTOREPLACE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
336 |
{CmdCloneVehicle, 0}, /* CMD_CLONE_VEHICLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
337 |
{CmdMassStartStopVehicle, 0}, /* CMD_MASS_START_STOP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
338 |
{CmdDepotSellAllVehicles, 0}, /* CMD_DEPOT_SELL_ALL_VEHICLES */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
339 |
{CmdDepotMassAutoReplace, 0}, /* CMD_DEPOT_MASS_AUTOREPLACE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
340 |
{CmdCreateGroup, 0}, /* CMD_CREATE_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
341 |
{CmdDeleteGroup, 0}, /* CMD_DELETE_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
342 |
{CmdRenameGroup, 0}, /* CMD_RENAME_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
343 |
{CmdAddVehicleGroup, 0}, /* CMD_ADD_VEHICLE_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
344 |
{CmdAddSharedVehicleGroup, 0}, /* CMD_ADD_SHARE_VEHICLE_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
345 |
{CmdRemoveAllVehiclesGroup, 0}, /* CMD_REMOVE_ALL_VEHICLES_GROUP */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
346 |
{CmdSetGroupReplaceProtection, 0}, /* CMD_SET_GROUP_REPLACE_PROTECTION */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
347 |
{CmdMoveOrder, 0}, /* CMD_MOVE_ORDER */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
348 |
{CmdChangeTimetable, 0}, /* CMD_CHANGE_TIMETABLE */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
349 |
{CmdSetVehicleOnTime, 0}, /* CMD_SET_VEHICLE_ON_TIME */ |
44758c09945e
(svn r12075) -Codechange: Remove explicit numbering on command enum, and remove blanks from command list where old commands have been removed.
peter1138
parents:
8982
diff
changeset
|
350 |
{CmdAutofillTimetable, 0}, /* CMD_AUTOFILL_TIMETABLE */ |
0 | 351 |
}; |
352 |
||
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
353 |
/*! |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
354 |
* This function range-checks a cmd, and checks if the cmd is not NULL |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
355 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
356 |
* @param cmd The integervalue of a command |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
357 |
* @return true if the command is valid (and got a CommandProc function) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
358 |
*/ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
359 |
bool IsValidCommand(uint cmd) |
903
f860c7234167
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
360 |
{ |
2645
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2425
diff
changeset
|
361 |
cmd &= 0xFF; |
903
f860c7234167
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
362 |
|
2645
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2425
diff
changeset
|
363 |
return |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2425
diff
changeset
|
364 |
cmd < lengthof(_command_proc_table) && |
964bd8fe3ce2
(svn r3187) Simplify overly complicated ifs, especially if (foo) return false; else return true; is confusing
tron
parents:
2425
diff
changeset
|
365 |
_command_proc_table[cmd].proc != NULL; |
903
f860c7234167
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
366 |
} |
f860c7234167
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
367 |
|
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
368 |
/*! |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
369 |
* This function mask the parameter with 0xFF and returns |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
370 |
* the flags which belongs to the given command. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
371 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
372 |
* @param cmd The integer value of the command |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
373 |
* @return The flags for this command |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
374 |
* @bug integervalues which are less equals 0xFF and greater than the |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
375 |
* size of _command_proc_table can result in an index out of bounce |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
376 |
* error (which doesn't happend anyway). Check function #IsValidCommand(). (Progman) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
377 |
*/ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
378 |
byte GetCommandFlags(uint cmd) |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
379 |
{ |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
380 |
return _command_proc_table[cmd & 0xFF].flags; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
381 |
} |
1804
7810fc0aa941
(svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents:
1802
diff
changeset
|
382 |
|
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
383 |
static int _docommand_recursive = 0; |
2304
f3309898aeb0
(svn r2828) Only command.c needs to know about _docommand_recursive, so make it static. Tell me if there's a problem, because i removed it from network_server.c, but afaict it should be ok
tron
parents:
2244
diff
changeset
|
384 |
|
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
385 |
/*! |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
386 |
* This function executes a given command with the parameters from the #CommandProc parameter list. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
387 |
* Depending on the flags parameter it execute or test a command. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
388 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
389 |
* @param tile The tile to apply the command on (for the #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
390 |
* @param p1 Additional data for the command (for the #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
391 |
* @param p2 Additional data for the command (for the #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
392 |
* @param flags Flags for the command and how to execute the command |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
393 |
* @param procc The command-id to execute (a value of the CMD_* enums) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
394 |
* @see CommandProc |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
395 |
*/ |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
396 |
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc) |
0 | 397 |
{ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7328
diff
changeset
|
398 |
CommandCost res; |
0 | 399 |
CommandProc *proc; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
400 |
|
1776
fa776997bba2
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents:
1728
diff
changeset
|
401 |
/* Do not even think about executing out-of-bounds tile-commands */ |
9148
778a53fe72f3
(svn r12304) -Codechange: use IsValidTile() where it should be used
glx
parents:
9015
diff
changeset
|
402 |
if (!IsValidTile(tile)) { |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
403 |
_cmd_text = NULL; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
404 |
return CMD_ERROR; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
405 |
} |
1776
fa776997bba2
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents:
1728
diff
changeset
|
406 |
|
1804
7810fc0aa941
(svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents:
1802
diff
changeset
|
407 |
proc = _command_proc_table[procc].proc; |
0 | 408 |
|
2749
46aba09ca365
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2715
diff
changeset
|
409 |
if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID; |
0 | 410 |
|
411 |
_docommand_recursive++; |
|
412 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
413 |
/* only execute the test call if it's toplevel, or we're not execing. */ |
8982
bef54a67b958
(svn r12061) -Cleanup: since r12060, DC_FORCETEST is not used anymore
smatz
parents:
8938
diff
changeset
|
414 |
if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) { |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
415 |
SetTownRatingTestMode(true); |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3421
diff
changeset
|
416 |
res = proc(tile, flags & ~DC_EXEC, p1, p2); |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
417 |
SetTownRatingTestMode(false); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1623
diff
changeset
|
418 |
if (CmdFailed(res)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
419 |
res.SetGlobalErrorMessage(); |
0 | 420 |
goto error; |
421 |
} |
|
422 |
||
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
423 |
if (_docommand_recursive == 1 && |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
424 |
!(flags & DC_QUERY_COST) && |
9015
4a44c6974ac1
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz
parents:
8996
diff
changeset
|
425 |
!(flags & DC_BANKRUPT) && |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
426 |
res.GetCost() != 0 && |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
427 |
!CheckPlayerHasMoney(res)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
428 |
goto error; |
0 | 429 |
} |
430 |
||
431 |
if (!(flags & DC_EXEC)) { |
|
432 |
_docommand_recursive--; |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
433 |
_cmd_text = NULL; |
0 | 434 |
return res; |
435 |
} |
|
436 |
} |
|
437 |
||
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
842
diff
changeset
|
438 |
/* Execute the command here. All cost-relevant functions set the expenses type |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8695
diff
changeset
|
439 |
* themselves to the cost object at some point */ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3421
diff
changeset
|
440 |
res = proc(tile, flags, p1, p2); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1623
diff
changeset
|
441 |
if (CmdFailed(res)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
442 |
res.SetGlobalErrorMessage(); |
0 | 443 |
error: |
444 |
_docommand_recursive--; |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
445 |
_cmd_text = NULL; |
0 | 446 |
return CMD_ERROR; |
447 |
} |
|
448 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
449 |
/* if toplevel, subtract the money. */ |
9015
4a44c6974ac1
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz
parents:
8996
diff
changeset
|
450 |
if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) { |
0 | 451 |
SubtractMoneyFromPlayer(res); |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
452 |
/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */ |
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4848
diff
changeset
|
453 |
if (tile != 0 && IsValidPlayer(_current_player)) { |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3421
diff
changeset
|
454 |
GetPlayer(_current_player)->last_build_coordinate = tile; |
2772
96e47991fd1d
(svn r3319) - Fix (regression): "Unnamed Competitors". A result of revision r3224 which allowed AI's for multiplayer. Old AI's didn't function correctly anymore. The update of last-built tile is moved back, but to a slightly different place so it is only executed when the command is actually successfully executed. This code shouldn't be neccessary, but alas, the old AI doesn't use DoCommandDP() functions.
Darkvater
parents:
2767
diff
changeset
|
455 |
} |
0 | 456 |
} |
457 |
||
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
458 |
_cmd_text = NULL; |
0 | 459 |
return res; |
460 |
} |
|
461 |
||
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
462 |
/*! |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
463 |
* This functions returns the money which can be used to execute a command. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
464 |
* This is either the money of the current player or INT64_MAX if there |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
465 |
* is no such a player "at the moment" like the server itself. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
466 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
467 |
* @return The available money of a player or INT64_MAX |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
468 |
*/ |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7476
diff
changeset
|
469 |
Money GetAvailableMoneyForCommand() |
0 | 470 |
{ |
1794
44f9deff97ed
(svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents:
1786
diff
changeset
|
471 |
PlayerID pid = _current_player; |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7476
diff
changeset
|
472 |
if (!IsValidPlayer(pid)) return INT64_MAX; |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1891
diff
changeset
|
473 |
return GetPlayer(pid)->player_money; |
0 | 474 |
} |
475 |
||
8055
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
476 |
/*! |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
477 |
* Toplevel network safe docommand function for the current player. Must not be called recursively. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
478 |
* The callback is called when the command succeeded or failed. The parameters |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
479 |
* tile, p1 and p2 are from the #CommandProc function. The paramater cmd is the command to execute. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
480 |
* The parameter my_cmd is used to indicate if the command is from a player or the server. |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
481 |
* |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
482 |
* @param tile The tile to perform a command on (see #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
483 |
* @param p1 Additional data for the command (see #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
484 |
* @param p2 Additional data for the command (see #CommandProc) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
485 |
* @param callback A callback function to call after the command is finished |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
486 |
* @param cmd The command to execute (a CMD_* value) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
487 |
* @param my_cmd indicator if the command is from a player or server (to display error messages for a user) |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
488 |
* @return true if the command succeeded, else false |
07697c701048
(svn r11084) -Documentation [FS#1219]: of command.*. Patch by Progman.
rubidium
parents:
8017
diff
changeset
|
489 |
*/ |
7718
220603f0122e
(svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents:
7562
diff
changeset
|
490 |
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd) |
0 | 491 |
{ |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
492 |
CommandCost res, res2; |
0 | 493 |
CommandProc *proc; |
494 |
uint32 flags; |
|
495 |
bool notest; |
|
3182
0f1161388ea1
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
2820
diff
changeset
|
496 |
StringID error_part1; |
0 | 497 |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3182
diff
changeset
|
498 |
int x = TileX(tile) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3182
diff
changeset
|
499 |
int y = TileY(tile) * TILE_SIZE; |
0 | 500 |
|
1776
fa776997bba2
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents:
1728
diff
changeset
|
501 |
/* Do not even think about executing out-of-bounds tile-commands */ |
9148
778a53fe72f3
(svn r12304) -Codechange: use IsValidTile() where it should be used
glx
parents:
9015
diff
changeset
|
502 |
if (!IsValidTile(tile)) { |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
503 |
_cmd_text = NULL; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
504 |
return false; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
505 |
} |
1776
fa776997bba2
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
Darkvater
parents:
1728
diff
changeset
|
506 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
507 |
assert(_docommand_recursive == 0); |
0 | 508 |
|
509 |
_error_message = INVALID_STRING_ID; |
|
3182
0f1161388ea1
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
2820
diff
changeset
|
510 |
error_part1 = GB(cmd, 16, 16); |
0 | 511 |
_additional_cash_required = 0; |
512 |
||
5067
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
513 |
/** Spectator has no rights except for the (dedicated) server which |
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
514 |
* is/can be a spectator but as the server it can do anything */ |
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
515 |
if (_current_player == PLAYER_SPECTATOR && !_network_server) { |
7718
220603f0122e
(svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents:
7562
diff
changeset
|
516 |
if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y); |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
517 |
_cmd_text = NULL; |
0 | 518 |
return false; |
519 |
} |
|
520 |
||
521 |
flags = 0; |
|
522 |
if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER; |
|
523 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
524 |
/* get pointer to command handler */ |
0 | 525 |
assert((cmd & 0xFF) < lengthof(_command_proc_table)); |
1804
7810fc0aa941
(svn r2308) - Fix: enforce server-only and/or offline commands by giving them flags in the process table. This also fixes bug "[ 1190944 ] Many commands not checked for security"
Darkvater
parents:
1802
diff
changeset
|
526 |
proc = _command_proc_table[cmd & 0xFF].proc; |
1877
e7318705dd04
(svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents:
1838
diff
changeset
|
527 |
if (proc == NULL) { |
e7318705dd04
(svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents:
1838
diff
changeset
|
528 |
_cmd_text = NULL; |
e7318705dd04
(svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents:
1838
diff
changeset
|
529 |
return false; |
e7318705dd04
(svn r2383) - Fix: Monkey-testing turned up some command crashes.
Darkvater
parents:
1838
diff
changeset
|
530 |
} |
0 | 531 |
|
8017
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
8002
diff
changeset
|
532 |
if (GetCommandFlags(cmd) & CMD_AUTO) flags |= DC_AUTO; |
8c46e61c510f
(svn r11040) -Fix [FS#1179]: removing CMD_AUTO from some commands could remotely trigger an assertion.
rubidium
parents:
8002
diff
changeset
|
533 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
534 |
/* Some commands have a different output in dryrun than the realrun |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
535 |
* e.g.: if you demolish a whole town, the dryrun would say okay. |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
536 |
* but by really destroying, your rating drops and at a certain point |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
537 |
* it will fail. so res and res2 are different |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
538 |
* CMD_REMOVE_LONG_ROAD: This command has special local authority |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
539 |
* restrictions which may cause the test run to fail (the previous |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
540 |
* road fragments still stay there and the town won't let you |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
541 |
* disconnect the road system), but the exec will succeed and this |
7042
d841fb0d8e9a
(svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents:
6987
diff
changeset
|
542 |
* fact will trigger an assertion failure. --pasky |
d841fb0d8e9a
(svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents:
6987
diff
changeset
|
543 |
* CMD_CLONE_VEHICLE: Both building new vehicles and refitting them can be |
d841fb0d8e9a
(svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents:
6987
diff
changeset
|
544 |
* influenced by newgrf callbacks, which makes it impossible to accurately |
9232
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
545 |
* estimate the cost of cloning a vehicle. |
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
546 |
* CMD_DEPOT_MASS_AUTOREPLACE: we can't predict wagon removal so |
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
547 |
* the test will not include income from any sold wagons. |
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
548 |
* This means that the costs can sometimes be lower than estimated. */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
549 |
notest = |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
550 |
(cmd & 0xFF) == CMD_CLEAR_AREA || |
0 | 551 |
(cmd & 0xFF) == CMD_LEVEL_LAND || |
7042
d841fb0d8e9a
(svn r9742) -Fix (r9689) [FS#739]: Fix cloning with refit costs again, hopefully for good this time.
maedhros
parents:
6987
diff
changeset
|
552 |
(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD || |
9232
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
553 |
(cmd & 0xFF) == CMD_CLONE_VEHICLE || |
37291ba2aa2a
(svn r12421) -Feature: [autoreplace] the autoreplace button in train depots will now also replace wagons even if they aren't connected to a locomotive
bjarni
parents:
9148
diff
changeset
|
554 |
(cmd & 0xFF) == CMD_DEPOT_MASS_AUTOREPLACE; |
8683 | 555 |
|
0 | 556 |
_docommand_recursive = 1; |
557 |
||
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
558 |
/* cost estimation only? */ |
5831
de5f05e20ae9
(svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents:
5726
diff
changeset
|
559 |
if (!IsGeneratingWorld() && |
de5f05e20ae9
(svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents:
5726
diff
changeset
|
560 |
_shift_pressed && |
de5f05e20ae9
(svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents:
5726
diff
changeset
|
561 |
IsLocalPlayer() && |
de5f05e20ae9
(svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents:
5726
diff
changeset
|
562 |
!(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) && |
de5f05e20ae9
(svn r8027) -Fix (FS#486) If a pause command is issues, it will now pause the game even if shift is pressed instead of giving a cost estimate of 0. This fixes a problem where the server does not pause_on_join when the player on the interactive server has the shift button pressed. (Thanks to pvz for the report and the fix)
celestar
parents:
5726
diff
changeset
|
563 |
(cmd & 0xFF) != CMD_PAUSE) { |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
564 |
/* estimate the cost. */ |
8938
79bcde6bbe6c
(svn r12012) -Fix (r11795): Enable TownRatingTestMode during cost estimation with 'shift'-key.
frosch
parents:
8802
diff
changeset
|
565 |
SetTownRatingTestMode(true); |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3421
diff
changeset
|
566 |
res = proc(tile, flags, p1, p2); |
8938
79bcde6bbe6c
(svn r12012) -Fix (r11795): Enable TownRatingTestMode during cost estimation with 'shift'-key.
frosch
parents:
8802
diff
changeset
|
567 |
SetTownRatingTestMode(false); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1623
diff
changeset
|
568 |
if (CmdFailed(res)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
569 |
res.SetGlobalErrorMessage(); |
3182
0f1161388ea1
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
2820
diff
changeset
|
570 |
ShowErrorMessage(_error_message, error_part1, x, y); |
0 | 571 |
} else { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
572 |
ShowEstimatedCostOrIncome(res.GetCost(), x, y); |
0 | 573 |
} |
574 |
||
575 |
_docommand_recursive = 0; |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
576 |
_cmd_text = NULL; |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8055
diff
changeset
|
577 |
ClearStorageChanges(false); |
0 | 578 |
return false; |
579 |
} |
|
580 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
581 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
582 |
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { |
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
583 |
/* first test if the command can be executed. */ |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
584 |
SetTownRatingTestMode(true); |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3421
diff
changeset
|
585 |
res = proc(tile, flags, p1, p2); |
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
586 |
SetTownRatingTestMode(false); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1623
diff
changeset
|
587 |
if (CmdFailed(res)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
588 |
res.SetGlobalErrorMessage(); |
0 | 589 |
goto show_error; |
590 |
} |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
591 |
/* no money? Only check if notest is off */ |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
592 |
if (!notest && res.GetCost() != 0 && !CheckPlayerHasMoney(res)) goto show_error; |
0 | 593 |
} |
594 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
595 |
#ifdef ENABLE_NETWORK |
1838
522076c550c0
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents:
1834
diff
changeset
|
596 |
/** If we are in network, and the command is not from the network |
522076c550c0
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents:
1834
diff
changeset
|
597 |
* send it to the command-queue and abort execution |
522076c550c0
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents:
1834
diff
changeset
|
598 |
* If we are a dedicated server temporarily switch local player, otherwise |
522076c550c0
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents:
1834
diff
changeset
|
599 |
* the other parties won't be able to execute our command and will desync. |
5067
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
600 |
* We also need to do this if the server's company has gone bankrupt |
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
601 |
* @todo Rewrite (dedicated) server to something more than a dirty hack! |
1838
522076c550c0
(svn r2343) - Fix (regression): dedicated server caused desyncs with its commands, because the player sent over the network is OWNER_SPECTATOR as well, which on clients cannot execute anything. So *hack*hack* it into temporarily player 0.
Darkvater
parents:
1834
diff
changeset
|
602 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
603 |
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) { |
5067
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
604 |
PlayerID pbck = _local_player; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
605 |
if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = PLAYER_FIRST; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
606 |
NetworkSend_Command(tile, p1, p2, cmd, callback); |
5067
870dfdcef898
(svn r7125) -Fix: Several errors/glitches related to multiplayer and bankrupcy, mainly such a
Darkvater
parents:
4850
diff
changeset
|
607 |
if (_network_dedicated || (_network_server && pbck == PLAYER_SPECTATOR)) _local_player = pbck; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
608 |
_docommand_recursive = 0; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
609 |
_cmd_text = NULL; |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8055
diff
changeset
|
610 |
ClearStorageChanges(false); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
611 |
return true; |
0 | 612 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
613 |
#endif /* ENABLE_NETWORK */ |
8743
62a558995c35
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium
parents:
8728
diff
changeset
|
614 |
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text); |
0 | 615 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
616 |
/* update last build coordinate of player. */ |
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4848
diff
changeset
|
617 |
if (tile != 0 && IsValidPlayer(_current_player)) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
618 |
GetPlayer(_current_player)->last_build_coordinate = tile; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
619 |
} |
0 | 620 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
842
diff
changeset
|
621 |
/* Actually try and execute the command. If no cost-type is given |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
842
diff
changeset
|
622 |
* use the construction one */ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3991
diff
changeset
|
623 |
res2 = proc(tile, flags | DC_EXEC, p1, p2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
624 |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
625 |
/* If notest is on, it means the result of the test can be different than |
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
626 |
* the real command.. so ignore the test */ |
652
0f553238c98a
(svn r1085) -Fix: [Network] [ 1084834 ] If IF_IN_NETWORK flag was on, an error
truelight
parents:
601
diff
changeset
|
627 |
if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
628 |
assert(res.GetCost() == res2.GetCost() && CmdFailed(res) == CmdFailed(res2)); // sanity check |
0 | 629 |
} else { |
1702
6402cfbb9772
(svn r2206) - Regression Fix: slight typo of res2 into res, this also fixes recent bug "[ 1183396 ] Train can't find depot, it gives money in Multiplayer"
Darkvater
parents:
1701
diff
changeset
|
630 |
if (CmdFailed(res2)) { |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
631 |
res.SetGlobalErrorMessage(); |
0 | 632 |
goto show_error; |
633 |
} |
|
634 |
} |
|
635 |
||
636 |
SubtractMoneyFromPlayer(res2); |
|
637 |
||
8802
e08824cdab46
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents:
8771
diff
changeset
|
638 |
/* update signals if needed */ |
e08824cdab46
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents:
8771
diff
changeset
|
639 |
UpdateSignalsInBuffer(); |
e08824cdab46
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents:
8771
diff
changeset
|
640 |
|
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2304
diff
changeset
|
641 |
if (IsLocalPlayer() && _game_mode != GM_EDITOR) { |
8002
589569211928
(svn r11021) -Fix [FS#1175]: do not display income/expenses when they do not belong to a "valid" tile, like the money cheat/giving money.
rubidium
parents:
7762
diff
changeset
|
642 |
if (res2.GetCost() != 0 && tile != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost()); |
7486
d130c10f4dab
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
7476
diff
changeset
|
643 |
if (_additional_cash_required != 0) { |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7487
diff
changeset
|
644 |
SetDParam(0, _additional_cash_required); |
7718
220603f0122e
(svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents:
7562
diff
changeset
|
645 |
if (my_cmd) ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y); |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
646 |
if (res2.GetCost() == 0) goto callb_err; |
0 | 647 |
} |
648 |
} |
|
649 |
||
650 |
_docommand_recursive = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
651 |
|
0 | 652 |
if (callback) callback(true, tile, p1, p2); |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
653 |
_cmd_text = NULL; |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8055
diff
changeset
|
654 |
ClearStorageChanges(true); |
0 | 655 |
return true; |
656 |
||
657 |
show_error: |
|
6449
e520244dc71e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
6338
diff
changeset
|
658 |
/* show error message if the command fails? */ |
7718
220603f0122e
(svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command.
rubidium
parents:
7562
diff
changeset
|
659 |
if (IsLocalPlayer() && error_part1 != 0 && my_cmd) { |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6949
diff
changeset
|
660 |
ShowErrorMessage(_error_message, error_part1, x, y); |
3182
0f1161388ea1
(svn r3827) Remove the global variable _error_message_2, it's only used as local variable
tron
parents:
2820
diff
changeset
|
661 |
} |
0 | 662 |
|
663 |
callb_err: |
|
664 |
_docommand_recursive = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
665 |
|
0 | 666 |
if (callback) callback(false, tile, p1, p2); |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1804
diff
changeset
|
667 |
_cmd_text = NULL; |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8055
diff
changeset
|
668 |
ClearStorageChanges(false); |
0 | 669 |
return false; |
670 |
} |
|
10080
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
671 |
|
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
672 |
|
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
673 |
CommandCost CommandCost::AddCost(CommandCost ret) |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
674 |
{ |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
675 |
this->AddCost(ret.cost); |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
676 |
if (this->success && !ret.success) { |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
677 |
this->message = ret.message; |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
678 |
this->success = false; |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
679 |
} |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
680 |
return *this; |
e0a9b92ed875
(svn r12616) -Codechange: r12591 didn't work as expected for NDS, move one function back to cpp
smatz
parents:
9337
diff
changeset
|
681 |
} |