|
1 /* $Id$ */ |
|
2 |
|
3 #ifndef COMMAND_H |
|
4 #define COMMAND_H |
|
5 |
|
6 enum { |
|
7 CMD_BUILD_RAILROAD_TRACK = 0, |
|
8 CMD_REMOVE_RAILROAD_TRACK = 1, |
|
9 CMD_BUILD_SINGLE_RAIL = 2, |
|
10 CMD_REMOVE_SINGLE_RAIL = 3, |
|
11 CMD_LANDSCAPE_CLEAR = 4, |
|
12 CMD_BUILD_BRIDGE = 5, |
|
13 CMD_BUILD_RAILROAD_STATION = 6, |
|
14 CMD_BUILD_TRAIN_DEPOT = 7, |
|
15 CMD_BUILD_SIGNALS = 8, |
|
16 CMD_REMOVE_SIGNALS = 9, |
|
17 CMD_TERRAFORM_LAND = 10, |
|
18 CMD_PURCHASE_LAND_AREA = 11, |
|
19 CMD_SELL_LAND_AREA = 12, |
|
20 CMD_BUILD_TUNNEL = 13, |
|
21 |
|
22 CMD_REMOVE_FROM_RAILROAD_STATION = 14, |
|
23 CMD_CONVERT_RAIL = 15, |
|
24 |
|
25 CMD_BUILD_TRAIN_WAYPOINT = 16, |
|
26 CMD_RENAME_WAYPOINT = 17, |
|
27 CMD_REMOVE_TRAIN_WAYPOINT = 18, |
|
28 |
|
29 CMD_BUILD_ROAD_STOP = 21, |
|
30 CMD_BUILD_LONG_ROAD = 23, |
|
31 CMD_REMOVE_LONG_ROAD = 24, |
|
32 CMD_BUILD_ROAD = 25, |
|
33 CMD_REMOVE_ROAD = 26, |
|
34 CMD_BUILD_ROAD_DEPOT = 27, |
|
35 |
|
36 CMD_BUILD_AIRPORT = 29, |
|
37 |
|
38 CMD_BUILD_DOCK = 30, |
|
39 |
|
40 CMD_BUILD_SHIP_DEPOT = 31, |
|
41 CMD_BUILD_BUOY = 32, |
|
42 |
|
43 CMD_PLANT_TREE = 33, |
|
44 |
|
45 CMD_BUILD_RAIL_VEHICLE = 34, |
|
46 CMD_MOVE_RAIL_VEHICLE = 35, |
|
47 |
|
48 CMD_START_STOP_TRAIN = 36, |
|
49 |
|
50 CMD_SELL_RAIL_WAGON = 38, |
|
51 |
|
52 CMD_SEND_TRAIN_TO_DEPOT = 39, |
|
53 CMD_FORCE_TRAIN_PROCEED = 40, |
|
54 CMD_REVERSE_TRAIN_DIRECTION = 41, |
|
55 |
|
56 CMD_MODIFY_ORDER = 42, |
|
57 CMD_SKIP_ORDER = 43, |
|
58 CMD_DELETE_ORDER = 44, |
|
59 CMD_INSERT_ORDER = 45, |
|
60 |
|
61 CMD_CHANGE_SERVICE_INT = 46, |
|
62 |
|
63 CMD_BUILD_INDUSTRY = 47, |
|
64 |
|
65 CMD_BUILD_COMPANY_HQ = 48, |
|
66 CMD_SET_PLAYER_FACE = 49, |
|
67 CMD_SET_PLAYER_COLOR = 50, |
|
68 |
|
69 CMD_INCREASE_LOAN = 51, |
|
70 CMD_DECREASE_LOAN = 52, |
|
71 |
|
72 CMD_WANT_ENGINE_PREVIEW = 53, |
|
73 |
|
74 CMD_NAME_VEHICLE = 54, |
|
75 CMD_RENAME_ENGINE = 55, |
|
76 CMD_CHANGE_COMPANY_NAME = 56, |
|
77 CMD_CHANGE_PRESIDENT_NAME = 57, |
|
78 CMD_RENAME_STATION = 58, |
|
79 |
|
80 CMD_SELL_AIRCRAFT = 59, |
|
81 CMD_START_STOP_AIRCRAFT = 60, |
|
82 CMD_BUILD_AIRCRAFT = 61, |
|
83 CMD_SEND_AIRCRAFT_TO_HANGAR = 62, |
|
84 CMD_REFIT_AIRCRAFT = 64, |
|
85 |
|
86 CMD_PLACE_SIGN = 65, |
|
87 CMD_RENAME_SIGN = 66, |
|
88 |
|
89 CMD_BUILD_ROAD_VEH = 67, |
|
90 CMD_START_STOP_ROADVEH = 68, |
|
91 CMD_SELL_ROAD_VEH = 69, |
|
92 CMD_SEND_ROADVEH_TO_DEPOT = 70, |
|
93 CMD_TURN_ROADVEH = 71, |
|
94 CMD_REFIT_ROAD_VEH = 72, |
|
95 |
|
96 CMD_PAUSE = 73, |
|
97 |
|
98 CMD_BUY_SHARE_IN_COMPANY = 74, |
|
99 CMD_SELL_SHARE_IN_COMPANY = 75, |
|
100 CMD_BUY_COMPANY = 76, |
|
101 |
|
102 CMD_BUILD_TOWN = 77, |
|
103 |
|
104 CMD_RENAME_TOWN = 80, |
|
105 CMD_DO_TOWN_ACTION = 81, |
|
106 |
|
107 CMD_SET_ROAD_DRIVE_SIDE = 82, |
|
108 |
|
109 CMD_CHANGE_DIFFICULTY_LEVEL = 85, |
|
110 |
|
111 CMD_START_STOP_SHIP = 86, |
|
112 CMD_SELL_SHIP = 87, |
|
113 CMD_BUILD_SHIP = 88, |
|
114 CMD_SEND_SHIP_TO_DEPOT = 89, |
|
115 CMD_REFIT_SHIP = 91, |
|
116 |
|
117 CMD_ORDER_REFIT = 98, |
|
118 CMD_CLONE_ORDER = 99, |
|
119 CMD_CLEAR_AREA = 100, |
|
120 |
|
121 CMD_MONEY_CHEAT = 102, |
|
122 CMD_BUILD_CANAL = 103, |
|
123 |
|
124 CMD_PLAYER_CTRL = 104, // used in multiplayer to create a new player etc. |
|
125 CMD_LEVEL_LAND = 105, // level land |
|
126 |
|
127 CMD_REFIT_RAIL_VEHICLE = 106, |
|
128 CMD_RESTORE_ORDER_INDEX = 107, |
|
129 CMD_BUILD_LOCK = 108, |
|
130 |
|
131 CMD_BUILD_SIGNAL_TRACK = 110, |
|
132 CMD_REMOVE_SIGNAL_TRACK = 111, |
|
133 |
|
134 CMD_GIVE_MONEY = 113, |
|
135 CMD_CHANGE_PATCH_SETTING = 114, |
|
136 |
|
137 CMD_SET_AUTOREPLACE = 115, |
|
138 |
|
139 CMD_CLONE_VEHICLE = 116, |
|
140 CMD_MASS_START_STOP = 117, |
|
141 CMD_DEPOT_SELL_ALL_VEHICLES = 118, |
|
142 CMD_DEPOT_MASS_AUTOREPLACE = 119, |
|
143 }; |
|
144 |
|
145 enum { |
|
146 DC_EXEC = 0x01, |
|
147 DC_AUTO = 0x02, // don't allow building on structures |
|
148 DC_QUERY_COST = 0x04, // query cost only, don't build. |
|
149 DC_NO_WATER = 0x08, // don't allow building on water |
|
150 DC_NO_RAIL_OVERLAP = 0x10, // don't allow overlap of rails (used in buildrail) |
|
151 DC_AI_BUILDING = 0x20, // special building rules for AI |
|
152 DC_NO_TOWN_RATING = 0x40, // town rating does not disallow you from building |
|
153 DC_FORCETEST = 0x80, // force test too. |
|
154 |
|
155 CMD_ERROR = ((int32)0x80000000), |
|
156 }; |
|
157 |
|
158 #define CMD_MSG(x) ((x)<<16) |
|
159 |
|
160 enum { |
|
161 CMD_AUTO = 0x0200, |
|
162 CMD_NO_WATER = 0x0400, |
|
163 CMD_NETWORK_COMMAND = 0x0800, // execute the command without sending it on the network |
|
164 CMD_NO_TEST_IF_IN_NETWORK = 0x1000, // When enabled, the command will bypass the no-DC_EXEC round if in network |
|
165 CMD_SHOW_NO_ERROR = 0x2000, |
|
166 }; |
|
167 |
|
168 /** Command flags for the command table |
|
169 * @see _command_proc_table |
|
170 */ |
|
171 enum { |
|
172 CMD_SERVER = 0x1, /// the command can only be initiated by the server |
|
173 CMD_OFFLINE = 0x2, /// the command cannot be executed in a multiplayer game; single-player only |
|
174 }; |
|
175 |
|
176 typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2); |
|
177 |
|
178 typedef struct Command { |
|
179 CommandProc *proc; |
|
180 byte flags; |
|
181 } Command; |
|
182 |
|
183 //#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0) |
|
184 #define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0) |
|
185 |
|
186 /** |
|
187 * Check the return value of a DoCommand*() function |
|
188 * @param res the resulting value from the command to be checked |
|
189 * @return Return true if the command failed, false otherwise |
|
190 */ |
|
191 static inline bool CmdFailed(int32 res) |
|
192 { |
|
193 // lower 16bits are the StringID of the possible error |
|
194 return res <= (CMD_ERROR | INVALID_STRING_ID); |
|
195 } |
|
196 |
|
197 /* command.c */ |
|
198 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2); |
|
199 int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
|
200 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); |
|
201 |
|
202 #ifdef ENABLE_NETWORK |
|
203 |
|
204 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); |
|
205 #endif /* ENABLE_NETWORK */ |
|
206 |
|
207 extern const char* _cmd_text; // Text, which gets sent with a command |
|
208 |
|
209 bool IsValidCommand(uint cmd); |
|
210 byte GetCommandFlags(uint cmd); |
|
211 int32 GetAvailableMoneyForCommand(void); |
|
212 |
|
213 #endif /* COMMAND_H */ |