Changeset - r11221:3f9e56376a1e
[Not reviewed]
master
0 1 0
rubidium - 16 years ago 2009-02-25 00:12:57
rubidium@openttd.org
(svn r15574) -Fix [FS#2680]: force unload not working when trying to force unload at the station where you received the cargo
1 file changed with 12 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1580,25 +1580,34 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
		GoodsEntry *ge = &st->goods[v->cargo_type];
 

	
 
		if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (u->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
			uint cargo_count = v->cargo.Count();
 
			uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
 
			bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
 
			bool accepted  = false; // Is the cargo accepted by the station?
 

	
 
			if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) {
 
				/* The cargo has reached it's final destination, the packets may now be destroyed */
 
				remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, last_visited);
 

	
 
				result |= 1;
 
			} else if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) {
 
				accepted = true;
 
			}
 

	
 
			/* The !accepted || v->cargo.Count == cargo_count clause is there
 
			 * to make it possible to force unload vehicles at the station where
 
			 * they were loaded, but to not force unload the vehicle when the
 
			 * station is still accepting the cargo in the vehicle. It doesn't
 
			 * accept cargo that was loaded at the same station. */
 
			if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER) && (!accepted || v->cargo.Count() == cargo_count)) {
 
				remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded);
 
				SetBit(ge->acceptance_pickup, GoodsEntry::PICKUP);
 

	
 
				result |= 2;
 
			} else {
 
			} else if (!accepted) {
 
				/* The order changed while unloading (unset unload/transfer) or the
 
				 * station does not accept goods anymore. */
 
				ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 
				continue;
 
			}
 

	
0 comments (0 inline, 0 general)