summaryrefslogtreecommitdiff
path: root/src/articulated_vehicles.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-06 19:52:38 +0000
committerfrosch <frosch@openttd.org>2009-10-06 19:52:38 +0000
commit9a9d0ee7c0234ed2ecec490f72746622926e8fe7 (patch)
treef9d050353f4b07db288a61cec9568cb002b95c9e /src/articulated_vehicles.cpp
parent1e2dc255829ecf9dad6be4ef88cbc3646a3d4675 (diff)
downloadopenttd-9a9d0ee7c0234ed2ecec490f72746622926e8fe7.tar.xz
(svn r17728) -Cleanup: Remove some more unneeded/unused parameters.
Diffstat (limited to 'src/articulated_vehicles.cpp')
-rw-r--r--src/articulated_vehicles.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 7481b2524..9ed1ab9c3 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -81,23 +81,24 @@ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include
return cargos;
}
-CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
+CargoArray GetCapacityOfArticulatedParts(EngineID engine)
{
CargoArray capacity;
+ const Engine *e = Engine::Get(engine);
CargoID cargo_type;
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
- if (type != VEH_TRAIN && type != VEH_ROAD) return capacity;
+ if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return capacity;
- if (!HasBit(EngInfo(engine)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
+ if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
- EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
+ EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
@@ -134,23 +135,23 @@ bool IsArticulatedVehicleRefittable(EngineID engine)
/**
* Ors the refit_masks of all articulated parts.
* @param engine the first part
- * @param type the vehicle type
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
* @return bit mask of CargoIDs which are a refit option for at least one articulated part
*/
-uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
+uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
{
+ const Engine *e = Engine::Get(engine);
uint32 cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
- if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
+ if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return cargos;
- if (!HasBit(EngInfo(engine)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
+ if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
- EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
+ EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
cargos |= GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
}
@@ -160,26 +161,26 @@ uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool i
/**
* Ands the refit_masks of all articulated parts.
* @param engine the first part
- * @param type the vehicle type
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
* @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0)
*/
-uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
+uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
{
+ const Engine *e = Engine::Get(engine);
uint32 cargos = UINT32_MAX;
uint32 veh_cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
if (veh_cargos != 0) cargos &= veh_cargos;
- if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
+ if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return cargos;
- if (!HasBit(EngInfo(engine)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
+ if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
- EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
+ EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
if (veh_cargos != 0) cargos &= veh_cargos;
}
@@ -239,9 +240,9 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
{
const Engine *engine = Engine::Get(v->engine_type);
- uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
- uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true);
- CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type);
+ uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, true);
+ uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, true);
+ CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type);
uint32 real_refit_union = 0;
uint32 real_refit_intersection = UINT_MAX;