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

Function AfterLoadLinkGraphs

src/saveload/linkgraph_sl.cpp:232–256  ·  view source on GitHub ↗

* Spawn the threads for running link graph calculations. * Has to be done after loading as the cargo classes might have changed. */

Source from the content-addressed store, hash-verified

230 * Has to be done after loading as the cargo classes might have changed.
231 */
232void AfterLoadLinkGraphs()
233{
234 if (IsSavegameVersionBefore(SLV_191)) {
235 for (LinkGraph *lg : LinkGraph::Iterate()) {
236 for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
237 const Station *st = Station::GetIfValid((*lg)[node_id].station);
238 if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
239 }
240 }
241
242 for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
243 LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
244 for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
245 const Station *st = Station::GetIfValid((*lg)[node_id].station);
246 if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
247 }
248 }
249 }
250
251 LinkGraphSchedule::instance.SpawnAll();
252
253 if (!_networking || _network_server) {
254 AfterLoad_LinkGraphPauseControl();
255 }
256}
257
258/**
259 * All link graphs.

Callers 1

AfterLoadGameFunction · 0.85

Calls 5

IsSavegameVersionBeforeFunction · 0.85
UpdateLocationMethod · 0.80
SpawnAllMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected