Changeset - r6567:09ee93303b9f
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-05-03 11:02:37
rubidium@openttd.org
(svn r9772) -Fix [r9770,FS#761]: under some circumstances loading/unloading didn't work (correctly).
1 file changed with 18 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -734,45 +734,48 @@ static bool CanFillVehicle_FullLoadAny(V
 
				keep_loading = true;
 
			} else {
 
				not_full |= mask;
 
			}
 
		}
 
	} while ((v = v->next) != NULL);
 

	
 
	/* continue loading if there is a non full cargo type and no cargo type that is full */
 
	return keep_loading || (not_full && (full & ~not_full) == 0);
 
}
 

	
 

	
 
bool CanFillVehicle(Vehicle *v)
 
bool CanFillVehicle(Vehicle *front_v)
 
{
 
	TileIndex tile = v->tile;
 

	
 
	if (IsTileType(tile, MP_STATION) ||
 
			(v->type == VEH_SHIP && (
 
	TileIndex tile = front_v->tile;
 

	
 
	assert(IsTileType(tile, MP_STATION) ||
 
			(front_v->type == VEH_SHIP && (
 
				IsTileType(TILE_ADDXY(tile,  1,  0), MP_STATION) ||
 
				IsTileType(TILE_ADDXY(tile, -1,  0), MP_STATION) ||
 
				IsTileType(TILE_ADDXY(tile,  0,  1), MP_STATION) ||
 
				IsTileType(TILE_ADDXY(tile,  0, -1), MP_STATION) ||
 
				IsTileType(TILE_ADDXY(tile, -2,  0), MP_STATION)
 
			))) {
 

	
 
		/* If patch is active, use alternative CanFillVehicle-function */
 
		if (_patches.full_load_any && v->current_order.flags & OF_FULL_LOAD) return CanFillVehicle_FullLoadAny(v);
 

	
 
		do {
 
			if (v->cargo_count != v->cargo_cap) return true;
 
		} while ((v = v->next) != NULL);
 
	}
 
	return false;
 
			)));
 

	
 
	bool full_load = front_v->current_order.flags & OF_FULL_LOAD;
 

	
 
	/* If patch is active, use alternative CanFillVehicle-function */
 
	if (_patches.full_load_any && full_load) return CanFillVehicle_FullLoadAny(front_v);
 

	
 
	Vehicle *v = front_v;
 
	do {
 
		if (HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) || (full_load && v->cargo_count != v->cargo_cap)) return true;
 
	} while ((v = v->next) != NULL);
 

	
 
	return !HASBIT(front_v->vehicle_flags, VF_LOADING_FINISHED);
 
}
 

	
 
/** Check if a given engine type can be refitted to a given cargo
 
 * @param engine_type Engine type to check
 
 * @param cid_to check refit to this cargo-type
 
 * @return true if it is possible, false otherwise
 
 */
 
bool CanRefitTo(EngineID engine_type, CargoID cid_to)
 
{
 
	return HASBIT(EngInfo(engine_type)->refit_mask, cid_to);
 
}
 

	
0 comments (0 inline, 0 general)