@@ -80,26 +80,26 @@ void LinkGraph::Compress()
edge.usage /= 2;
}
/**
* Merge a link graph with another one.
* @param other LinkGraph to be merged into this one.
*/
void LinkGraph::Merge(LinkGraph *other)
{
Date age = TimerGameCalendar::date - this->last_compression + 1;
Date other_age = TimerGameCalendar::date - other->last_compression + 1;
TimerGameCalendar::Date age = TimerGameCalendar::date - this->last_compression + 1;
TimerGameCalendar::Date other_age = TimerGameCalendar::date - other->last_compression + 1;
NodeID first = this->Size();
for (NodeID node1 = 0; node1 < other->Size(); ++node1) {
Station *st = Station::Get(other->nodes[node1].station);
NodeID new_node = this->AddNode(st);
this->nodes[new_node].supply = LinkGraph::Scale(other->nodes[node1].supply, age, other_age);
st->goods[this->cargo].link_graph = this->index;
st->goods[this->cargo].node = new_node;
for (BaseEdge &e : other->nodes[node1].edges) {
BaseEdge &new_edge = this->nodes[new_node].edges.emplace_back(first + e.dest_node);
new_edge.capacity = LinkGraph::Scale(e.capacity, age, other_age);
new_edge.usage = LinkGraph::Scale(e.usage, age, other_age);