(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.
--- a/src/economy.cpp Mon May 14 15:20:50 2007 +0000
+++ b/src/economy.cpp Mon May 14 16:07:05 2007 +0000
@@ -1482,8 +1482,13 @@
* 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 @@
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 @@
}
}
+/**
+ * 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<Vehicle *>::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();
--- a/src/economy.h Mon May 14 15:20:50 2007 +0000
+++ b/src/economy.h Mon May 14 16:07:05 2007 +0000
@@ -69,5 +69,6 @@
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
void VehiclePayment(Vehicle *front_v);
+void LoadUnloadStation(Station *st);
#endif /* ECONOMY_H */
--- a/src/vehicle.cpp Mon May 14 15:20:50 2007 +0000
+++ b/src/vehicle.cpp Mon May 14 16:07:05 2007 +0000
@@ -659,8 +659,6 @@
void CallVehicleTicks()
{
- Vehicle *v;
-
#ifdef ENABLE_NETWORK
/* hotfix for desync problem:
* for MP games invalidate the YAPF cache every tick to keep it exactly the same on the server and all clients */
@@ -671,6 +669,10 @@
_first_veh_in_depot_list = NULL; // now we are sure it's initialized at the start of each tick
+ Station *st;
+ FOR_ALL_STATIONS(st) LoadUnloadStation(st);
+
+ Vehicle *v;
FOR_ALL_VEHICLES(v) {
_vehicle_tick_procs[v->type](v);
@@ -2933,17 +2935,8 @@
{
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. */
- LoadUnloadVehicle(this);
-
- if (!HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return;
+ /* Not the first call for this tick, or still loading */
+ if (mode || !HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return;
this->PlayLeaveStationSound();
--- a/src/vehicle.h Mon May 14 15:20:50 2007 +0000
+++ b/src/vehicle.h Mon May 14 16:07:05 2007 +0000
@@ -521,8 +521,6 @@
UnitID GetFreeUnitNumber(byte type);
-void LoadUnloadVehicle(Vehicle *v);
-
void TrainConsistChanged(Vehicle *v);
void TrainPowerChanged(Vehicle *v);
int32 GetTrainRunningCost(const Vehicle *v);