summaryrefslogtreecommitdiff
path: root/src
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
parent1e2dc255829ecf9dad6be4ef88cbc3646a3d4675 (diff)
downloadopenttd-9a9d0ee7c0234ed2ecec490f72746622926e8fe7.tar.xz
(svn r17728) -Cleanup: Remove some more unneeded/unused parameters.
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_engine.cpp2
-rw-r--r--src/ai/api/ai_event_types.cpp2
-rw-r--r--src/articulated_vehicles.cpp35
-rw-r--r--src/articulated_vehicles.h6
-rw-r--r--src/autoreplace_cmd.cpp20
-rw-r--r--src/build_vehicle_gui.cpp18
-rw-r--r--src/engine_func.h2
-rw-r--r--src/engine_gui.cpp8
-rw-r--r--src/vehicle_gui.cpp2
9 files changed, 48 insertions, 47 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index bdb96bf56..0be62af1f 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -75,7 +75,7 @@
switch (e->type) {
case VEH_ROAD:
case VEH_TRAIN: {
- CargoArray capacities = GetCapacityOfArticulatedParts(engine_id, e->type);
+ CargoArray capacities = GetCapacityOfArticulatedParts(engine_id);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (capacities[c] == 0) continue;
return capacities[c];
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp
index 2c2b8cb91..4e214431d 100644
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -41,7 +41,7 @@ int32 AIEventEnginePreview::GetCapacity()
switch (e->type) {
case VEH_ROAD:
case VEH_TRAIN: {
- CargoArray capacities = GetCapacityOfArticulatedParts(this->engine, e->type);
+ CargoArray capacities = GetCapacityOfArticulatedParts(this->engine);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (capacities[c] == 0) continue;
return capacities[c];
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;
diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h
index a404cd2e6..37426b8b4 100644
--- a/src/articulated_vehicles.h
+++ b/src/articulated_vehicles.h
@@ -16,10 +16,10 @@
#include "engine_type.h"
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
-CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
+CargoArray GetCapacityOfArticulatedParts(EngineID engine);
void AddArticulatedParts(Vehicle *first);
-uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
-uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
+uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
+uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type);
bool IsArticulatedVehicleRefittable(EngineID engine);
void CheckConsistencyOfArticulatedVehicle(const Vehicle *v);
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 2c3f973f8..ededb4cd6 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -33,10 +33,10 @@ extern void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index);
* @param type the type of the engines
* @return true if they can both carry the same type of cargo (or at least one of them got no capacity at all)
*/
-static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b, VehicleType type)
+static bool EnginesHaveCargoInCommon(EngineID engine_a, EngineID engine_b)
{
- uint32 available_cargos_a = GetUnionOfArticulatedRefitMasks(engine_a, type, true);
- uint32 available_cargos_b = GetUnionOfArticulatedRefitMasks(engine_b, type, true);
+ uint32 available_cargos_a = GetUnionOfArticulatedRefitMasks(engine_a, true);
+ uint32 available_cargos_b = GetUnionOfArticulatedRefitMasks(engine_b, true);
return (available_cargos_a == 0 || available_cargos_b == 0 || (available_cargos_a & available_cargos_b) != 0);
}
@@ -87,7 +87,7 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
}
/* the engines needs to be able to carry the same cargo */
- return EnginesGotCargoInCommon(from, to, type);
+ return EnginesHaveCargoInCommon(from, to);
}
/** Transfer cargo from a single (articulated )old vehicle to the new vehicle chain
@@ -138,8 +138,8 @@ static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, EngineID engine_ty
const Order *o;
const Vehicle *u;
- uint32 union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, false);
- uint32 union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, v->type, false);
+ uint32 union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, false);
+ uint32 union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, false);
if (v->type == VEH_TRAIN) {
u = v->First();
@@ -171,11 +171,11 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
{
CargoID cargo_type;
- if (GetUnionOfArticulatedRefitMasks(engine_type, v->type, true) == 0) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
+ if (GetUnionOfArticulatedRefitMasks(engine_type, true) == 0) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
if (IsArticulatedVehicleCarryingDifferentCargos(v, &cargo_type)) return CT_INVALID; // We cannot refit to mixed cargos in an automated way
- uint32 available_cargo_types = GetIntersectionOfArticulatedRefitMasks(engine_type, v->type, true);
+ uint32 available_cargo_types = GetIntersectionOfArticulatedRefitMasks(engine_type, true);
if (cargo_type == CT_INVALID) {
if (v->type != VEH_TRAIN) return CT_NO_REFIT; // If the vehicle does not carry anything at all, every replacement is fine.
@@ -190,7 +190,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
if (HasBit(available_cargo_types, v->cargo_type)) {
/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
- CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
+ CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type);
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (cid != v->cargo_type && default_capacity[cid] > 0) return v->cargo_type;
}
@@ -206,7 +206,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return CT_INVALID; // Some refit orders lose their effect
/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
- CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
+ CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type);
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (cid != cargo_type && default_capacity[cid] > 0) return cargo_type;
}
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 34d432011..2f6a5771c 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -239,8 +239,8 @@ static int CDECL TrainEngineCapacitySorter(const EngineID *a, const EngineID *b)
const RailVehicleInfo *rvi_a = RailVehInfo(*a);
const RailVehicleInfo *rvi_b = RailVehInfo(*b);
- int va = GetTotalCapacityOfArticulatedParts(*a, VEH_TRAIN) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
- int vb = GetTotalCapacityOfArticulatedParts(*b, VEH_TRAIN) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+ int va = GetTotalCapacityOfArticulatedParts(*a) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+ int vb = GetTotalCapacityOfArticulatedParts(*b) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int r = va - vb;
/* Use EngineID to sort instead since we want consistent sorting */
@@ -262,8 +262,8 @@ static int CDECL TrainEnginesThenWagonsSorter(const EngineID *a, const EngineID
/* Road vehicle sorting functions */
static int CDECL RoadVehEngineCapacitySorter(const EngineID *a, const EngineID *b)
{
- int va = GetTotalCapacityOfArticulatedParts(*a, VEH_ROAD);
- int vb = GetTotalCapacityOfArticulatedParts(*b, VEH_ROAD);
+ int va = GetTotalCapacityOfArticulatedParts(*a);
+ int vb = GetTotalCapacityOfArticulatedParts(*b);
int r = va - vb;
/* Use EngineID to sort instead since we want consistent sorting */
@@ -406,7 +406,7 @@ static const StringID _sort_listing[][11] = {{
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
{
if (cid == CF_ANY) return true;
- uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, Engine::Get(*eid)->type, true);
+ uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true);
return (cid == CF_NONE ? refit_mask == 0 : HasBit(refit_mask, cid));
}
@@ -414,9 +414,9 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = {
&CargoFilter,
};
-static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, VehicleType type, bool refittable)
+static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, bool refittable)
{
- CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
+ CargoArray cap = GetCapacityOfArticulatedParts(engine);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (cap[c] == 0) continue;
@@ -640,7 +640,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
}
/* Cargo type + capacity, or N/A */
- int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, VEH_TRAIN, refittable);
+ int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
if (new_y == y) {
SetDParam(0, CT_INVALID);
@@ -656,7 +656,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
y = DrawRoadVehPurchaseInfo(left, right, y, engine_number);
/* Cargo type + capacity, or N/A */
- int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, VEH_ROAD, refittable);
+ int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
if (new_y == y) {
SetDParam(0, CT_INVALID);
diff --git a/src/engine_func.h b/src/engine_func.h
index 63bf10444..3402576d5 100644
--- a/src/engine_func.h
+++ b/src/engine_func.h
@@ -32,6 +32,6 @@ void SetCachedEngineCounts();
void SetYearEngineAgingStops();
void StartupOneEngine(Engine *e, Date aging_date);
-uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type);
+uint GetTotalCapacityOfArticulatedParts(EngineID engine);
#endif /* ENGINE_H */
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 43125c4d4..38a4dfa8e 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -122,11 +122,11 @@ void ShowEnginePreviewWindow(EngineID engine)
AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
}
-uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type)
+uint GetTotalCapacityOfArticulatedParts(EngineID engine)
{
uint total = 0;
- CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
+ CargoArray cap = GetCapacityOfArticulatedParts(engine);
for (CargoID c = 0; c < NUM_CARGO; c++) {
total += cap[c];
}
@@ -143,7 +143,7 @@ static StringID GetTrainEngineInfoString(const Engine *e)
SetDParam(4, e->GetRunningCost());
- uint capacity = GetTotalCapacityOfArticulatedParts(e->index, VEH_TRAIN);
+ uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
if (capacity != 0) {
SetDParam(5, e->GetDefaultCargoType());
SetDParam(6, capacity);
@@ -180,7 +180,7 @@ static StringID GetRoadVehEngineInfoString(const Engine *e)
{
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayMaxSpeed());
- uint capacity = GetTotalCapacityOfArticulatedParts(e->index, VEH_ROAD);
+ uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
if (capacity != 0) {
SetDParam(2, e->GetDefaultCargoType());
SetDParam(3, capacity);
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index fc1e4abb3..4af37ff2c 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -447,7 +447,7 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *pare
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
{
/* List of cargo types of this engine */
- uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, Engine::Get(engine)->type, false);
+ uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, false);
/* List of cargo types available in this climate */
uint32 lmask = _cargo_mask;
char string[512];