From 2efecd34c4237bb52981c92241a7b76c46896c4c Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 7 May 2007 16:21:34 +0000 Subject: (svn r9808) -Codechange: unify the HandleLoading functions. --- src/vehicle.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/vehicle.cpp') diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 745ca776a..89757e7e7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2929,6 +2929,40 @@ void Vehicle::LeaveStation() } +void Vehicle::HandleLoading(bool mode) +{ + switch (this->current_order.type) { + case OT_LOADING: { + /* Not the first call for this tick */ + if (mode) return; + + /* We have not waited enough time till the next round of loading/unloading */ + if (--this->load_unload_time_rem) return; + + /* Load/unload the vehicle; when it actually did something + * we do not leave the station. */ + if (LoadUnloadVehicle(this)) return; + + this->PlayLeaveStationSound(); + + Order b = this->current_order; + this->LeaveStation(); + + /* If this was not the final order, don't remove it from the list. */ + if (!(b.flags & OF_NON_STOP)) return; + break; + } + + case OT_DUMMY: break; + + default: return; + } + + this->cur_order_index++; + InvalidateVehicleOrder(this); +} + + void SpecialVehicle::UpdateDeltaXY(Direction direction) { this->x_offs = 0; -- cgit v1.2.3-54-g00ecf