mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: Limit industry default cargo label lists to original slot counts. (#13072)
IndustrySpec and IndustryTileSpec cargo label lists are only used for original industries. Original industries can only have up to 2 inputs and 3 outputs. Therefore having space for 16 input/outputs slots is unnecessary This saves 216 bytes per industry type, and 164 bytes per industry tile type.
This commit is contained in:
parent
9742038b68
commit
61aff3fa49
@ -106,7 +106,6 @@ struct IndustrySpec {
|
|||||||
IndustryType conflicting[3]; ///< Industries this industry cannot be close to
|
IndustryType conflicting[3]; ///< Industries this industry cannot be close to
|
||||||
uint8_t check_proc; ///< Index to a procedure to check for conflicting circumstances
|
uint8_t check_proc; ///< Index to a procedure to check for conflicting circumstances
|
||||||
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo;
|
std::array<CargoID, INDUSTRY_NUM_OUTPUTS> produced_cargo;
|
||||||
std::variant<CargoLabel, MixedCargoType> produced_cargo_label[INDUSTRY_NUM_OUTPUTS];
|
|
||||||
uint8_t production_rate[INDUSTRY_NUM_OUTPUTS];
|
uint8_t production_rate[INDUSTRY_NUM_OUTPUTS];
|
||||||
/**
|
/**
|
||||||
* minimum amount of cargo transported to the stations.
|
* minimum amount of cargo transported to the stations.
|
||||||
@ -114,7 +113,6 @@ struct IndustrySpec {
|
|||||||
*/
|
*/
|
||||||
uint8_t minimal_cargo;
|
uint8_t minimal_cargo;
|
||||||
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo; ///< 16 accepted cargoes.
|
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo; ///< 16 accepted cargoes.
|
||||||
std::variant<CargoLabel, MixedCargoType> accepts_cargo_label[INDUSTRY_NUM_INPUTS];
|
|
||||||
uint16_t input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes)
|
uint16_t 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
|
IndustryLifeType life_type; ///< This is also known as Industry production flag, in newgrf specs
|
||||||
uint8_t climate_availability; ///< Bitmask, giving landscape enums as bit position
|
uint8_t climate_availability; ///< Bitmask, giving landscape enums as bit position
|
||||||
@ -134,6 +132,9 @@ struct IndustrySpec {
|
|||||||
GRFFileProps grf_prop; ///< properties related to the grf file
|
GRFFileProps grf_prop; ///< properties related to the grf file
|
||||||
std::vector<uint8_t> random_sounds; ///< Random sounds;
|
std::vector<uint8_t> random_sounds; ///< Random sounds;
|
||||||
|
|
||||||
|
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_ORIGINAL_NUM_OUTPUTS> produced_cargo_label; ///< Cargo labels of produced cargo for default industries.
|
||||||
|
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_ORIGINAL_NUM_INPUTS> accepts_cargo_label; ///< Cargo labels of accepted cargo for default industries.
|
||||||
|
|
||||||
bool IsRawIndustry() const;
|
bool IsRawIndustry() const;
|
||||||
bool IsProcessingIndustry() const;
|
bool IsProcessingIndustry() const;
|
||||||
Money GetConstructionCost() const;
|
Money GetConstructionCost() const;
|
||||||
@ -147,7 +148,6 @@ struct IndustrySpec {
|
|||||||
*/
|
*/
|
||||||
struct IndustryTileSpec {
|
struct IndustryTileSpec {
|
||||||
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo; ///< Cargo accepted by this tile
|
std::array<CargoID, INDUSTRY_NUM_INPUTS> accepts_cargo; ///< Cargo accepted by this tile
|
||||||
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_NUM_INPUTS> accepts_cargo_label;
|
|
||||||
std::array<int8_t, INDUSTRY_NUM_INPUTS> acceptance; ///< Level of acceptance per cargo type (signed, may be negative!)
|
std::array<int8_t, INDUSTRY_NUM_INPUTS> acceptance; ///< Level of acceptance per cargo type (signed, may be negative!)
|
||||||
Slope slopes_refused; ///< slope pattern on which this tile cannot be built
|
Slope slopes_refused; ///< slope pattern on which this tile cannot be built
|
||||||
uint8_t anim_production; ///< Animation frame to start when goods are produced
|
uint8_t anim_production; ///< Animation frame to start when goods are produced
|
||||||
@ -163,6 +163,8 @@ struct IndustryTileSpec {
|
|||||||
IndustryTileSpecialFlags special_flags; ///< Bitmask of extra flags used by the tile
|
IndustryTileSpecialFlags special_flags; ///< Bitmask of extra flags used by the tile
|
||||||
bool enabled; ///< entity still available (by default true).newgrf can disable it, though
|
bool enabled; ///< entity still available (by default true).newgrf can disable it, though
|
||||||
GRFFileProps grf_prop; ///< properties related to the grf file
|
GRFFileProps grf_prop; ///< properties related to the grf file
|
||||||
|
|
||||||
|
std::array<std::variant<CargoLabel, MixedCargoType>, INDUSTRY_ORIGINAL_NUM_INPUTS> accepts_cargo_label; ///< Cargo labels of accepted cargo for default industry tiles.
|
||||||
};
|
};
|
||||||
|
|
||||||
/* industry_cmd.cpp*/
|
/* industry_cmd.cpp*/
|
||||||
|
@ -3380,7 +3380,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr
|
|||||||
tsp->accepts_cargo[i] = INVALID_CARGO;
|
tsp->accepts_cargo[i] = INVALID_CARGO;
|
||||||
tsp->acceptance[i] = 0;
|
tsp->acceptance[i] = 0;
|
||||||
}
|
}
|
||||||
tsp->accepts_cargo_label[i] = CT_INVALID;
|
if (i < std::size(tsp->accepts_cargo_label)) tsp->accepts_cargo_label[i] = CT_INVALID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3821,7 +3821,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
|
|||||||
} else {
|
} else {
|
||||||
indsp->produced_cargo[i] = INVALID_CARGO;
|
indsp->produced_cargo[i] = INVALID_CARGO;
|
||||||
}
|
}
|
||||||
indsp->produced_cargo_label[i] = CT_INVALID;
|
if (i < std::size(indsp->produced_cargo_label)) indsp->produced_cargo_label[i] = CT_INVALID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3840,7 +3840,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop,
|
|||||||
} else {
|
} else {
|
||||||
indsp->accepts_cargo[i] = INVALID_CARGO;
|
indsp->accepts_cargo[i] = INVALID_CARGO;
|
||||||
}
|
}
|
||||||
indsp->accepts_cargo_label[i] = CT_INVALID;
|
if (i < std::size(indsp->accepts_cargo_label)) indsp->accepts_cargo_label[i] = CT_INVALID;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -9457,17 +9457,17 @@ static void FinaliseIndustriesArray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Apply default cargo translation map for unset cargo slots */
|
/* Apply default cargo translation map for unset cargo slots */
|
||||||
for (size_t i = 0; i < std::size(indsp.produced_cargo); ++i) {
|
for (size_t i = 0; i < std::size(indsp.produced_cargo_label); ++i) {
|
||||||
if (!IsValidCargoID(indsp.produced_cargo[i])) indsp.produced_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indsp.produced_cargo_label[i]));
|
if (!IsValidCargoID(indsp.produced_cargo[i])) indsp.produced_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indsp.produced_cargo_label[i]));
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < std::size(indsp.accepts_cargo); ++i) {
|
for (size_t i = 0; i < std::size(indsp.accepts_cargo_label); ++i) {
|
||||||
if (!IsValidCargoID(indsp.accepts_cargo[i])) indsp.accepts_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indsp.accepts_cargo_label[i]));
|
if (!IsValidCargoID(indsp.accepts_cargo[i])) indsp.accepts_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indsp.accepts_cargo_label[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &indtsp : _industry_tile_specs) {
|
for (auto &indtsp : _industry_tile_specs) {
|
||||||
/* Apply default cargo translation map for unset cargo slots */
|
/* Apply default cargo translation map for unset cargo slots */
|
||||||
for (size_t i = 0; i < indtsp.accepts_cargo.size(); ++i) {
|
for (size_t i = 0; i < std::size(indtsp.accepts_cargo_label); ++i) {
|
||||||
if (!IsValidCargoID(indtsp.accepts_cargo[i])) indtsp.accepts_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indtsp.accepts_cargo_label[i]));
|
if (!IsValidCargoID(indtsp.accepts_cargo[i])) indtsp.accepts_cargo[i] = GetCargoIDByLabel(GetActiveCargoLabel(indtsp.accepts_cargo_label[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1129,13 +1129,12 @@ enum IndustryTypes {
|
|||||||
c1, c2, c3, proc, p1, r1, p2, r2, m, a1, im1, a2, im2, a3, im3, pr, clim, bev, in, intx, s1, s2, s3) \
|
c1, c2, c3, proc, p1, r1, p2, r2, m, a1, im1, a2, im2, a3, im3, pr, clim, bev, in, intx, s1, s2, s3) \
|
||||||
{tbl, d, 0, pc, {c1, c2, c3}, proc, \
|
{tbl, d, 0, pc, {c1, c2, c3}, proc, \
|
||||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||||
{p1, p2, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID}, \
|
|
||||||
{r1, r2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, m, \
|
{r1, r2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, m, \
|
||||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||||
{a1, a2, a3, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID}, \
|
|
||||||
{{im1, 0}, {im2, 0}, {im3, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, \
|
{{im1, 0}, {im2, 0}, {im3, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, \
|
||||||
pr, clim, bev, col, in, intx, s1, s2, s3, STR_UNDEFINED, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
|
pr, clim, bev, col, in, intx, s1, s2, s3, STR_UNDEFINED, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
|
||||||
0, true, GRFFileProps(INVALID_INDUSTRYTYPE), snd}
|
0, true, GRFFileProps(INVALID_INDUSTRYTYPE), snd, \
|
||||||
|
{{p1, p2}}, {{a1, a2, a3}}}
|
||||||
/* Format:
|
/* Format:
|
||||||
tile table count and sounds table
|
tile table count and sounds table
|
||||||
cost multiplier appear chances(4ingame, 4random) map colour
|
cost multiplier appear chances(4ingame, 4random) map colour
|
||||||
@ -1534,8 +1533,7 @@ static const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET] = {
|
|||||||
*/
|
*/
|
||||||
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) { \
|
#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) { \
|
||||||
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
{INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO, INVALID_CARGO}, \
|
||||||
{c1, c2, c3, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID, CT_INVALID}, \
|
{ca1, ca2, ca3}, sl, a1, a2, a3, 0, {0, ANIM_STATUS_NO_ANIMATION, 2, 0}, INDTILE_SPECIAL_NONE, true, GRFFileProps(INVALID_INDUSTRYTILE), {c1, c2, c3} \
|
||||||
{ca1, ca2, ca3}, sl, a1, a2, a3, 0, {0, ANIM_STATUS_NO_ANIMATION, 2, 0}, INDTILE_SPECIAL_NONE, true, GRFFileProps(INVALID_INDUSTRYTILE) \
|
|
||||||
}
|
}
|
||||||
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
|
static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
|
||||||
/* Coal Mine */
|
/* Coal Mine */
|
||||||
|
Loading…
Reference in New Issue
Block a user