1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 01:12:39 +01:00

Codechange: Use variable storage for GrfProps with cargo-type groups. (#13557)

Slots are only allocated when used instead of being reserved.

Array-based GrfProps are still used when the number of options is more limited.
This commit is contained in:
Peter Nelson
2025-02-14 18:30:17 +00:00
committed by GitHub
parent 4fe3f0ccdd
commit ff7eb996e6
21 changed files with 126 additions and 56 deletions

View File

@@ -273,7 +273,7 @@ static void DrawTile_Town(TileInfo *ti)
/* Houses don't necessarily need new graphics. If they don't have a
* spritegroup associated with them, then the sprite for the substitute
* house id is drawn instead. */
if (HouseSpec::Get(house_id)->grf_prop.spritegroup[0] != nullptr) {
if (HouseSpec::Get(house_id)->grf_prop.GetSpriteGroup() != nullptr) {
DrawNewHouseTile(ti, house_id);
return;
} else {
@@ -334,7 +334,7 @@ static Foundation GetFoundation_Town(TileIndex tile, Slope tileh)
*/
if (hid >= NEW_HOUSE_OFFSET) {
const HouseSpec *hs = HouseSpec::Get(hid);
if (hs->grf_prop.spritegroup[0] != nullptr && hs->callback_mask.Test(HouseCallbackMask::DrawFoundations)) {
if (hs->grf_prop.GetSpriteGroup() != nullptr && hs->callback_mask.Test(HouseCallbackMask::DrawFoundations)) {
uint32_t callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE;
}