Use CargoID instead of CargoSpec in town_production_cargoes

pull/661/head
Jonathan G Rennison 2 months ago
parent 19e4895ffd
commit 6ab1f9a416

@ -24,7 +24,7 @@
#include "safeguards.h"
CargoSpec CargoSpec::array[NUM_CARGO];
std::array<std::vector<const CargoSpec *>, NUM_TPE> CargoSpec::town_production_cargoes{};
std::array<std::vector<CargoID>, NUM_TPE> CargoSpec::town_production_cargoes{};
std::array<CargoTypes, NUM_TPE> CargoSpec::town_production_cargo_mask{};
/**
@ -237,7 +237,7 @@ void InitializeSortedCargoSpecs()
uint8_t nb_standard_cargo = 0;
for (const auto &cargo : _sorted_cargo_specs) {
assert(cargo->town_production_effect != INVALID_TPE);
CargoSpec::town_production_cargoes[cargo->town_production_effect].push_back(cargo);
CargoSpec::town_production_cargoes[cargo->town_production_effect].push_back(cargo->Index());
SetBit(CargoSpec::town_production_cargo_mask[cargo->town_production_effect], cargo->Index());
if (cargo->classes & CC_SPECIAL) break;
nb_standard_cargo++;

@ -197,7 +197,7 @@ struct CargoSpec {
static IterateWrapper Iterate(size_t from = 0) { return IterateWrapper(from); }
/** List of cargo specs for each Town Product Effect. */
static std::array<std::vector<const CargoSpec *>, NUM_TPE> town_production_cargoes;
static std::array<std::vector<CargoID>, NUM_TPE> town_production_cargoes;
/** Mask of cargo IDs for each Town Product Effect. */
static std::array<CargoTypes, NUM_TPE> town_production_cargo_mask;

@ -595,8 +595,7 @@ public:
StringID str_last_period = EconTime::UsingWallclockUnits() ? STR_TOWN_VIEW_CARGO_LAST_MINUTE_MAX : STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX;
for (auto tpe : {TPE_PASSENGERS, TPE_MAIL}) {
for (const CargoSpec *cs : CargoSpec::town_production_cargoes[tpe]) {
CargoID cid = cs->Index();
for (CargoID cid : CargoSpec::town_production_cargoes[tpe]) {
SetDParam(0, 1ULL << cid);
SetDParam(1, this->town->supplied[cid].old_act);
SetDParam(2, this->town->supplied[cid].old_max);

Loading…
Cancel
Save