(svn r11805) -Fix [FS#1620]: VEHICLE_TRIGGER_EMPTY was triggered continuously while train waiting in station.

This commit is contained in:
frosch 2008-01-10 13:13:18 +00:00
parent 88f11bbfeb
commit 9629b26677

View File

@ -1564,7 +1564,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
int result = 0; int result = 0;
uint cap; uint cap;
bool completely_empty = true; bool completely_emptied = true;
bool anything_unloaded = false; bool anything_unloaded = false;
bool anything_loaded = false; bool anything_loaded = false;
uint32 cargo_not_full = 0; uint32 cargo_not_full = 0;
@ -1612,7 +1612,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
anything_unloaded = true; anything_unloaded = true;
if (_patches.gradual_loading && remaining) { if (_patches.gradual_loading && remaining) {
completely_empty = false; completely_emptied = false;
} else { } else {
/* We have finished unloading (cargo count == 0) */ /* We have finished unloading (cargo count == 0) */
ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING); ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
@ -1665,9 +1665,9 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
* loading them. Since this will cause * loading them. Since this will cause
* VEHICLE_TRIGGER_EMPTY to be called at the time when * VEHICLE_TRIGGER_EMPTY to be called at the time when
* the whole vehicle chain is really totally empty, the * the whole vehicle chain is really totally empty, the
* completely_empty assignment can then be safely * completely_emptied assignment can then be safely
* removed; that's how TTDPatch behaves too. --pasky */ * removed; that's how TTDPatch behaves too. --pasky */
completely_empty = false; completely_emptied = false;
anything_loaded = true; anything_loaded = true;
ge->cargo.MoveTo(&v->cargo, cap, CargoList::MTA_CARGO_LOAD, st->xy); ge->cargo.MoveTo(&v->cargo, cap, CargoList::MTA_CARGO_LOAD, st->xy);
@ -1687,6 +1687,9 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
} }
} }
/* Only set completly_emptied, if we just unloaded all remaining cargo */
completely_emptied &= anything_unloaded;
/* We update these variables here, so gradual loading still fills /* We update these variables here, so gradual loading still fills
* all wagons at the same time instead of using the same 'improved' * all wagons at the same time instead of using the same 'improved'
* loading algorithm for the wagons (only fill wagon when there is * loading algorithm for the wagons (only fill wagon when there is
@ -1754,7 +1757,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
v->load_unload_time_rem = unloading_time; v->load_unload_time_rem = unloading_time;
if (completely_empty) { if (completely_emptied) {
TriggerVehicle(v, VEHICLE_TRIGGER_EMPTY); TriggerVehicle(v, VEHICLE_TRIGGER_EMPTY);
} }