Use std::array for industry/industry spec input/output arrays

wip-string
Jonathan G Rennison 6 months ago
parent 03e0ec8276
commit 61d65c9861

@ -61,21 +61,21 @@ DECLARE_ENUM_AS_BIT_SET(IndustryControlFlags);
* Defines the internal data of a functional industry.
*/
struct Industry : IndustryPool::PoolItem<&_industry_pool> {
TileArea location; ///< Location of the industry
Town *town; ///< Nearest town
Station *neutral_station; ///< Associated neutral station
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS]; ///< 16 production cargo slots
uint16 produced_cargo_waiting[INDUSTRY_NUM_OUTPUTS]; ///< amount of cargo produced per cargo
uint16 incoming_cargo_waiting[INDUSTRY_NUM_INPUTS]; ///< incoming cargo waiting to be processed
byte production_rate[INDUSTRY_NUM_OUTPUTS]; ///< production rate for each cargo
byte prod_level; ///< general production level
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]; ///< 16 input cargo slots
uint16 this_month_production[INDUSTRY_NUM_OUTPUTS]; ///< stats of this month's production per cargo
uint16 this_month_transported[INDUSTRY_NUM_OUTPUTS]; ///< stats of this month's transport per cargo
byte last_month_pct_transported[INDUSTRY_NUM_OUTPUTS]; ///< percentage transported per cargo in the last full month
uint16 last_month_production[INDUSTRY_NUM_OUTPUTS]; ///< total units produced per cargo in the last full month
uint16 last_month_transported[INDUSTRY_NUM_OUTPUTS]; ///< total units transported per cargo in the last full month
TileArea location; ///< Location of the industry
Town *town; ///< Nearest town
Station *neutral_station; ///< Associated neutral station
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo{};
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo{}; ///< 16 production cargo slots
std::array<uint16, INDUSTRY_NUM_OUTPUTS> produced_cargo_waiting{}; ///< amount of cargo produced per cargo
std::array<uint16, INDUSTRY_NUM_OUTPUTS> incoming_cargo_waiting{}; ///< incoming cargo waiting to be processed
std::array<byte, INDUSTRY_NUM_OUTPUTS> production_rate{}; ///< production rate for each cargo
std::array<uint16, INDUSTRY_NUM_OUTPUTS> this_month_production{}; ///< stats of this month's production per cargo
std::array<uint16, INDUSTRY_NUM_OUTPUTS> this_month_transported{}; ///< stats of this month's transport per cargo
std::array<byte, INDUSTRY_NUM_OUTPUTS> last_month_pct_transported{}; ///< percentage transported per cargo in the last full month
std::array<uint16, INDUSTRY_NUM_OUTPUTS> last_month_production{}; ///< total units produced per cargo in the last full month
std::array<uint16, INDUSTRY_NUM_OUTPUTS> last_month_transported{}; ///< total units transported per cargo in the last full month
uint16 counter; ///< used for animation and/or production (if available cargo)
byte prod_level; ///< general production level
IndustryType type; ///< type of industry.
Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE
@ -119,17 +119,17 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
inline int GetCargoProducedIndex(CargoID cargo) const
{
if (cargo == CT_INVALID) return -1;
const CargoID *pos = std::find(this->produced_cargo, endof(this->produced_cargo), cargo);
if (pos == endof(this->produced_cargo)) return -1;
return pos - this->produced_cargo;
auto pos = std::find(this->produced_cargo.begin(), this->produced_cargo.end(), cargo);
if (pos == this->produced_cargo.end()) return -1;
return pos - this->produced_cargo.begin();
}
inline int GetCargoAcceptedIndex(CargoID cargo) const
{
if (cargo == CT_INVALID) return -1;
const CargoID *pos = std::find(this->accepts_cargo, endof(this->accepts_cargo), cargo);
if (pos == endof(this->accepts_cargo)) return -1;
return pos - this->accepts_cargo;
auto pos = std::find(this->accepts_cargo.begin(), this->accepts_cargo.end(), cargo);
if (pos == this->accepts_cargo.end()) return -1;
return pos - this->accepts_cargo.begin();
}
/**

@ -420,7 +420,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca
if (itspec->special_flags & INDTILE_SPECIAL_ACCEPTS_ALL_CARGO) {
/* Copy all accepted cargoes from industry itself */
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
for (size_t i = 0; i < ind->accepts_cargo.size(); i++) {
auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), ind->accepts_cargo[i]);
if (pos == std::end(accepts_cargo)) {
/* Not found, insert */
@ -1833,17 +1833,9 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
i->type = type;
Industry::IncIndustryTypeCount(type);
MemCpyT(i->produced_cargo, indspec->produced_cargo, lengthof(i->produced_cargo));
MemCpyT(i->production_rate, indspec->production_rate, lengthof(i->production_rate));
MemCpyT(i->accepts_cargo, indspec->accepts_cargo, lengthof(i->accepts_cargo));
MemSetT(i->produced_cargo_waiting, 0, lengthof(i->produced_cargo_waiting));
MemSetT(i->this_month_production, 0, lengthof(i->this_month_production));
MemSetT(i->this_month_transported, 0, lengthof(i->this_month_transported));
MemSetT(i->last_month_pct_transported, 0, lengthof(i->last_month_pct_transported));
MemSetT(i->last_month_transported, 0, lengthof(i->last_month_transported));
MemSetT(i->incoming_cargo_waiting, 0, lengthof(i->incoming_cargo_waiting));
MemSetT(i->last_cargo_accepted_at, 0, lengthof(i->last_cargo_accepted_at));
i->produced_cargo = indspec->produced_cargo;
i->production_rate = indspec->production_rate;
i->accepts_cargo = indspec->accepts_cargo;
/* Randomize inital production if non-original economy is used and there are no production related callbacks. */
if (!indspec->UsesOriginalEconomy()) {
@ -1916,7 +1908,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) {
/* Clear all input cargo types */
for (uint j = 0; j < lengthof(i->accepts_cargo); j++) i->accepts_cargo[j] = CT_INVALID;
for (size_t j = 0; j < i->accepts_cargo.size(); j++) i->accepts_cargo[j] = CT_INVALID;
/* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? lengthof(i->accepts_cargo) : 3;
for (uint j = 0; j < maxcargoes; j++) {
@ -1932,12 +1924,12 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
* and solve this by returning undefined cargo indexes. Skip these. */
if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
/* Verify valid cargo */
if (std::find(indspec->accepts_cargo, endof(indspec->accepts_cargo), cargo) == endof(indspec->accepts_cargo)) {
if (std::find(indspec->accepts_cargo.begin(), indspec->accepts_cargo.end(), cargo) == indspec->accepts_cargo.end()) {
/* Cargo not in spec, error in NewGRF */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res);
break;
}
if (std::find(i->accepts_cargo, i->accepts_cargo + j, cargo) != i->accepts_cargo + j) {
if (std::find(i->accepts_cargo.begin(), i->accepts_cargo.begin() + j, cargo) != i->accepts_cargo.begin() + j) {
/* Duplicate cargo */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res);
break;
@ -1948,7 +1940,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
if (HasBit(indspec->callback_mask, CBM_IND_OUTPUT_CARGO_TYPES)) {
/* Clear all output cargo types */
for (uint j = 0; j < lengthof(i->produced_cargo); j++) i->produced_cargo[j] = CT_INVALID;
for (size_t j = 0; j < i->produced_cargo.size(); j++) i->produced_cargo[j] = CT_INVALID;
/* Query actual types */
uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? lengthof(i->produced_cargo) : 2;
for (uint j = 0; j < maxcargoes; j++) {
@ -1962,12 +1954,12 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
/* Allow older GRFs to skip slots. */
if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
/* Verify valid cargo */
if (std::find(indspec->produced_cargo, endof(indspec->produced_cargo), cargo) == endof(indspec->produced_cargo)) {
if (std::find(indspec->produced_cargo.begin(), indspec->produced_cargo.end(), cargo) == indspec->produced_cargo.end()) {
/* Cargo not in spec, error in NewGRF */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res);
break;
}
if (std::find(i->produced_cargo, i->produced_cargo + j, cargo) != i->produced_cargo + j) {
if (std::find(i->produced_cargo.begin(), i->produced_cargo.begin() + j, cargo) != i->produced_cargo.begin() + j) {
/* Duplicate cargo */
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res);
break;

@ -367,18 +367,18 @@ class BuildIndustryWindow : public Window {
* @param prefixstr String to use for the first item
* @return A formatted raw string
*/
std::string MakeCargoListString(const CargoID *cargolist, const CargoSuffix *cargo_suffix, int cargolistlen, StringID prefixstr) const
std::string MakeCargoListString(const CargoID *cargolist, const CargoSuffix *cargo_suffix, size_t cargolistlen, StringID prefixstr) const
{
std::string cargostring;
char buf[1024];
int numcargo = 0;
int firstcargo = -1;
for (int j = 0; j < cargolistlen; j++) {
for (size_t j = 0; j < cargolistlen; j++) {
if (cargolist[j] == CT_INVALID) continue;
numcargo++;
if (firstcargo < 0) {
firstcargo = j;
firstcargo = (int)j;
continue;
}
SetDParam(0, CargoSpec::Get(cargolist[j])->name);
@ -459,7 +459,7 @@ public:
/* Measure the accepted cargoes, if any. */
GetAllCargoSuffixes(CARGOSUFFIX_IN, CST_FUND, nullptr, indtype, indsp, indsp->accepts_cargo, cargo_suffix);
std::string cargostring = this->MakeCargoListString(indsp->accepts_cargo, cargo_suffix, lengthof(indsp->accepts_cargo), STR_INDUSTRY_VIEW_REQUIRES_N_CARGO);
std::string cargostring = this->MakeCargoListString(indsp->accepts_cargo.data(), cargo_suffix, indsp->accepts_cargo.size(), STR_INDUSTRY_VIEW_REQUIRES_N_CARGO);
Dimension strdim = GetStringBoundingBox(cargostring);
if (strdim.width > max_minwidth) {
extra_lines_req = std::max(extra_lines_req, strdim.width / max_minwidth + 1);
@ -469,7 +469,7 @@ public:
/* Measure the produced cargoes, if any. */
GetAllCargoSuffixes(CARGOSUFFIX_OUT, CST_FUND, nullptr, indtype, indsp, indsp->produced_cargo, cargo_suffix);
cargostring = this->MakeCargoListString(indsp->produced_cargo, cargo_suffix, lengthof(indsp->produced_cargo), STR_INDUSTRY_VIEW_PRODUCES_N_CARGO);
cargostring = this->MakeCargoListString(indsp->produced_cargo.data(), cargo_suffix, indsp->produced_cargo.size(), STR_INDUSTRY_VIEW_PRODUCES_N_CARGO);
strdim = GetStringBoundingBox(cargostring);
if (strdim.width > max_minwidth) {
extra_lines_prd = std::max(extra_lines_prd, strdim.width / max_minwidth + 1);
@ -574,12 +574,12 @@ public:
/* Draw the accepted cargoes, if any. Otherwise, will print "Nothing". */
GetAllCargoSuffixes(CARGOSUFFIX_IN, CST_FUND, nullptr, this->selected_type, indsp, indsp->accepts_cargo, cargo_suffix);
std::string cargostring = this->MakeCargoListString(indsp->accepts_cargo, cargo_suffix, lengthof(indsp->accepts_cargo), STR_INDUSTRY_VIEW_REQUIRES_N_CARGO);
std::string cargostring = this->MakeCargoListString(indsp->accepts_cargo.data(), cargo_suffix, indsp->accepts_cargo.size(), STR_INDUSTRY_VIEW_REQUIRES_N_CARGO);
ir.top = DrawStringMultiLine(ir, cargostring);
/* Draw the produced cargoes, if any. Otherwise, will print "Nothing". */
GetAllCargoSuffixes(CARGOSUFFIX_OUT, CST_FUND, nullptr, this->selected_type, indsp, indsp->produced_cargo, cargo_suffix);
cargostring = this->MakeCargoListString(indsp->produced_cargo, cargo_suffix, lengthof(indsp->produced_cargo), STR_INDUSTRY_VIEW_PRODUCES_N_CARGO);
cargostring = this->MakeCargoListString(indsp->produced_cargo.data(), cargo_suffix, indsp->produced_cargo.size(), STR_INDUSTRY_VIEW_PRODUCES_N_CARGO);
ir.top = DrawStringMultiLine(ir, cargostring);
/* Get the additional purchase info text, if it has not already been queried. */
@ -2077,11 +2077,11 @@ struct CargoesField {
* @param bottom_end This is the last cargo field of this column.
* @note #supp_cargoes and #cust_cargoes should be filled in later.
*/
void MakeCargo(const CargoID *cargoes, uint length, int count = -1, bool top_end = false, bool bottom_end = false)
void MakeCargo(const CargoID *cargoes, size_t length, int count = -1, bool top_end = false, bool bottom_end = false)
{
this->type = CFT_CARGO;
auto insert = std::begin(this->u.cargo.vertical_cargoes);
for (uint i = 0; insert != std::end(this->u.cargo.vertical_cargoes) && i < length; i++) {
for (size_t i = 0; insert != std::end(this->u.cargo.vertical_cargoes) && i < length; i++) {
if (cargoes[i] != CT_INVALID) {
*insert = cargoes[i];
++insert;
@ -2592,8 +2592,8 @@ struct IndustryCargoesWindow : public Window {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (!indsp->enabled) continue;
this->ind_textsize = maxdim(this->ind_textsize, GetStringBoundingBox(indsp->name));
CargoesField::max_cargoes = std::max<uint>(CargoesField::max_cargoes, std::count_if(indsp->accepts_cargo, endof(indsp->accepts_cargo), IsValidCargoID));
CargoesField::max_cargoes = std::max<uint>(CargoesField::max_cargoes, std::count_if(indsp->produced_cargo, endof(indsp->produced_cargo), IsValidCargoID));
CargoesField::max_cargoes = std::max<uint>(CargoesField::max_cargoes, std::count_if(indsp->accepts_cargo.begin(), indsp->accepts_cargo.end(), IsValidCargoID));
CargoesField::max_cargoes = std::max<uint>(CargoesField::max_cargoes, std::count_if(indsp->produced_cargo.begin(), indsp->produced_cargo.end(), IsValidCargoID));
}
d.width = std::max(d.width, this->ind_textsize.width);
d.height = this->ind_textsize.height;
@ -2663,11 +2663,11 @@ struct IndustryCargoesWindow : public Window {
* @param length2 Number of cargoes in the second cargo array.
* @return Arrays have at least one valid cargo in common.
*/
static bool HasCommonValidCargo(const CargoID *cargoes1, uint length1, const CargoID *cargoes2, uint length2)
static bool HasCommonValidCargo(const CargoID *cargoes1, size_t length1, const CargoID *cargoes2, size_t length2)
{
while (length1 > 0) {
if (*cargoes1 != CT_INVALID) {
for (uint i = 0; i < length2; i++) if (*cargoes1 == cargoes2[i]) return true;
for (size_t i = 0; i < length2; i++) if (*cargoes1 == cargoes2[i]) return true;
}
cargoes1++;
length1--;
@ -2681,9 +2681,9 @@ struct IndustryCargoesWindow : public Window {
* @param length Number of cargoes in the array.
* @return Houses can supply at least one of the cargoes.
*/
static bool HousesCanSupply(const CargoID *cargoes, uint length)
static bool HousesCanSupply(const CargoID *cargoes, size_t length)
{
for (uint i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
if (cargoes[i] == CT_INVALID) continue;
if (cargoes[i] == CT_PASSENGERS || cargoes[i] == CT_MAIL) return true;
}
@ -2696,7 +2696,7 @@ struct IndustryCargoesWindow : public Window {
* @param length Number of cargoes in the array.
* @return Houses can accept at least one of the cargoes.
*/
static bool HousesCanAccept(const CargoID *cargoes, uint length)
static bool HousesCanAccept(const CargoID *cargoes, size_t length)
{
HouseZones climate_mask;
switch (_settings_game.game_creation.landscape) {
@ -2706,7 +2706,7 @@ struct IndustryCargoesWindow : public Window {
case LT_TOYLAND: climate_mask = HZ_TOYLND; break;
default: NOT_REACHED();
}
for (uint i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
if (cargoes[i] == CT_INVALID) continue;
for (uint h = 0; h < NUM_HOUSES; h++) {
@ -2727,14 +2727,14 @@ struct IndustryCargoesWindow : public Window {
* @param length Number of cargoes in \a cargoes.
* @return Number of industries that have an accepted cargo in common with the supplied set.
*/
static int CountMatchingAcceptingIndustries(const CargoID *cargoes, uint length)
static int CountMatchingAcceptingIndustries(const CargoID *cargoes, size_t length)
{
int count = 0;
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (!indsp->enabled) continue;
if (HasCommonValidCargo(cargoes, length, indsp->accepts_cargo, lengthof(indsp->accepts_cargo))) count++;
if (HasCommonValidCargo(cargoes, length, indsp->accepts_cargo.data(), indsp->accepts_cargo.size())) count++;
}
return count;
}
@ -2745,14 +2745,14 @@ struct IndustryCargoesWindow : public Window {
* @param length Number of cargoes in \a cargoes.
* @return Number of industries that have a produced cargo in common with the supplied set.
*/
static int CountMatchingProducingIndustries(const CargoID *cargoes, uint length)
static int CountMatchingProducingIndustries(const CargoID *cargoes, size_t length)
{
int count = 0;
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (!indsp->enabled) continue;
if (HasCommonValidCargo(cargoes, length, indsp->produced_cargo, lengthof(indsp->produced_cargo))) count++;
if (HasCommonValidCargo(cargoes, length, indsp->produced_cargo.data(), indsp->produced_cargo.size())) count++;
}
return count;
}
@ -2829,18 +2829,18 @@ struct IndustryCargoesWindow : public Window {
first_row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
const IndustrySpec *central_sp = GetIndustrySpec(displayed_it);
bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
bool houses_accept = HousesCanAccept(central_sp->produced_cargo, lengthof(central_sp->produced_cargo));
bool houses_supply = HousesCanSupply(central_sp->accepts_cargo.data(), central_sp->accepts_cargo.size());
bool houses_accept = HousesCanAccept(central_sp->produced_cargo.data(), central_sp->produced_cargo.size());
/* Make a field consisting of two cargo columns. */
int num_supp = CountMatchingProducingIndustries(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)) + houses_supply;
int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)) + houses_accept;
int num_supp = CountMatchingProducingIndustries(central_sp->accepts_cargo.data(), central_sp->accepts_cargo.size()) + houses_supply;
int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo.data(), central_sp->produced_cargo.size()) + houses_accept;
int num_indrows = std::max(3, std::max(num_supp, num_cust)); // One is needed for the 'it' industry, and 2 for the cargo labels.
for (int i = 0; i < num_indrows; i++) {
CargoesRow &row = this->fields.emplace_back();
row.columns[0].MakeEmpty(CFT_EMPTY);
row.columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
row.columns[1].MakeCargo(central_sp->accepts_cargo.data(), central_sp->accepts_cargo.size());
row.columns[2].MakeEmpty(CFT_EMPTY);
row.columns[3].MakeCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo));
row.columns[3].MakeCargo(central_sp->produced_cargo.data(), central_sp->produced_cargo.size());
row.columns[4].MakeEmpty(CFT_EMPTY);
}
/* Add central industry. */
@ -2860,13 +2860,13 @@ struct IndustryCargoesWindow : public Window {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (!indsp->enabled) continue;
if (HasCommonValidCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo), indsp->produced_cargo, lengthof(indsp->produced_cargo))) {
if (HasCommonValidCargo(central_sp->accepts_cargo.data(), central_sp->accepts_cargo.size(), indsp->produced_cargo.data(), indsp->produced_cargo.size())) {
this->PlaceIndustry(1 + supp_count * num_indrows / num_supp, 0, it);
_displayed_industries.set(it);
_displayed_industries_in.set(it);
supp_count++;
}
if (HasCommonValidCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo), indsp->accepts_cargo, lengthof(indsp->accepts_cargo))) {
if (HasCommonValidCargo(central_sp->produced_cargo.data(), central_sp->produced_cargo.size(), indsp->accepts_cargo.data(), indsp->accepts_cargo.size())) {
this->PlaceIndustry(1 + cust_count * num_indrows / num_cust, 4, it);
_displayed_industries.set(it);
_displayed_industries_out.set(it);
@ -2932,13 +2932,13 @@ struct IndustryCargoesWindow : public Window {
const IndustrySpec *indsp = GetIndustrySpec(it);
if (!indsp->enabled) continue;
if (HasCommonValidCargo(&cid, 1, indsp->produced_cargo, lengthof(indsp->produced_cargo))) {
if (HasCommonValidCargo(&cid, 1, indsp->produced_cargo.data(), indsp->produced_cargo.size())) {
this->PlaceIndustry(1 + supp_count * num_indrows / num_supp, 0, it);
_displayed_industries.set(it);
_displayed_industries_in.set(it);
supp_count++;
}
if (HasCommonValidCargo(&cid, 1, indsp->accepts_cargo, lengthof(indsp->accepts_cargo))) {
if (HasCommonValidCargo(&cid, 1, indsp->accepts_cargo.data(), indsp->accepts_cargo.size())) {
this->PlaceIndustry(1 + cust_count * num_indrows / num_cust, 2, it);
_displayed_industries.set(it);
_displayed_industries_out.set(it);

@ -112,14 +112,14 @@ struct IndustrySpec {
uint32 prospecting_chance; ///< Chance prospecting succeeds
IndustryType conflicting[3]; ///< Industries this industry cannot be close to
byte check_proc; ///< Index to a procedure to check for conflicting circumstances
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS];
byte production_rate[INDUSTRY_NUM_OUTPUTS];
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo{};
std::array<byte, INDUSTRY_NUM_OUTPUTS> production_rate{};
/**
* minimum amount of cargo transported to the stations.
* If the waiting cargo is less than this number, no cargo is moved to it.
*/
byte minimal_cargo;
CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]; ///< 16 accepted cargoes.
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo{}; ///< 16 accepted cargoes.
uint16 input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes)
IndustryLifeType life_type; ///< This is also known as Industry production flag, in newgrf specs
byte climate_availability; ///< Bitmask, giving landscape enums as bit position

Loading…
Cancel
Save