diff options
author | rubidium <rubidium@openttd.org> | 2007-05-06 14:59:01 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-05-06 14:59:01 +0000 |
commit | abbaa1691e1900870740b5878dd95b5bef7a0cf0 (patch) | |
tree | 1cb12a860a1d49d0f55ca151829a324e5d880a14 /src/vehicle.cpp | |
parent | cf927a97926001d8aba5f18116754b801cec353d (diff) | |
download | openttd-abbaa1691e1900870740b5878dd95b5bef7a0cf0.tar.xz |
(svn r9794) -Codechange: refactor the question whether a vehicle can be loaded into LoadUnloadVehicle instead of duplicating it for each vehicle.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 60896198c..f8c233184 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -701,73 +701,6 @@ void CallVehicleTicks() } } -static bool CanFillVehicle_FullLoadAny(Vehicle *v) -{ - uint32 full = 0, not_full = 0; - const GoodsEntry *ge = GetStation(v->last_station_visited)->goods; - - /* special handling of aircraft */ - - /* if the aircraft carries passengers and is NOT full, then - *continue loading, no matter how much mail is in */ - if (v->type == VEH_AIRCRAFT && - IsCargoInClass(v->cargo_type, CC_PASSENGERS) && - v->cargo_cap != v->cargo_count) { - return true; - } - - /* patch should return "true" to continue loading, i.e. when there is no cargo type that is fully loaded. */ - do { - /* Should never happen, but just in case future additions change this */ - assert(v->cargo_type<32); - - if (v->cargo_cap != 0) { - uint32 mask = 1 << v->cargo_type; - - if (!HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && v->cargo_cap == v->cargo_count) { - full |= mask; - } else if (GB(ge[v->cargo_type].waiting_acceptance, 0, 12) > 0 || - (HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) { - /* If there is any cargo waiting, or this vehicle is still unloading - * and the station accepts the cargo, don't leave the station. */ - return 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 not_full && (full & ~not_full) == 0; -} - - -bool CanFillVehicle(Vehicle *front_v) -{ - 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) - ))); - - bool full_load = HASBIT(front_v->current_order.flags, OFB_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 |