(svn r20506) -Change: Vehicles will now stop loading after a load cycle that loaded less than possible, unless it's a full load order. This should improve behaviour with gradual loading and cargo continuously trickling in.

This commit is contained in:
michi_cc 2010-08-15 22:37:30 +00:00
parent d08c3d9381
commit 29e7f55d94
2 changed files with 13 additions and 3 deletions

View File

@ -1161,6 +1161,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
bool completely_emptied = true;
bool anything_unloaded = false;
bool anything_loaded = false;
bool full_load_amount = false;
uint32 cargo_not_full = 0;
uint32 cargo_full = 0;
@ -1239,8 +1240,8 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
continue;
}
/* Do not pick up goods when we have no-load set. */
if (u->current_order.GetLoadType() & OLFB_NO_LOAD) continue;
/* Do not pick up goods when we have no-load set or loading is stopped. */
if (u->current_order.GetLoadType() & OLFB_NO_LOAD || HasBit(u->vehicle_flags, VF_STOP_LOADING)) continue;
/* update stats */
int t;
@ -1272,12 +1273,17 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
}
if (cap > count) cap = count;
if (_settings_game.order.gradual_loading) cap = min(cap, load_amount);
if (_settings_game.order.gradual_loading) {
cap = min(cap, load_amount);
cap_left = min(cap_left, load_amount);
}
if (_settings_game.order.improved_load) {
/* Don't load stuff that is already 'reserved' for other vehicles */
cap = min((uint)cargo_left[v->cargo_type], cap);
count = cargo_left[v->cargo_type];
cargo_left[v->cargo_type] -= cap;
}
if (count >= (uint)cap_left) full_load_amount = true;
if (v->cargo.Empty()) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
@ -1330,6 +1336,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
if (!anything_unloaded) delete payment;
ClrBit(u->vehicle_flags, VF_STOP_LOADING);
if (anything_loaded || anything_unloaded) {
if (_settings_game.order.gradual_loading) {
/* The time it takes to load one 'slice' of cargo or passengers depends
@ -1338,6 +1345,8 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
unloading_time = gradual_loading_wait_time[v->type];
}
/* We loaded less cargo than possible and it's not full load, stop loading. */
if (!anything_unloaded && !full_load_amount && !(v->current_order.GetLoadType() & OLFB_FULL_LOAD)) SetBit(u->vehicle_flags, VF_STOP_LOADING);
} else {
bool finished_loading = true;
if (v->current_order.GetLoadType() & OLFB_FULL_LOAD) {

View File

@ -40,6 +40,7 @@ enum VehicleFlags {
VF_TIMETABLE_STARTED, ///< Whether the vehicle has started running on the timetable yet.
VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically.
VF_AUTOFILL_PRES_WAIT_TIME, ///< Whether non-destructive auto-fill should preserve waiting times
VF_STOP_LOADING, ///< Don't load anymore during the next load cycle.
};
/** Cached oftenly queried (NewGRF) values */