Changeset - r15817:d3b2c9fe7ab6
[Not reviewed]
master
0 2 0
michi_cc - 14 years ago 2010-08-15 22:37:30
michi_cc@openttd.org
(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.
2 files changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1161,6 +1161,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
	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
 
			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
 
			}
 

	
 
			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
 

	
 
	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
 

	
 
			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) {
src/vehicle_base.h
Show inline comments
 
@@ -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 */
0 comments (0 inline, 0 general)