Link graph: Fix FlowStat::ScaleToMonthly scaling

Fixes: e1cce4d9
pull/564/head
Jonathan G Rennison 11 months ago
parent e1cce4d9f7
commit 51a66b9590

@ -53,7 +53,7 @@ void FlowMapper::Run(LinkGraphJob &job) const
/* Scale by time the graph has been running without being compressed. Add 1 to avoid
* division by 0 if spawn date == last compression date. This matches
* LinkGraph::Monthly(). */
uint runtime = (job.StartDateTicks() / DAY_TICKS) - job.LastCompression() + 1;
uint runtime = _scaled_date_ticks - job.LastCompression() + 1;
for (auto &it : flows) {
it.ScaleToMonthly(runtime);
}

@ -5500,7 +5500,7 @@ void FlowStat::ReleaseShare(StationID st)
/**
* Scale all shares from link graph's runtime to monthly values.
* @param runtime Time the link graph has been running without compression.
* @param runtime Time the link graph has been running without compression, in scaled ticks.
* @pre runtime must be greater than 0 as we don't want infinite flow values.
*/
void FlowStat::ScaleToMonthly(uint runtime)
@ -5508,7 +5508,7 @@ void FlowStat::ScaleToMonthly(uint runtime)
assert(runtime > 0);
uint share = 0;
for (iterator i = this->begin(); i != this->end(); ++i) {
share = std::max(share + 1, i->first * 30 / runtime);
share = std::max(share + 1, ClampTo<uint>((static_cast<uint64>(i->first) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / runtime));
if (this->unrestricted == i->first) this->unrestricted = share;
i->first = share;
}

Loading…
Cancel
Save