1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-15 16:32:41 +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

@@ -335,7 +335,7 @@ static void DrawTile_Industry(TileInfo *ti)
* DrawNewIndustry will return false if ever the resolver could not
* find any sprite to display. So in this case, we will jump on the
* substitute gfx instead. */
if (indts->grf_prop.spritegroup[0] != nullptr && DrawNewIndustryTile(ti, ind, gfx, indts)) {
if (indts->grf_prop.GetSpriteGroup() != nullptr && DrawNewIndustryTile(ti, ind, gfx, indts)) {
return;
} else {
/* No sprite group (or no valid one) found, meaning no graphics associated.
@@ -404,7 +404,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
*/
if (gfx >= NEW_INDUSTRYTILEOFFSET) {
const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
if (indts->grf_prop.spritegroup[0] != nullptr && indts->callback_mask.Test(IndustryTileCallbackMask::DrawFoundations)) {
if (indts->grf_prop.GetSpriteGroup() != nullptr && indts->callback_mask.Test(IndustryTileCallbackMask::DrawFoundations)) {
uint32_t callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile);
if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(indts->grf_prop.grffile, CBID_INDTILE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE;
}