equal
deleted
inserted
replaced
11 * p1 >> 16 = index in order list |
11 * p1 >> 16 = index in order list |
12 * p2 = order command to insert |
12 * p2 = order command to insert |
13 */ |
13 */ |
14 int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
14 int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
15 { |
15 { |
16 Vehicle *v = &_vehicles[p1 & 0xFFFF]; |
16 Vehicle *v = GetVehicle(p1 & 0xFFFF); |
17 int sel = p1 >> 16; |
17 int sel = p1 >> 16; |
18 Order new_order = UnpackOrder(p2); |
18 Order new_order = UnpackOrder(p2); |
19 |
19 |
20 if (sel > v->num_orders) return_cmd_error(STR_EMPTY); |
20 if (sel > v->num_orders) return_cmd_error(STR_EMPTY); |
21 if (_ptr_to_next_order == endof(_order_array)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); |
21 if (_ptr_to_next_order == endof(_order_array)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS); |
24 // for ships, make sure that the station is not too far away from the previous destination. |
24 // for ships, make sure that the station is not too far away from the previous destination. |
25 if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) && |
25 if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) && |
26 sel != 0 && v->schedule_ptr[sel - 1].type == OT_GOTO_STATION) { |
26 sel != 0 && v->schedule_ptr[sel - 1].type == OT_GOTO_STATION) { |
27 |
27 |
28 int dist = GetTileDist( |
28 int dist = GetTileDist( |
29 DEREF_STATION(v->schedule_ptr[sel - 1].station)->xy, |
29 GetStation(v->schedule_ptr[sel - 1].station)->xy, |
30 DEREF_STATION(new_order.station)->xy |
30 GetStation(new_order.station)->xy |
31 ); |
31 ); |
32 if (dist >= 130) |
32 if (dist >= 130) |
33 return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO); |
33 return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO); |
34 } |
34 } |
35 |
35 |
92 /* p1 = vehicle |
92 /* p1 = vehicle |
93 * p2 = sel |
93 * p2 = sel |
94 */ |
94 */ |
95 int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
95 int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
96 { |
96 { |
97 Vehicle *v = &_vehicles[p1], *u; |
97 Vehicle *v = GetVehicle(p1), *u; |
98 uint sel = (uint)p2; |
98 uint sel = (uint)p2; |
99 |
99 |
100 _error_message = STR_EMPTY; |
100 _error_message = STR_EMPTY; |
101 if (sel >= v->num_orders) |
101 if (sel >= v->num_orders) |
102 return DecloneOrder(v, flags); |
102 return DecloneOrder(v, flags); |
139 |
139 |
140 /* p1 = vehicle */ |
140 /* p1 = vehicle */ |
141 int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
141 int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
142 { |
142 { |
143 if (flags & DC_EXEC) { |
143 if (flags & DC_EXEC) { |
144 Vehicle *v = &_vehicles[p1]; |
144 Vehicle *v = GetVehicle(p1); |
145 |
145 |
146 { |
146 { |
147 byte b = v->cur_order_index + 1; |
147 byte b = v->cur_order_index + 1; |
148 if (b >= v->num_orders) b = 0; |
148 if (b >= v->num_orders) b = 0; |
149 v->cur_order_index = b; |
149 v->cur_order_index = b; |
166 * p2&0xFF = sel |
166 * p2&0xFF = sel |
167 * p2>>8 = mode |
167 * p2>>8 = mode |
168 */ |
168 */ |
169 int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
169 int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
170 { |
170 { |
171 Vehicle *v = &_vehicles[p1]; |
171 Vehicle *v = GetVehicle(p1); |
172 byte sel = (byte)p2; |
172 byte sel = (byte)p2; |
173 Order *sched; |
173 Order *sched; |
174 |
174 |
175 if (sel >= v->num_orders) |
175 if (sel >= v->num_orders) |
176 return CMD_ERROR; |
176 return CMD_ERROR; |
217 // 2 - unclone |
217 // 2 - unclone |
218 |
218 |
219 |
219 |
220 int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
220 int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
221 { |
221 { |
222 Vehicle *dst = &_vehicles[p1 & 0xFFFF]; |
222 Vehicle *dst = GetVehicle(p1 & 0xFFFF); |
223 |
223 |
224 if (!(dst->type && dst->owner == _current_player)) |
224 if (!(dst->type && dst->owner == _current_player)) |
225 return CMD_ERROR; |
225 return CMD_ERROR; |
226 |
226 |
227 switch(p2) { |
227 switch(p2) { |
228 |
228 |
229 // share vehicle orders? |
229 // share vehicle orders? |
230 case 0: { |
230 case 0: { |
231 Vehicle *src = &_vehicles[p1 >> 16]; |
231 Vehicle *src = GetVehicle(p1 >> 16); |
232 |
232 |
233 // sanity checks |
233 // sanity checks |
234 if (!(src->owner == _current_player && dst->type == src->type && dst != src)) |
234 if (!(src->owner == _current_player && dst->type == src->type && dst != src)) |
235 return CMD_ERROR; |
235 return CMD_ERROR; |
236 |
236 |
253 break; |
253 break; |
254 } |
254 } |
255 |
255 |
256 // copy vehicle orders? |
256 // copy vehicle orders? |
257 case 1: { |
257 case 1: { |
258 Vehicle *src = &_vehicles[p1 >> 16]; |
258 Vehicle *src = GetVehicle(p1 >> 16); |
259 int delta; |
259 int delta; |
260 |
260 |
261 // sanity checks |
261 // sanity checks |
262 if (!(src->owner == _current_player && dst->type == src->type && dst != src)) |
262 if (!(src->owner == _current_player && dst->type == src->type && dst != src)) |
263 return CMD_ERROR; |
263 return CMD_ERROR; |
267 const Order *i; |
267 const Order *i; |
268 TileIndex required_dst; |
268 TileIndex required_dst; |
269 |
269 |
270 for (i = src->schedule_ptr; i->type != OT_NOTHING; ++i) { |
270 for (i = src->schedule_ptr; i->type != OT_NOTHING; ++i) { |
271 if (i->type == OT_GOTO_STATION) { |
271 if (i->type == OT_GOTO_STATION) { |
272 const Station *st = DEREF_STATION(i->station); |
272 const Station *st = GetStation(i->station); |
273 required_dst = (dst->cargo_type == CT_PASSENGERS) ? st->bus_tile : st->lorry_tile; |
273 required_dst = (dst->cargo_type == CT_PASSENGERS) ? st->bus_tile : st->lorry_tile; |
274 if ( !required_dst ) |
274 if ( !required_dst ) |
275 return CMD_ERROR; |
275 return CMD_ERROR; |
276 } |
276 } |
277 } |
277 } |
364 */ |
364 */ |
365 int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
365 int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
366 { |
366 { |
367 // nonsense to update the windows, since, train rebought will have its window deleted |
367 // nonsense to update the windows, since, train rebought will have its window deleted |
368 if (flags & DC_EXEC) { |
368 if (flags & DC_EXEC) { |
369 Vehicle *v = &_vehicles[p1]; |
369 Vehicle *v = GetVehicle(p1); |
370 v->service_interval = (uint16)(p2>>16); |
370 v->service_interval = (uint16)(p2>>16); |
371 v->cur_order_index = (byte)(p2&0xFFFF); |
371 v->cur_order_index = (byte)(p2&0xFFFF); |
372 } |
372 } |
373 return 0; |
373 return 0; |
374 } |
374 } |
413 } |
413 } |
414 if (order.type == OT_GOTO_STATION /*&& (order != old_order) */) { |
414 if (order.type == OT_GOTO_STATION /*&& (order != old_order) */) { |
415 //I uncommented this in order not to get two error messages |
415 //I uncommented this in order not to get two error messages |
416 //when two identical entries are in the list |
416 //when two identical entries are in the list |
417 n_st++; |
417 n_st++; |
418 st = DEREF_STATION(order.station); |
418 st = GetStation(order.station); |
419 required_tile = GetStationTileForVehicle(v,st); |
419 required_tile = GetStationTileForVehicle(v,st); |
420 if (!required_tile) problem_type = 3; |
420 if (!required_tile) problem_type = 3; |
421 } |
421 } |
422 old_order = order; //store the old order |
422 old_order = order; //store the old order |
423 } |
423 } |