diff options
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6b158aaf1..6ef602b83 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4290,6 +4290,22 @@ 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. + */ +void FlowStat::ScaleToMonthly(uint runtime) +{ + SharesMap new_shares; + uint share = 0; + for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) { + share = max(share + 1, i->first * 30 / runtime); + new_shares[share] = i->second; + if (this->unrestricted == i->first) this->unrestricted = share; + } + this->shares.swap(new_shares); +} + +/** * Add some flow from "origin", going via "via". * @param origin Origin of the flow. * @param via Next hop. |