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

@@ -3807,9 +3807,9 @@ void DeleteStaleLinks(Station *from)
for (Edge &edge : (*lg)[ge.node].edges) {
Station *to = Station::Get((*lg)[edge.dest_node].station);
assert(to->goods[c].node == edge.dest_node);
assert(_date >= edge.LastUpdate());
assert(TimerGameCalendar::date >= edge.LastUpdate());
uint timeout = LinkGraph::MIN_TIMEOUT_DISTANCE + (DistanceManhattan(from->xy, to->xy) >> 3);
if ((uint)(_date - edge.LastUpdate()) > timeout) {
if ((uint)(TimerGameCalendar::date - edge.LastUpdate()) > timeout) {
bool updated = false;
if (auto_distributed) {
@@ -3837,11 +3837,11 @@ void DeleteStaleLinks(Station *from)
while (iter != vehicles.end()) {
Vehicle *v = *iter;
/* Do not refresh links of vehicles that have been stopped in depot for a long time. */
if (!v->IsStoppedInDepot() || static_cast<uint>(_date - v->date_of_last_service) <=
if (!v->IsStoppedInDepot() || static_cast<uint>(TimerGameCalendar::date - v->date_of_last_service) <=
LinkGraph::STALE_LINK_DEPOT_TIMEOUT) {
LinkRefresher::Run(v, false); // Don't allow merging. Otherwise lg might get deleted.
}
if (edge.LastUpdate() == _date) {
if (edge.LastUpdate() == TimerGameCalendar::date) {
updated = true;
break;
}
@@ -3864,19 +3864,19 @@ void DeleteStaleLinks(Station *from)
ge.flows.DeleteFlows(to->index);
RerouteCargo(from, c, to->index, from->index);
}
} else if (edge.last_unrestricted_update != INVALID_DATE && (uint)(_date - edge.last_unrestricted_update) > timeout) {
} else if (edge.last_unrestricted_update != INVALID_DATE && (uint)(TimerGameCalendar::date - edge.last_unrestricted_update) > timeout) {
edge.Restrict();
ge.flows.RestrictFlows(to->index);
RerouteCargo(from, c, to->index, from->index);
} else if (edge.last_restricted_update != INVALID_DATE && (uint)(_date - edge.last_restricted_update) > timeout) {
} else if (edge.last_restricted_update != INVALID_DATE && (uint)(TimerGameCalendar::date - edge.last_restricted_update) > timeout) {
edge.Release();
}
}
/* Remove dead edges. */
for (NodeID r : to_remove) (*lg)[ge.node].RemoveEdge(r);
assert(_date >= lg->LastCompression());
if ((uint)(_date - lg->LastCompression()) > LinkGraph::COMPRESSION_INTERVAL) {
assert(TimerGameCalendar::date >= lg->LastCompression());
if ((uint)(TimerGameCalendar::date - lg->LastCompression()) > LinkGraph::COMPRESSION_INTERVAL) {
lg->Compress();
}
}
@@ -4304,7 +4304,7 @@ void BuildOilRig(TileIndex tile)
st->airport.Add(tile);
st->ship_station.Add(tile);
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
st->build_date = _date;
st->build_date = TimerGameCalendar::date;
UpdateStationDockingTiles(st);
st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE);