summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/saveload/linkgraph_sl.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 0640dba19..4fcc36e96 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -144,15 +144,33 @@ void SaveLoad_LinkGraph(LinkGraph &lg)
}
/**
- * Save a link graph job.
- * @param lgj LinkGraphJob to be saved.
+ * Spawn the threads for running link graph calculations.
+ * Has to be done after loading as the cargo classes might have changed.
*/
-static void DoSave_LGRJ(LinkGraphJob *lgj)
+void AfterLoadLinkGraphs()
{
- SlObject(lgj, GetLinkGraphJobDesc());
- _num_nodes = lgj->Size();
- SlObject(const_cast<LinkGraph *>(&lgj->Graph()), GetLinkGraphDesc());
- SaveLoad_LinkGraph(const_cast<LinkGraph &>(lgj->Graph()));
+ if (IsSavegameVersionBefore(SLV_191)) {
+ for (LinkGraph *lg : LinkGraph::Iterate()) {
+ for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
+ const Station *st = Station::GetIfValid((*lg)[node_id].Station());
+ if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
+ }
+ }
+
+ for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
+ LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
+ for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
+ const Station *st = Station::GetIfValid((*lg)[node_id].Station());
+ if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
+ }
+ }
+ }
+
+ LinkGraphSchedule::instance.SpawnAll();
+
+ if (!_networking || _network_server) {
+ AfterLoad_LinkGraphPauseControl();
+ }
}
/**
@@ -167,6 +185,17 @@ static void DoSave_LGRP(LinkGraph *lg)
}
/**
+ * Save all link graphs.
+ */
+static void Save_LGRP()
+{
+ for (LinkGraph *lg : LinkGraph::Iterate()) {
+ SlSetArrayIndex(lg->index);
+ SlAutolength((AutolengthProc*)DoSave_LGRP, lg);
+ }
+}
+
+/**
* Load all link graphs.
*/
static void Load_LGRP()
@@ -185,6 +214,29 @@ static void Load_LGRP()
}
/**
+ * Save a link graph job.
+ * @param lgj LinkGraphJob to be saved.
+ */
+static void DoSave_LGRJ(LinkGraphJob *lgj)
+{
+ SlObject(lgj, GetLinkGraphJobDesc());
+ _num_nodes = lgj->Size();
+ SlObject(const_cast<LinkGraph *>(&lgj->Graph()), GetLinkGraphDesc());
+ SaveLoad_LinkGraph(const_cast<LinkGraph &>(lgj->Graph()));
+}
+
+/**
+ * Save all link graph jobs.
+ */
+static void Save_LGRJ()
+{
+ for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
+ SlSetArrayIndex(lgj->index);
+ SlAutolength((AutolengthProc*)DoSave_LGRJ, lgj);
+ }
+}
+
+/**
* Load all link graph jobs.
*/
static void Load_LGRJ()
@@ -205,69 +257,17 @@ static void Load_LGRJ()
}
/**
- * Load the link graph schedule.
+ * Save the link graph schedule.
*/
-static void Load_LGRS()
+static void Save_LGRS()
{
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}
/**
- * Spawn the threads for running link graph calculations.
- * Has to be done after loading as the cargo classes might have changed.
- */
-void AfterLoadLinkGraphs()
-{
- if (IsSavegameVersionBefore(SLV_191)) {
- for (LinkGraph *lg : LinkGraph::Iterate()) {
- for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
- const Station *st = Station::GetIfValid((*lg)[node_id].Station());
- if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
- }
- }
-
- for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
- LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
- for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
- const Station *st = Station::GetIfValid((*lg)[node_id].Station());
- if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
- }
- }
- }
-
- LinkGraphSchedule::instance.SpawnAll();
-
- if (!_networking || _network_server) {
- AfterLoad_LinkGraphPauseControl();
- }
-}
-
-/**
- * Save all link graphs.
- */
-static void Save_LGRP()
-{
- for (LinkGraph *lg : LinkGraph::Iterate()) {
- SlSetArrayIndex(lg->index);
- SlAutolength((AutolengthProc*)DoSave_LGRP, lg);
- }
-}
-
-/**
- * Save all link graph jobs.
- */
-static void Save_LGRJ()
-{
- for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
- SlSetArrayIndex(lgj->index);
- SlAutolength((AutolengthProc*)DoSave_LGRJ, lgj);
- }
-}
-
-/**
- * Save the link graph schedule.
+ * Load the link graph schedule.
*/
-static void Save_LGRS()
+static void Load_LGRS()
{
SlObject(&LinkGraphSchedule::instance, GetLinkGraphScheduleDesc());
}