diff options
author | rubidium <rubidium@openttd.org> | 2007-04-29 18:21:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-04-29 18:21:24 +0000 |
commit | 6440440f129041fbb60d25fbfb182a68c82f17a2 (patch) | |
tree | 87b202dc9547deba8ff9f14dc895001e6404777e /src | |
parent | bf04c88ecad4d4a183ebf8461f1d58fa57d658ae (diff) | |
download | openttd-6440440f129041fbb60d25fbfb182a68c82f17a2.tar.xz |
(svn r9752) -Codechange: remove some duplication related to BeginLoading.
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft_cmd.cpp | 8 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 9 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 4 | ||||
-rw-r--r-- | src/train_cmd.cpp | 14 | ||||
-rw-r--r-- | src/vehicle.cpp | 18 |
5 files changed, 20 insertions, 33 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index c68c06383..c704645db 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1509,15 +1509,7 @@ static void AircraftEntersTerminal(Vehicle *v) 0); } - Order old_order = v->current_order; v->BeginLoading(); - v->current_order.flags = 0; - - if (old_order.type == OT_GOTO_STATION && - v->current_order.dest == v->last_station_visited) { - v->current_order.flags = - (old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP; - } SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC); LoadUnloadVehicle(v, true); diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index d0e3813dc..5f8612bc9 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1569,7 +1569,6 @@ again: if (v->current_order.type != OT_LEAVESTATION && v->current_order.type != OT_GOTO_DEPOT) { /* Vehicle has arrived at a bay in a road stop */ - Order old_order; if (IsDriveThroughStopTile(v->tile)) { TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction)); @@ -1600,15 +1599,7 @@ again: RoadVehArrivesAt(v, st); - old_order = v->current_order; v->BeginLoading(); - v->current_order.flags = 0; - - if (old_order.type == OT_GOTO_STATION && - v->current_order.dest == v->last_station_visited) { - v->current_order.flags = - (old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP; - } SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC); if (LoadUnloadVehicle(v, true)) { diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 58864273b..6e4d44d94 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -304,7 +304,7 @@ static void HandleShipLoading(Vehicle *v) { switch (v->current_order.type) { case OT_LOADING: { - if (--v->load_unload_time_rem) return; + if (--v->load_unload_time_rem != 0) return; if (CanFillVehicle(v) && ( v->current_order.flags & OF_FULL_LOAD || @@ -736,8 +736,6 @@ static void ShipController(Vehicle *v) st = GetStation(v->current_order.dest); if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations v->BeginLoading(); - v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; - v->current_order.flags |= OF_NON_STOP; ShipArrivesAt(v, st); SET_EXPENSES_TYPE(EXPENSES_SHIP_INC); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index c3eedc2c5..6de1b96e0 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2634,19 +2634,7 @@ static void TrainEnterStation(Vehicle *v, StationID station) ); } - /* Did we reach the final destination? */ - if (v->current_order.type == OT_GOTO_STATION && - v->current_order.dest == station) { - /* Yeah, keep the load/unload flags - * Non Stop now means if the order should be increased. */ - v->BeginLoading(); - v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; - v->current_order.flags |= OF_NON_STOP; - } else { - /* No, just do a simple load */ - v->BeginLoading(); - v->current_order.flags = 0; - } + v->BeginLoading(); v->current_order.dest = 0; SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 90ee45ad6..dccebcd5d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2950,6 +2950,24 @@ extern const ChunkHandler _veh_chunk_handlers[] = { void Vehicle::BeginLoading() { assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP); + + if (this->current_order.type == OT_GOTO_STATION && + this->current_order.dest == this->last_station_visited) { + /* Arriving at the ordered station. + * Keep the load/unload flags, as we (obviously) still need them. */ + this->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; + + /* Furthermore add the Non Stop flag to mark that this station + * is the actual destination of the vehicle, which is (for example) + * necessary to be known for HandleTrainLoading to determine + * whether the train is lost or not; not marking a train lost + * that arrives at random stations is bad. */ + this->current_order.flags |= OF_NON_STOP; + } else { + /* This is just an unordered intermediate stop */ + this->current_order.flags = 0; + } + current_order.type = OT_LOADING; GetStation(this->last_station_visited)->loading_vehicles.push_back(this); } |