1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-23 12:14:11 +01:00

Codechange: Add NewGRFSpecsBase class to hold class/index information.

Standardises how the class index is stored in the spec, instead of relying ot the Spec structs having the same members.

This allows retrieving class_index and index without searching or using pointer arithmetic.

'cls_id' is renamed to 'class_index' to make it clearer that it is an index rather than the multichar label of the class.
This commit is contained in:
Peter Nelson
2024-05-07 12:13:46 +01:00
committed by Peter Nelson
parent 733284cc16
commit d5671030b1
13 changed files with 83 additions and 78 deletions

View File

@@ -3346,7 +3346,7 @@ void FillTileDescRailStation(TileIndex tile, TileDesc *td)
const StationSpec *spec = GetStationSpec(tile);
if (spec != nullptr) {
td->station_class = StationClass::Get(spec->cls_id)->name;
td->station_class = StationClass::Get(spec->class_index)->name;
td->station_name = spec->name;
if (spec->grf_prop.grffile != nullptr) {
@@ -3363,7 +3363,7 @@ void FillTileDescRailStation(TileIndex tile, TileDesc *td)
void FillTileDescAirport(TileIndex tile, TileDesc *td)
{
const AirportSpec *as = Station::GetByTile(tile)->airport.GetSpec();
td->airport_class = AirportClass::Get(as->cls_id)->name;
td->airport_class = AirportClass::Get(as->class_index)->name;
td->airport_name = as->name;
const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);