diff options
-rw-r--r-- | src/ai/api/ai_engine.cpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_event_types.cpp | 2 | ||||
-rw-r--r-- | src/articulated_vehicles.cpp | 10 | ||||
-rw-r--r-- | src/articulated_vehicles.h | 2 | ||||
-rw-r--r-- | src/autoreplace_cmd.cpp | 4 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 4 | ||||
-rw-r--r-- | src/engine_gui.cpp | 4 |
7 files changed, 13 insertions, 15 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index b8be61069..8f5bf2167 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -70,7 +70,7 @@ switch (e->type) { case VEH_ROAD: case VEH_TRAIN: { - uint16 *capacities = GetCapacityOfArticulatedParts(engine_id, e->type); + CargoArray capacities = GetCapacityOfArticulatedParts(engine_id, e->type); 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 80607220d..0f757be18 100644 --- a/src/ai/api/ai_event_types.cpp +++ b/src/ai/api/ai_event_types.cpp @@ -35,7 +35,7 @@ int32 AIEventEnginePreview::GetCapacity() switch (e->type) { case VEH_ROAD: case VEH_TRAIN: { - uint16 *capacities = GetCapacityOfArticulatedParts(engine, e->type); + CargoArray capacities = GetCapacityOfArticulatedParts(engine, e->type); 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 15b4121d4..e325642f2 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -78,10 +78,9 @@ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType return cargos; } -uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type) +CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type) { - static uint16 capacity[NUM_CARGO]; - memset(capacity, 0, sizeof(capacity)); + CargoArray capacity; CargoID cargo_type; uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, type, &cargo_type); @@ -239,12 +238,11 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v) uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true); uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true); - uint16 *purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type); + CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type); uint32 real_refit_union = 0; uint32 real_refit_intersection = UINT_MAX; - uint16 real_default_capacity[NUM_CARGO]; - memset(real_default_capacity, 0, sizeof(real_default_capacity)); + CargoArray real_default_capacity; do { uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, v->type, true); diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h index 702473211..1d70ea09d 100644 --- a/src/articulated_vehicles.h +++ b/src/articulated_vehicles.h @@ -9,7 +9,7 @@ #include "engine_type.h" uint CountArticulatedParts(EngineID engine_type, bool purchase_window); -uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type); +CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type); void AddArticulatedParts(Vehicle *first, VehicleType type); uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type); uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type); diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 183284dac..e7fb28458 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -182,7 +182,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? */ - uint16 *default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type); + CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type); for (CargoID cid = 0; cid < NUM_CARGO; cid++) { if (cid != v->cargo_type && default_capacity[cid] > 0) return v->cargo_type; } @@ -198,7 +198,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? */ - uint16 *default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type); + CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->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 0a276dcb4..6eb77a645 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -414,9 +414,9 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = { static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, VehicleType type, bool refittable) { - uint16 *cap = GetCapacityOfArticulatedParts(engine, type); + CargoArray cap = GetCapacityOfArticulatedParts(engine, type); - for (uint c = 0; c < NUM_CARGO; c++) { + for (CargoID c = 0; c < NUM_CARGO; c++) { if (cap[c] == 0) continue; SetDParam(0, c); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 980268673..333f3b88c 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -139,8 +139,8 @@ uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type) { uint total = 0; - uint16 *cap = GetCapacityOfArticulatedParts(engine, type); - for (uint c = 0; c < NUM_CARGO; c++) { + CargoArray cap = GetCapacityOfArticulatedParts(engine, type); + for (CargoID c = 0; c < NUM_CARGO; c++) { total += cap[c]; } |