# HG changeset patch # User rubidium # Date 1178190157 0 # Node ID f8b804793df0a842700fc7ecb1ed9025e7f3c4a7 # Parent 383e83c8d51957c14b7b06d1fbe3ba762c5f4074 (svn r9772) -Fix [r9770,FS#761]: under some circumstances loading/unloading didn't work (correctly). diff -r 383e83c8d519 -r f8b804793df0 src/vehicle.cpp --- a/src/vehicle.cpp Wed May 02 19:00:59 2007 +0000 +++ b/src/vehicle.cpp Thu May 03 11:02:37 2007 +0000 @@ -743,27 +743,30 @@ } -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