summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-03 11:02:37 +0000
committerrubidium <rubidium@openttd.org>2007-05-03 11:02:37 +0000
commite11e91b02c04de8e5a83f39f020f74a47c94e0ea (patch)
tree58e22a3850350c61b45c4e7d5051888d7bfa8c18
parent15aaaf3c6f48f85a3332228d1597796bb8a626f7 (diff)
downloadopenttd-e11e91b02c04de8e5a83f39f020f74a47c94e0ea.tar.xz
(svn r9772) -Fix [r9770,FS#761]: under some circumstances loading/unloading didn't work (correctly).
-rw-r--r--src/vehicle.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 8920c4376..41cb04caa 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -743,27 +743,30 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
}
-bool CanFillVehicle(Vehicle *v)
+bool CanFillVehicle(Vehicle *front_v)
{
- TileIndex tile = v->tile;
+ TileIndex tile = front_v->tile;
- if (IsTileType(tile, MP_STATION) ||
- (v->type == VEH_SHIP && (
+ 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);
+ bool full_load = front_v->current_order.flags & OF_FULL_LOAD;
- do {
- if (v->cargo_count != v->cargo_cap) return true;
- } while ((v = v->next) != NULL);
- }
- return false;
+ /* 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