author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1287 | adb8820d4600 |
child 1621 | 890ab08b9855 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
467
diff
changeset
|
3 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
652
diff
changeset
|
4 |
#include "map.h" |
0 | 5 |
#include "gui.h" |
6 |
#include "command.h" |
|
7 |
#include "player.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
8 |
#include "network.h" |
0 | 9 |
|
10 |
#define DEF_COMMAND(yyyy) int32 yyyy(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
11 |
||
12 |
DEF_COMMAND(CmdBuildRailroadTrack); |
|
13 |
DEF_COMMAND(CmdRemoveRailroadTrack); |
|
14 |
DEF_COMMAND(CmdBuildSingleRail); |
|
15 |
DEF_COMMAND(CmdRemoveSingleRail); |
|
16 |
||
17 |
DEF_COMMAND(CmdLandscapeClear); |
|
18 |
||
19 |
DEF_COMMAND(CmdBuildBridge); |
|
20 |
||
21 |
DEF_COMMAND(CmdBuildRailroadStation); |
|
22 |
DEF_COMMAND(CmdRemoveFromRailroadStation); |
|
23 |
DEF_COMMAND(CmdConvertRail); |
|
24 |
||
1227
1d940a5e02d2
(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
|
25 |
DEF_COMMAND(CmdBuildSingleSignal); |
1d940a5e02d2
(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
|
26 |
DEF_COMMAND(CmdRemoveSingleSignal); |
0 | 27 |
|
28 |
DEF_COMMAND(CmdTerraformLand); |
|
29 |
||
30 |
DEF_COMMAND(CmdPurchaseLandArea); |
|
31 |
DEF_COMMAND(CmdSellLandArea); |
|
32 |
||
33 |
DEF_COMMAND(CmdBuildTunnel); |
|
34 |
||
35 |
DEF_COMMAND(CmdBuildTrainDepot); |
|
395
788a9bba0889
(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
|
36 |
DEF_COMMAND(CmdBuildTrainWaypoint); |
788a9bba0889
(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
|
37 |
DEF_COMMAND(CmdRenameWaypoint); |
788a9bba0889
(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
|
38 |
DEF_COMMAND(CmdRemoveTrainWaypoint); |
0 | 39 |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
40 |
DEF_COMMAND(CmdBuildRoadStop); |
0 | 41 |
|
42 |
DEF_COMMAND(CmdBuildLongRoad); |
|
43 |
DEF_COMMAND(CmdRemoveLongRoad); |
|
44 |
DEF_COMMAND(CmdBuildRoad); |
|
45 |
DEF_COMMAND(CmdRemoveRoad); |
|
46 |
||
47 |
DEF_COMMAND(CmdBuildRoadDepot); |
|
48 |
||
49 |
DEF_COMMAND(CmdBuildAirport); |
|
50 |
||
51 |
DEF_COMMAND(CmdBuildDock); |
|
52 |
||
53 |
DEF_COMMAND(CmdBuildShipDepot); |
|
54 |
||
55 |
DEF_COMMAND(CmdBuildBuoy); |
|
56 |
||
57 |
DEF_COMMAND(CmdPlantTree); |
|
58 |
||
59 |
DEF_COMMAND(CmdBuildRailVehicle); |
|
60 |
DEF_COMMAND(CmdMoveRailVehicle); |
|
61 |
||
62 |
DEF_COMMAND(CmdStartStopTrain); |
|
63 |
||
64 |
DEF_COMMAND(CmdSellRailWagon); |
|
65 |
||
66 |
DEF_COMMAND(CmdTrainGotoDepot); |
|
67 |
DEF_COMMAND(CmdForceTrainProceed); |
|
68 |
DEF_COMMAND(CmdReverseTrainDirection); |
|
69 |
||
70 |
DEF_COMMAND(CmdModifyOrder); |
|
71 |
DEF_COMMAND(CmdSkipOrder); |
|
72 |
DEF_COMMAND(CmdDeleteOrder); |
|
73 |
DEF_COMMAND(CmdInsertOrder); |
|
74 |
DEF_COMMAND(CmdChangeTrainServiceInt); |
|
75 |
DEF_COMMAND(CmdRestoreOrderIndex); |
|
76 |
||
77 |
DEF_COMMAND(CmdBuildIndustry); |
|
78 |
||
79 |
DEF_COMMAND(CmdBuildCompanyHQ); |
|
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
|
80 |
DEF_COMMAND(CmdDestroyCompanyHQ); |
0 | 81 |
DEF_COMMAND(CmdSetPlayerFace); |
82 |
DEF_COMMAND(CmdSetPlayerColor); |
|
83 |
||
84 |
DEF_COMMAND(CmdIncreaseLoan); |
|
85 |
DEF_COMMAND(CmdDecreaseLoan); |
|
86 |
||
87 |
DEF_COMMAND(CmdWantEnginePreview); |
|
88 |
||
89 |
DEF_COMMAND(CmdNameVehicle); |
|
90 |
DEF_COMMAND(CmdRenameEngine); |
|
91 |
||
92 |
DEF_COMMAND(CmdChangeCompanyName); |
|
93 |
DEF_COMMAND(CmdChangePresidentName); |
|
94 |
||
95 |
DEF_COMMAND(CmdRenameStation); |
|
96 |
||
97 |
DEF_COMMAND(CmdSellAircraft); |
|
98 |
DEF_COMMAND(CmdStartStopAircraft); |
|
99 |
DEF_COMMAND(CmdBuildAircraft); |
|
100 |
DEF_COMMAND(CmdSendAircraftToHangar); |
|
101 |
DEF_COMMAND(CmdChangeAircraftServiceInt); |
|
102 |
DEF_COMMAND(CmdRefitAircraft); |
|
103 |
||
104 |
DEF_COMMAND(CmdPlaceSign); |
|
105 |
DEF_COMMAND(CmdRenameSign); |
|
106 |
||
107 |
DEF_COMMAND(CmdBuildRoadVeh); |
|
108 |
DEF_COMMAND(CmdStartStopRoadVeh); |
|
109 |
DEF_COMMAND(CmdSellRoadVeh); |
|
110 |
DEF_COMMAND(CmdSendRoadVehToDepot); |
|
111 |
DEF_COMMAND(CmdTurnRoadVeh); |
|
112 |
DEF_COMMAND(CmdChangeRoadVehServiceInt); |
|
113 |
||
114 |
DEF_COMMAND(CmdPause); |
|
115 |
DEF_COMMAND(CmdResume); |
|
116 |
||
117 |
DEF_COMMAND(CmdBuyShareInCompany); |
|
118 |
DEF_COMMAND(CmdSellShareInCompany); |
|
119 |
DEF_COMMAND(CmdBuyCompany); |
|
120 |
||
121 |
DEF_COMMAND(CmdBuildTown); |
|
122 |
||
123 |
DEF_COMMAND(CmdRenameTown); |
|
124 |
DEF_COMMAND(CmdDoTownAction); |
|
125 |
||
126 |
DEF_COMMAND(CmdSetRoadDriveSide); |
|
127 |
DEF_COMMAND(CmdSetTownNameType); |
|
128 |
||
129 |
DEF_COMMAND(CmdChangeDifficultyLevel); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
130 |
DEF_COMMAND(CmdChangePatchSetting); |
0 | 131 |
|
132 |
DEF_COMMAND(CmdStartStopShip); |
|
133 |
DEF_COMMAND(CmdSellShip); |
|
134 |
DEF_COMMAND(CmdBuildShip); |
|
135 |
DEF_COMMAND(CmdSendShipToDepot); |
|
136 |
DEF_COMMAND(CmdChangeShipServiceInt); |
|
137 |
DEF_COMMAND(CmdRefitShip); |
|
138 |
||
139 |
||
140 |
DEF_COMMAND(CmdStartNewGame); |
|
141 |
DEF_COMMAND(CmdLoadGame); |
|
142 |
DEF_COMMAND(CmdCreateScenario); |
|
143 |
DEF_COMMAND(CmdSetSinglePlayer); |
|
144 |
||
145 |
DEF_COMMAND(CmdSetNewLandscapeType); |
|
146 |
||
147 |
DEF_COMMAND(CmdGenRandomNewGame); |
|
148 |
DEF_COMMAND(CmdCloneOrder); |
|
149 |
||
150 |
DEF_COMMAND(CmdClearArea); |
|
151 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
152 |
DEF_COMMAND(CmdGiveMoney); |
0 | 153 |
DEF_COMMAND(CmdMoneyCheat); |
154 |
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
|
155 |
DEF_COMMAND(CmdBuildLock); |
0 | 156 |
|
157 |
DEF_COMMAND(CmdPlayerCtrl); |
|
158 |
||
159 |
DEF_COMMAND(CmdLevelLand); |
|
160 |
||
161 |
DEF_COMMAND(CmdRefitRailVehicle); |
|
162 |
||
163 |
DEF_COMMAND(CmdStartScenario); |
|
164 |
||
1227
1d940a5e02d2
(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
|
165 |
DEF_COMMAND(CmdBuildSignalTrack); |
1d940a5e02d2
(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
|
166 |
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
|
167 |
|
842 | 168 |
DEF_COMMAND(CmdReplaceVehicle); |
812
65ecc321b3db
(svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents:
679
diff
changeset
|
169 |
|
0 | 170 |
/* The master command table */ |
171 |
static CommandProc * const _command_proc_table[] = { |
|
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 |
CmdBuildRailroadTrack, /* 0 */ |
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
|
173 |
CmdRemoveRailroadTrack, /* 1 */ |
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
|
174 |
CmdBuildSingleRail, /* 2 */ |
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
|
175 |
CmdRemoveSingleRail, /* 3 */ |
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
|
176 |
CmdLandscapeClear, /* 4 */ |
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
|
177 |
CmdBuildBridge, /* 5 */ |
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
|
178 |
CmdBuildRailroadStation, /* 6 */ |
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
|
179 |
CmdBuildTrainDepot, /* 7 */ |
1227
1d940a5e02d2
(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 |
CmdBuildSingleSignal, /* 8 */ |
1d940a5e02d2
(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 |
CmdRemoveSingleSignal, /* 9 */ |
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
|
182 |
CmdTerraformLand, /* 10 */ |
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
|
183 |
CmdPurchaseLandArea, /* 11 */ |
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
|
184 |
CmdSellLandArea, /* 12 */ |
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
|
185 |
CmdBuildTunnel, /* 13 */ |
0 | 186 |
CmdRemoveFromRailroadStation, /* 14 */ |
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
|
187 |
CmdConvertRail, /* 15 */ |
395
788a9bba0889
(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
|
188 |
CmdBuildTrainWaypoint, /* 16 */ |
788a9bba0889
(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
|
189 |
CmdRenameWaypoint, /* 17 */ |
788a9bba0889
(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
|
190 |
CmdRemoveTrainWaypoint, /* 18 */ |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
191 |
NULL, /* 19 */ |
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
|
192 |
NULL, /* 20 */ |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
193 |
CmdBuildRoadStop, /* 21 */ |
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
|
194 |
NULL, /* 22 */ |
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
|
195 |
CmdBuildLongRoad, /* 23 */ |
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
|
196 |
CmdRemoveLongRoad, /* 24 */ |
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
|
197 |
CmdBuildRoad, /* 25 */ |
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
|
198 |
CmdRemoveRoad, /* 26 */ |
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
|
199 |
CmdBuildRoadDepot, /* 27 */ |
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
|
200 |
NULL, /* 28 */ |
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
|
201 |
CmdBuildAirport, /* 29 */ |
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
|
202 |
CmdBuildDock, /* 30 */ |
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
|
203 |
CmdBuildShipDepot, /* 31 */ |
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
|
204 |
CmdBuildBuoy, /* 32 */ |
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
|
205 |
CmdPlantTree, /* 33 */ |
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
|
206 |
CmdBuildRailVehicle, /* 34 */ |
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
|
207 |
CmdMoveRailVehicle, /* 35 */ |
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
|
208 |
CmdStartStopTrain, /* 36 */ |
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
|
209 |
NULL, /* 37 */ |
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
|
210 |
CmdSellRailWagon, /* 38 */ |
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
|
211 |
CmdTrainGotoDepot, /* 39 */ |
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
|
212 |
CmdForceTrainProceed, /* 40 */ |
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
|
213 |
CmdReverseTrainDirection, /* 41 */ |
0 | 214 |
|
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
|
215 |
CmdModifyOrder, /* 42 */ |
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
|
216 |
CmdSkipOrder, /* 43 */ |
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
|
217 |
CmdDeleteOrder, /* 44 */ |
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
|
218 |
CmdInsertOrder, /* 45 */ |
0 | 219 |
|
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
|
220 |
CmdChangeTrainServiceInt, /* 46 */ |
0 | 221 |
|
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
|
222 |
CmdBuildIndustry, /* 47 */ |
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
|
223 |
CmdBuildCompanyHQ, /* 48 */ |
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
|
224 |
CmdSetPlayerFace, /* 49 */ |
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
|
225 |
CmdSetPlayerColor, /* 50 */ |
0 | 226 |
|
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
|
227 |
CmdIncreaseLoan, /* 51 */ |
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
|
228 |
CmdDecreaseLoan, /* 52 */ |
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
|
229 |
|
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
|
230 |
CmdWantEnginePreview, /* 53 */ |
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
|
231 |
|
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
|
232 |
CmdNameVehicle, /* 54 */ |
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
|
233 |
CmdRenameEngine, /* 55 */ |
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
|
234 |
|
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
|
235 |
CmdChangeCompanyName, /* 56 */ |
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
|
236 |
CmdChangePresidentName, /* 57 */ |
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
|
237 |
|
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
|
238 |
CmdRenameStation, /* 58 */ |
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
|
239 |
|
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
|
240 |
CmdSellAircraft, /* 59 */ |
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
|
241 |
CmdStartStopAircraft, /* 60 */ |
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
|
242 |
CmdBuildAircraft, /* 61 */ |
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
|
243 |
CmdSendAircraftToHangar, /* 62 */ |
0 | 244 |
CmdChangeAircraftServiceInt, /* 63 */ |
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
|
245 |
CmdRefitAircraft, /* 64 */ |
0 | 246 |
|
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
|
247 |
CmdPlaceSign, /* 65 */ |
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
|
248 |
CmdRenameSign, /* 66 */ |
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
|
249 |
|
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
|
250 |
CmdBuildRoadVeh, /* 67 */ |
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
|
251 |
CmdStartStopRoadVeh, /* 68 */ |
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
|
252 |
CmdSellRoadVeh, /* 69 */ |
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
|
253 |
CmdSendRoadVehToDepot, /* 70 */ |
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
|
254 |
CmdTurnRoadVeh, /* 71 */ |
0 | 255 |
CmdChangeRoadVehServiceInt, /* 72 */ |
256 |
||
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
|
257 |
CmdPause, /* 73 */ |
0 | 258 |
|
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
|
259 |
CmdBuyShareInCompany, /* 74 */ |
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
|
260 |
CmdSellShareInCompany, /* 75 */ |
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
|
261 |
CmdBuyCompany, /* 76 */ |
0 | 262 |
|
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
|
263 |
CmdBuildTown, /* 77 */ |
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
|
264 |
NULL, /* 78 */ |
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
|
265 |
NULL, /* 79 */ |
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
|
266 |
CmdRenameTown, /* 80 */ |
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
|
267 |
CmdDoTownAction, /* 81 */ |
0 | 268 |
|
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
|
269 |
CmdSetRoadDriveSide, /* 82 */ |
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
|
270 |
CmdSetTownNameType, /* 83 */ |
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
|
271 |
NULL, /* 84 */ |
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
|
272 |
CmdChangeDifficultyLevel, /* 85 */ |
0 | 273 |
|
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
|
274 |
CmdStartStopShip, /* 86 */ |
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
|
275 |
CmdSellShip, /* 87 */ |
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
|
276 |
CmdBuildShip, /* 88 */ |
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
|
277 |
CmdSendShipToDepot, /* 89 */ |
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
|
278 |
CmdChangeShipServiceInt, /* 90 */ |
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
|
279 |
CmdRefitShip, /* 91 */ |
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
|
280 |
|
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
|
281 |
CmdStartNewGame, /* 92 */ |
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
|
282 |
CmdLoadGame, /* 93 */ |
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
|
283 |
CmdCreateScenario, /* 94 */ |
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
|
284 |
CmdSetSinglePlayer, /* 95 */ |
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
|
285 |
NULL, /* 96 */ |
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
|
286 |
CmdSetNewLandscapeType, /* 97 */ |
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
|
287 |
|
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
|
288 |
CmdGenRandomNewGame, /* 98 */ |
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
|
289 |
|
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
|
290 |
CmdCloneOrder, /* 99 */ |
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
|
291 |
|
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
|
292 |
CmdClearArea, /* 100 */ |
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
|
293 |
CmdResume, /* 101 */ |
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
|
294 |
|
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
|
295 |
CmdMoneyCheat, /* 102 */ |
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
|
296 |
CmdBuildCanal, /* 103 */ |
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
|
297 |
CmdPlayerCtrl, /* 104 */ |
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
|
298 |
|
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
|
299 |
CmdLevelLand, /* 105 */ |
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
|
300 |
|
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
|
301 |
CmdRefitRailVehicle, /* 106 */ |
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
|
302 |
CmdRestoreOrderIndex, /* 107 */ |
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
|
303 |
CmdBuildLock, /* 108 */ |
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
|
304 |
CmdStartScenario, /* 109 */ |
1227
1d940a5e02d2
(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
|
305 |
CmdBuildSignalTrack, /* 110 */ |
1d940a5e02d2
(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
|
306 |
CmdRemoveSignalTrack, /* 111 */ |
1d940a5e02d2
(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
|
307 |
CmdDestroyCompanyHQ, /* 112 */ |
1d940a5e02d2
(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
|
308 |
CmdGiveMoney, /* 113 */ |
1d940a5e02d2
(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
|
309 |
CmdChangePatchSetting, /* 114 */ |
1d940a5e02d2
(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
|
310 |
CmdReplaceVehicle, /* 115 */ |
0 | 311 |
}; |
312 |
||
903
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
313 |
/* This function range-checks a cmd, and checks if the cmd is not NULL */ |
959
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
314 |
bool IsValidCommand(uint cmd) |
903
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
315 |
{ |
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
316 |
cmd = cmd & 0xFF; |
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
317 |
|
959
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
318 |
if (cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd] == NULL) |
903
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
319 |
return false; |
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
320 |
|
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
321 |
return true; |
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
322 |
} |
a301a264e0fc
(svn r1389) -Add: [Network] Added packet protection. No longer a client or server
truelight
parents:
889
diff
changeset
|
323 |
|
0 | 324 |
int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc) |
325 |
{ |
|
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
903
diff
changeset
|
326 |
return DoCommand(TileX(tile) * 16, TileY(tile) * 16, p1, p2, flags, procc); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
327 |
} |
0 | 328 |
|
329 |
||
330 |
//extern void _stdcall Sleep(int s); |
|
331 |
||
332 |
int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc) |
|
333 |
{ |
|
334 |
int32 res; |
|
335 |
CommandProc *proc; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
336 |
|
0 | 337 |
proc = _command_proc_table[procc]; |
338 |
||
339 |
if (_docommand_recursive == 0) { |
|
340 |
_error_message = INVALID_STRING_ID; |
|
341 |
// update last build coord of player |
|
342 |
if ( (x|y) != 0 && _current_player < MAX_PLAYERS) { |
|
343 |
DEREF_PLAYER(_current_player)->last_build_coordinate = TILE_FROM_XY(x,y); |
|
344 |
} |
|
345 |
} |
|
346 |
||
347 |
_docommand_recursive++; |
|
348 |
||
349 |
// only execute the test call if it's toplevel, or we're not execing. |
|
350 |
if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) { |
|
351 |
res = proc(x, y, flags&~DC_EXEC, p1, p2); |
|
352 |
if ((uint32)res >> 16 == 0x8000) { |
|
353 |
if (res & 0xFFFF) _error_message = res & 0xFFFF; |
|
354 |
goto error; |
|
355 |
} |
|
356 |
||
357 |
if (_docommand_recursive == 1) { |
|
358 |
if (!(flags&DC_QUERY_COST) && res != 0 && !CheckPlayerHasMoney(res)) |
|
359 |
goto error; |
|
360 |
} |
|
361 |
||
362 |
if (!(flags & DC_EXEC)) { |
|
363 |
_docommand_recursive--; |
|
364 |
return res; |
|
365 |
} |
|
366 |
} |
|
367 |
||
889
64d2f7d5f02b
(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
|
368 |
/* Execute the command here. All cost-relevant functions set the expenses type |
64d2f7d5f02b
(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
|
369 |
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */ |
0 | 370 |
res = proc(x, y, flags, p1, p2); |
371 |
if ((uint32)res >> 16 == 0x8000) { |
|
372 |
if (res & 0xFFFF) _error_message = res & 0xFFFF; |
|
373 |
error: |
|
374 |
_docommand_recursive--; |
|
375 |
return CMD_ERROR; |
|
376 |
} |
|
377 |
||
378 |
// if toplevel, subtract the money. |
|
379 |
if (--_docommand_recursive == 0) { |
|
380 |
SubtractMoneyFromPlayer(res); |
|
381 |
} |
|
382 |
||
383 |
return res; |
|
384 |
} |
|
385 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
959
diff
changeset
|
386 |
int32 GetAvailableMoneyForCommand(void) |
0 | 387 |
{ |
388 |
uint pid = _current_player; |
|
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
|
389 |
if (pid >= MAX_PLAYERS) return 0x7FFFFFFF; // max int |
0 | 390 |
return DEREF_PLAYER(pid)->player_money; |
391 |
} |
|
392 |
||
393 |
// toplevel network safe docommand function for the current player. must not be called recursively. |
|
394 |
// the callback is called when the command succeeded or failed. |
|
395 |
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd) |
|
396 |
{ |
|
397 |
int32 res = 0,res2; |
|
398 |
CommandProc *proc; |
|
399 |
uint32 flags; |
|
400 |
bool notest; |
|
401 |
||
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
903
diff
changeset
|
402 |
int x = TileX(tile) * 16; |
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
903
diff
changeset
|
403 |
int y = TileY(tile) * 16; |
0 | 404 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
405 |
assert(_docommand_recursive == 0); |
0 | 406 |
|
407 |
_error_message = INVALID_STRING_ID; |
|
408 |
_error_message_2 = cmd >> 16; |
|
409 |
_additional_cash_required = 0; |
|
410 |
||
411 |
// spectator has no rights. |
|
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
|
412 |
if (_current_player == OWNER_SPECTATOR) { |
0 | 413 |
ShowErrorMessage(_error_message, _error_message_2, x, y); |
414 |
return false; |
|
415 |
} |
|
416 |
||
417 |
flags = 0; |
|
418 |
if (cmd & CMD_AUTO) flags |= DC_AUTO; |
|
419 |
if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER; |
|
420 |
||
421 |
// get pointer to command handler |
|
422 |
assert((cmd & 0xFF) < lengthof(_command_proc_table)); |
|
423 |
proc = _command_proc_table[cmd & 0xFF]; |
|
424 |
||
826 | 425 |
// Some commands have a different output in dryrun than the realrun |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
426 |
// e.g.: if you demolish a whole town, the dryrun would say okay. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
427 |
// but by really destroying, your rating drops and at a certain point |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
428 |
// it will fail. so res and res2 are different |
467
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
429 |
// CMD_REMOVE_ROAD: This command has special local authority |
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
430 |
// restrictions which may cause the test run to fail (the previous |
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
431 |
// road fragments still stay there and the town won't let you |
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
432 |
// disconnect the road system), but the exec will succeed and this |
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
433 |
// fact will trigger an assertion failure. --pasky |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
434 |
notest = |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
435 |
(cmd & 0xFF) == CMD_CLEAR_AREA || |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
436 |
(cmd & 0xFF) == CMD_CONVERT_RAIL || |
0 | 437 |
(cmd & 0xFF) == CMD_LEVEL_LAND || |
467
dd312bc9ca36
(svn r697) Fix the town road removal crash _still_ present there.
pasky
parents:
395
diff
changeset
|
438 |
(cmd & 0xFF) == CMD_REMOVE_ROAD; |
0 | 439 |
|
440 |
_docommand_recursive = 1; |
|
441 |
||
442 |
// cost estimation only? |
|
842 | 443 |
if (_shift_pressed && _current_player == _local_player && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR))) { |
0 | 444 |
// estimate the cost. |
445 |
res = proc(x, y, flags, p1, p2); |
|
446 |
if ((uint32)res >> 16 == 0x8000) { |
|
447 |
if (res & 0xFFFF) _error_message = res & 0xFFFF; |
|
448 |
ShowErrorMessage(_error_message, _error_message_2, x, y); |
|
449 |
} else { |
|
450 |
ShowEstimatedCostOrIncome(res, x, y); |
|
451 |
} |
|
452 |
||
453 |
_docommand_recursive = 0; |
|
454 |
return false; |
|
455 |
} |
|
456 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
457 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
458 |
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { |
0 | 459 |
// first test if the command can be executed. |
460 |
res = proc(x,y, flags, p1, p2); |
|
461 |
if ((uint32)res >> 16 == 0x8000) { |
|
462 |
if (res & 0xFFFF) _error_message = res & 0xFFFF; |
|
463 |
goto show_error; |
|
464 |
} |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
465 |
// no money? Only check if notest is off |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
466 |
if (!notest && res != 0 && !CheckPlayerHasMoney(res)) goto show_error; |
0 | 467 |
} |
468 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
469 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
470 |
// If we are in network, and the command is not from the network |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
471 |
// send it to the command-queue and abort execution |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
472 |
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
473 |
NetworkSend_Command(tile, p1, p2, cmd, callback); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
474 |
_docommand_recursive = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
475 |
return true; |
0 | 476 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
477 |
#endif /* ENABLE_NETWORK */ |
0 | 478 |
|
479 |
// update last build coordinate of player. |
|
480 |
if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile; |
|
481 |
||
889
64d2f7d5f02b
(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
|
482 |
/* Actually try and execute the command. If no cost-type is given |
64d2f7d5f02b
(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
|
483 |
* use the construction one */ |
64d2f7d5f02b
(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
|
484 |
_yearly_expenses_type = EXPENSES_CONSTRUCTION; |
0 | 485 |
res2 = proc(x,y, flags|DC_EXEC, p1, p2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
486 |
|
826 | 487 |
// If notest is on, it means the result of the test can be different than |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
488 |
// the real command.. so ignore the test |
652
206a7c2016ba
(svn r1085) -Fix: [Network] [ 1084834 ] If IF_IN_NETWORK flag was on, an error
truelight
parents:
601
diff
changeset
|
489 |
if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { |
0 | 490 |
assert(res == res2); // sanity check |
491 |
} else { |
|
492 |
if ((uint32)res2 >> 16 == 0x8000) { |
|
493 |
if (res2 & 0xFFFF) _error_message = res2 & 0xFFFF; |
|
494 |
goto show_error; |
|
495 |
} |
|
496 |
} |
|
497 |
||
498 |
SubtractMoneyFromPlayer(res2); |
|
499 |
||
500 |
if (_current_player == _local_player && _game_mode != GM_EDITOR) { |
|
501 |
if (res2 != 0) |
|
502 |
ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2); |
|
503 |
if (_additional_cash_required) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
504 |
SetDParam(0, _additional_cash_required); |
0 | 505 |
ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, _error_message_2, x,y); |
506 |
if (res2 == 0) goto callb_err; |
|
507 |
} |
|
508 |
} |
|
509 |
||
510 |
_docommand_recursive = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
511 |
|
0 | 512 |
if (callback) callback(true, tile, p1, p2); |
513 |
return true; |
|
514 |
||
515 |
show_error: |
|
516 |
// show error message if the command fails? |
|
517 |
if (_current_player == _local_player && _error_message_2 != 0) |
|
518 |
ShowErrorMessage(_error_message, _error_message_2, x,y); |
|
519 |
||
520 |
callb_err: |
|
521 |
_docommand_recursive = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
147
diff
changeset
|
522 |
|
0 | 523 |
if (callback) callback(false, tile, p1, p2); |
524 |
return false; |
|
525 |
} |