Codechange: move all date-related variables inside the timer (#10706)

This commit is contained in:
Patric Stout
2023-04-24 17:56:01 +02:00
committed by GitHub
parent f5f6306af3
commit 7aa2b9ab0a
76 changed files with 308 additions and 301 deletions

View File

@@ -65,7 +65,7 @@ void LinkGraph::ShiftDates(int interval)
void LinkGraph::Compress()
{
this->last_compression = (_date + this->last_compression) / 2;
this->last_compression = (TimerGameCalendar::date + this->last_compression) / 2;
for (NodeID node1 = 0; node1 < this->Size(); ++node1) {
this->nodes[node1].supply /= 2;
for (BaseEdge &edge : this->nodes[node1].edges) {
@@ -89,8 +89,8 @@ void LinkGraph::Compress()
*/
void LinkGraph::Merge(LinkGraph *other)
{
Date age = _date - this->last_compression + 1;
Date other_age = _date - other->last_compression + 1;
Date age = TimerGameCalendar::date - this->last_compression + 1;
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);
@@ -172,8 +172,8 @@ void LinkGraph::BaseNode::AddEdge(NodeID to, uint capacity, uint usage, uint32 t
edge.capacity = capacity;
edge.usage = usage;
edge.travel_time_sum = static_cast<uint64>(travel_time) * capacity;
if (mode & EUM_UNRESTRICTED) edge.last_unrestricted_update = _date;
if (mode & EUM_RESTRICTED) edge.last_restricted_update = _date;
if (mode & EUM_UNRESTRICTED) edge.last_unrestricted_update = TimerGameCalendar::date;
if (mode & EUM_RESTRICTED) edge.last_restricted_update = TimerGameCalendar::date;
}
/**
@@ -239,8 +239,8 @@ void LinkGraph::BaseEdge::Update(uint capacity, uint usage, uint32 travel_time,
}
this->usage = std::max(this->usage, usage);
}
if (mode & EUM_UNRESTRICTED) this->last_unrestricted_update = _date;
if (mode & EUM_RESTRICTED) this->last_restricted_update = _date;
if (mode & EUM_UNRESTRICTED) this->last_unrestricted_update = TimerGameCalendar::date;
if (mode & EUM_RESTRICTED) this->last_restricted_update = TimerGameCalendar::date;
}
/**