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

@@ -114,11 +114,11 @@ void AfterLoadStations()
for (BaseStation *st : BaseStation::Iterate()) {
for (auto &sm : GetStationSpecList<StationSpec>(st)) {
if (sm.grfid == 0) continue;
sm.spec = StationClass::GetByGrf(sm.grfid, sm.localidx, nullptr);
sm.spec = StationClass::GetByGrf(sm.grfid, sm.localidx);
}
for (auto &sm : GetStationSpecList<RoadStopSpec>(st)) {
if (sm.grfid == 0) continue;
sm.spec = RoadStopClass::GetByGrf(sm.grfid, sm.localidx, nullptr);
sm.spec = RoadStopClass::GetByGrf(sm.grfid, sm.localidx);
}
if (Station::IsExpected(st)) {