diff options
author | rubidium <rubidium@openttd.org> | 2008-04-05 10:55:50 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-05 10:55:50 +0000 |
commit | bdd64495cd7af3fa064ed58a5419845eb78def46 (patch) | |
tree | b4b03c4e03ba0d09492cdcef08e4dd07ceb77dc8 /src/ship_cmd.cpp | |
parent | e9661fb42054aa0a96579efe4ccc3a276619f12e (diff) | |
download | openttd-bdd64495cd7af3fa064ed58a5419845eb78def46.tar.xz |
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r-- | src/ship_cmd.cpp | 65 |
1 files changed, 7 insertions, 58 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index baac1285b..0d814003e 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -242,66 +242,15 @@ void Ship::PlayLeaveStationSound() const PlayShipSound(this); } -static void ProcessShipOrder(Vehicle *v) +TileIndex Ship::GetOrderStationLocation(StationID station) { - const Order *order; - - switch (v->current_order.type) { - case OT_GOTO_DEPOT: - if (!(v->current_order.flags & OFB_PART_OF_ORDERS)) return; - if (v->current_order.flags & OFB_SERVICE_IF_NEEDED && - !VehicleNeedsService(v)) { - UpdateVehicleTimetable(v, true); - v->cur_order_index++; - } - break; - - case OT_LOADING: - case OT_LEAVESTATION: - return; - - default: break; - } - - if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; - - order = GetVehicleOrder(v, v->cur_order_index); - - if (order == NULL) { - v->current_order.Free(); - v->dest_tile = 0; - return; - } - - if (order->type == v->current_order.type && - order->flags == v->current_order.flags && - order->dest == v->current_order.dest && - (order->type != OT_GOTO_STATION || GetStation(order->dest)->dock_tile != 0)) - return; - - v->current_order = *order; - - if (order->type == OT_GOTO_STATION) { - const Station *st; - - if (order->dest == v->last_station_visited) - v->last_station_visited = INVALID_STATION; - - st = GetStation(order->dest); - if (st->dock_tile != 0) { - v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile))); - } else { - v->cur_order_index++; - } - } else if (order->type == OT_GOTO_DEPOT) { - v->dest_tile = GetDepot(order->dest)->xy; + Station *st = GetStation(station); + if (st->dock_tile != 0) { + return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile))); } else { - v->dest_tile = 0; + this->cur_order_index++; + return 0; } - - InvalidateVehicleOrder(v); - - InvalidateWindowClasses(WC_SHIPS_LIST); } void Ship::UpdateDeltaXY(Direction direction) @@ -650,7 +599,7 @@ static void ShipController(Vehicle *v) if (v->vehstatus & VS_STOPPED) return; - ProcessShipOrder(v); + ProcessOrders(v); v->HandleLoading(); if (v->current_order.type == OT_LOADING) return; |