Codechange: Limit house default cargo label lists to original slot counts. (#13079)

Same as for IndustrySpec and IndustryTileSpec.
This commit is contained in:
Peter Nelson 2024-11-15 08:07:02 +00:00 committed by GitHub
parent d6c2f9edf1
commit 98c8445519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -101,7 +101,6 @@ struct HouseSpec {
uint8_t mail_generation; ///< mail generation multiplier (tile based, as the acceptances below) uint8_t mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
uint8_t cargo_acceptance[HOUSE_NUM_ACCEPTS]; ///< acceptance level for the cargo slots uint8_t cargo_acceptance[HOUSE_NUM_ACCEPTS]; ///< acceptance level for the cargo slots
CargoID accepts_cargo[HOUSE_NUM_ACCEPTS]; ///< input cargo slots CargoID accepts_cargo[HOUSE_NUM_ACCEPTS]; ///< input cargo slots
CargoLabel accepts_cargo_label[HOUSE_NUM_ACCEPTS]; ///< input landscape cargo slots
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...) BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
HouseZones building_availability; ///< where can it be built (climates, zones) HouseZones building_availability; ///< where can it be built (climates, zones)
bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf) bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
@ -118,6 +117,8 @@ struct HouseSpec {
uint8_t minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it uint8_t minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
CargoTypes watched_cargoes; ///< Cargo types watched for acceptance. CargoTypes watched_cargoes; ///< Cargo types watched for acceptance.
CargoLabel accepts_cargo_label[HOUSE_ORIGINAL_NUM_ACCEPTS]; ///< input landscape cargo slots
HouseID Index() const; HouseID Index() const;
Money GetRemovalCost() const; Money GetRemovalCost() const;

View File

@ -2639,7 +2639,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt
housespec->accepts_cargo[i] = INVALID_CARGO; housespec->accepts_cargo[i] = INVALID_CARGO;
housespec->cargo_acceptance[i] = 0; housespec->cargo_acceptance[i] = 0;
} }
housespec->accepts_cargo_label[i] = CT_INVALID; if (i < std::size(housespec->accepts_cargo_label)) housespec->accepts_cargo_label[i] = CT_INVALID;
} }
break; break;
} }
@ -9376,7 +9376,7 @@ static void FinaliseHouseArray()
} }
/* Apply default cargo translation map for unset cargo slots */ /* Apply default cargo translation map for unset cargo slots */
for (uint i = 0; i < lengthof(hs->accepts_cargo); ++i) { for (uint i = 0; i < lengthof(hs->accepts_cargo_label); ++i) {
if (!IsValidCargoID(hs->accepts_cargo[i])) hs->accepts_cargo[i] = GetCargoIDByLabel(hs->accepts_cargo_label[i]); if (!IsValidCargoID(hs->accepts_cargo[i])) hs->accepts_cargo[i] = GetCargoIDByLabel(hs->accepts_cargo_label[i]);
/* Disable acceptance if cargo type is invalid. */ /* Disable acceptance if cargo type is invalid. */
if (!IsValidCargoID(hs->accepts_cargo[i])) hs->cargo_acceptance[i] = 0; if (!IsValidCargoID(hs->accepts_cargo[i])) hs->cargo_acceptance[i] = 0;

View File

@ -1813,9 +1813,8 @@ static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
{mnd, mxd, p, rc, bn, rr, mg, \ {mnd, mxd, p, rc, bn, rr, mg, \
{ca1, ca2, ca3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ {ca1, ca2, ca3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{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}, \
{cg1, cg2, cg3, 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}, \
bf, ba, true, GRFFileProps(INVALID_HOUSE_ID), 0, {COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN}, \ bf, ba, true, GRFFileProps(INVALID_HOUSE_ID), 0, {COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN, COLOUR_BEGIN}, \
16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, {0, 2, 0, 0}, 0, 0, 0} 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, {0, 2, 0, 0}, 0, 0, 0, {cg1, cg2, cg3}, }
/** House specifications from original data */ /** House specifications from original data */
extern const HouseSpec _original_house_specs[] = { extern const HouseSpec _original_house_specs[] = {
/** /**