summaryrefslogtreecommitdiff
path: root/src/linkgraph
diff options
context:
space:
mode:
Diffstat (limited to 'src/linkgraph')
-rw-r--r--src/linkgraph/linkgraph.cpp18
-rw-r--r--src/linkgraph/linkgraph.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp
index dbaa02b41..87a95ad18 100644
--- a/src/linkgraph/linkgraph.cpp
+++ b/src/linkgraph/linkgraph.cpp
@@ -43,6 +43,24 @@ inline void LinkGraph::BaseEdge::Init(uint distance)
this->next_edge = INVALID_NODE;
}
+/**
+ * Shift all dates by given interval.
+ * This is useful if the date has been modified with the cheat menu.
+ * @param interval Number of days to be added or subtracted.
+ */
+void LinkGraph::ShiftDates(int interval)
+{
+ this->last_compression += interval;
+ for (NodeID node1 = 0; node1 < this->Size(); ++node1) {
+ BaseNode &source = this->nodes[node1];
+ if (source.last_update != INVALID_DATE) source.last_update += interval;
+ for (NodeID node2 = 0; node2 < this->Size(); ++node2) {
+ BaseEdge &edge = this->edges[node1][node2];
+ if (edge.last_update != INVALID_DATE) edge.last_update += interval;
+ }
+ }
+}
+
void LinkGraph::Compress()
{
this->last_compression = (_date + this->last_compression) / 2;
diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h
index 8dfe3f8ea..07a6bed95 100644
--- a/src/linkgraph/linkgraph.h
+++ b/src/linkgraph/linkgraph.h
@@ -442,6 +442,7 @@ public:
LinkGraph(CargoID cargo) : cargo(cargo), last_compression(_date) {}
void Init(uint size);
+ void ShiftDates(int interval);
void Compress();
void Merge(LinkGraph *other);