240 void Ship::PlayLeaveStationSound() const |
240 void Ship::PlayLeaveStationSound() const |
241 { |
241 { |
242 PlayShipSound(this); |
242 PlayShipSound(this); |
243 } |
243 } |
244 |
244 |
245 static void ProcessShipOrder(Vehicle *v) |
245 TileIndex Ship::GetOrderStationLocation(StationID station) |
246 { |
246 { |
247 const Order *order; |
247 Station *st = GetStation(station); |
248 |
248 if (st->dock_tile != 0) { |
249 switch (v->current_order.type) { |
249 return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile))); |
250 case OT_GOTO_DEPOT: |
|
251 if (!(v->current_order.flags & OFB_PART_OF_ORDERS)) return; |
|
252 if (v->current_order.flags & OFB_SERVICE_IF_NEEDED && |
|
253 !VehicleNeedsService(v)) { |
|
254 UpdateVehicleTimetable(v, true); |
|
255 v->cur_order_index++; |
|
256 } |
|
257 break; |
|
258 |
|
259 case OT_LOADING: |
|
260 case OT_LEAVESTATION: |
|
261 return; |
|
262 |
|
263 default: break; |
|
264 } |
|
265 |
|
266 if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; |
|
267 |
|
268 order = GetVehicleOrder(v, v->cur_order_index); |
|
269 |
|
270 if (order == NULL) { |
|
271 v->current_order.Free(); |
|
272 v->dest_tile = 0; |
|
273 return; |
|
274 } |
|
275 |
|
276 if (order->type == v->current_order.type && |
|
277 order->flags == v->current_order.flags && |
|
278 order->dest == v->current_order.dest && |
|
279 (order->type != OT_GOTO_STATION || GetStation(order->dest)->dock_tile != 0)) |
|
280 return; |
|
281 |
|
282 v->current_order = *order; |
|
283 |
|
284 if (order->type == OT_GOTO_STATION) { |
|
285 const Station *st; |
|
286 |
|
287 if (order->dest == v->last_station_visited) |
|
288 v->last_station_visited = INVALID_STATION; |
|
289 |
|
290 st = GetStation(order->dest); |
|
291 if (st->dock_tile != 0) { |
|
292 v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile))); |
|
293 } else { |
|
294 v->cur_order_index++; |
|
295 } |
|
296 } else if (order->type == OT_GOTO_DEPOT) { |
|
297 v->dest_tile = GetDepot(order->dest)->xy; |
|
298 } else { |
250 } else { |
299 v->dest_tile = 0; |
251 this->cur_order_index++; |
300 } |
252 return 0; |
301 |
253 } |
302 InvalidateVehicleOrder(v); |
|
303 |
|
304 InvalidateWindowClasses(WC_SHIPS_LIST); |
|
305 } |
254 } |
306 |
255 |
307 void Ship::UpdateDeltaXY(Direction direction) |
256 void Ship::UpdateDeltaXY(Direction direction) |
308 { |
257 { |
309 #define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) |
258 #define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0) |