1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 03:42:41 +01:00

Codechange: Store grfid with entity grfprops.

This allows using the grfid without having to dereference the grffile pointer.

Uses no extra storage as it fits within otherwise wasted padding space.
This commit is contained in:
Peter Nelson
2024-11-23 14:05:42 +00:00
committed by Peter Nelson
parent e750d10cee
commit e73d6fcaac
24 changed files with 132 additions and 112 deletions

View File

@@ -1479,7 +1479,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
if (callback <= UINT8_MAX) {
SetStationGfx(tile, (callback & ~1) + axis);
} else {
ErrorUnknownCallbackResult(statspec->grf_prop.grffile->grfid, CBID_STATION_BUILD_TILE_LAYOUT, callback);
ErrorUnknownCallbackResult(statspec->grf_prop.grfid, CBID_STATION_BUILD_TILE_LAYOUT, callback);
}
}
@@ -3503,8 +3503,8 @@ void FillTileDescRailStation(TileIndex tile, TileDesc *td)
td->station_class = StationClass::Get(spec->class_index)->name;
td->station_name = spec->name;
if (spec->grf_prop.grffile != nullptr) {
const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid);
if (spec->grf_prop.HasGrfFile()) {
const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grfid);
td->grf = gc->GetName();
}
}
@@ -3523,11 +3523,11 @@ void FillTileDescAirport(TileIndex tile, TileDesc *td)
const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
td->airport_tile_name = ats->name;
if (as->grf_prop.grffile != nullptr) {
const GRFConfig *gc = GetGRFConfig(as->grf_prop.grffile->grfid);
if (as->grf_prop.HasGrfFile()) {
const GRFConfig *gc = GetGRFConfig(as->grf_prop.grfid);
td->grf = gc->GetName();
} else if (ats->grf_prop.grffile != nullptr) {
const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid);
} else if (ats->grf_prop.HasGrfFile()) {
const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grfid);
td->grf = gc->GetName();
}
}
@@ -3555,7 +3555,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
const IndustrySpec *is = GetIndustrySpec(i->type);
td->owner[0] = i->owner;
str = is->name;
if (is->grf_prop.grffile != nullptr) td->grf = GetGRFConfig(is->grf_prop.grffile->grfid)->GetName();
if (is->grf_prop.HasGrfFile()) td->grf = GetGRFConfig(is->grf_prop.grfid)->GetName();
break;
}
case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK; break;