MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / AfterLoadStations

Function AfterLoadStations

src/saveload/station_sl.cpp:111–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void AfterLoadStations()
112{
113 /* Update the speclists of all stations to point to the currently loaded custom stations. */
114 for (BaseStation *st : BaseStation::Iterate()) {
115 for (auto &sm : GetStationSpecList<StationSpec>(st)) {
116 if (sm.grfid == 0) continue;
117 sm.spec = StationClass::GetByGrf(sm.grfid, sm.localidx);
118 }
119 for (auto &sm : GetStationSpecList<RoadStopSpec>(st)) {
120 if (sm.grfid == 0) continue;
121 sm.spec = RoadStopClass::GetByGrf(sm.grfid, sm.localidx);
122 }
123
124 if (Station::IsExpected(st)) {
125 Station *sta = Station::From(st);
126 for (const RoadStop *rs = sta->bus_stops; rs != nullptr; rs = rs->next) sta->bus_station.Add(rs->xy);
127 for (const RoadStop *rs = sta->truck_stops; rs != nullptr; rs = rs->next) sta->truck_station.Add(rs->xy);
128 }
129
130 StationUpdateCachedTriggers(st);
131 RoadStopUpdateCachedTriggers(st);
132 }
133
134 /* Station blocked, wires and pylon flags need to be stored in the map. This is effectively cached data, so no
135 * version check is necessary. */
136 for (const auto t : Map::Iterate()) {
137 if (HasStationTileRail(t)) SetRailStationTileFlags(t, GetStationSpec(t));
138 }
139}
140
141/**
142 * (Re)building of road stop caches after loading a savegame.

Callers 2

AfterLoadGameFunction · 0.85
ReloadNewGRFDataFunction · 0.85

Calls 6

HasStationTileRailFunction · 0.85
SetRailStationTileFlagsFunction · 0.85
GetStationSpecFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected