From c7d57379fbdda52590cddb83240934da6b5e8b21 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 14 May 2007 16:07:05 +0000 Subject: (svn r9836) -Codechange: make non-improved loading happen FIFO-ish; generally loading/unloading will happen fifo, but there are no guarantees on the FIFO-ness. For (better) FIFO guarantees you still need to use improved loading. --- src/economy.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/economy.cpp') diff --git a/src/economy.cpp b/src/economy.cpp index bb90cb488..91679412c 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1482,8 +1482,13 @@ void VehiclePayment(Vehicle *front_v) * Loads/unload the vehicle if possible. * @param v the vehicle to be (un)loaded */ -void LoadUnloadVehicle(Vehicle *v) +static void LoadUnloadVehicle(Vehicle *v) { + assert(v->current_order.type == OT_LOADING); + + /* We have not waited enough time till the next round of loading/unloading */ + if (--v->load_unload_time_rem != 0) return; + int unloading_time = 0; Vehicle *u = v; int result = 0; @@ -1496,8 +1501,6 @@ void LoadUnloadVehicle(Vehicle *v) uint32 cargo_full = 0; int total_cargo_feeder_share = 0; // the feeder cash amount for the goods being loaded/unloaded in this load step - assert(v->current_order.type == OT_LOADING); - v->cur_speed = 0; StationID last_visited = v->last_station_visited; @@ -1706,6 +1709,20 @@ void LoadUnloadVehicle(Vehicle *v) } } +/** + * Load/unload the vehicles in this station according to the order + * they entered. + * @param st the station to do the loading/unloading for + */ +void LoadUnloadStation(Station *st) +{ + std::list::iterator iter; + for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) { + Vehicle *v = *iter; + if (!(v->vehstatus & (VS_STOPPED | VS_CRASHED))) LoadUnloadVehicle(v); + } +} + void PlayersMonthlyLoop() { PlayersGenStatistics(); -- cgit v1.2.3-54-g00ecf