MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScaleToMonthly

Method ScaleToMonthly

src/station_cmd.cpp:5195–5206  ·  view source on GitHub ↗

* Scale all shares from link graph's runtime to monthly values. * @param runtime Time the link graph has been running without compression. * @pre runtime must be greater than 0 as we don't want infinite flow values. */

Source from the content-addressed store, hash-verified

5193 * @pre runtime must be greater than 0 as we don't want infinite flow values.
5194 */
5195void FlowStat::ScaleToMonthly(uint runtime)
5196{
5197 assert(runtime > 0);
5198 SharesMap new_shares;
5199 uint share = 0;
5200 for (auto i : this->shares) {
5201 share = std::max(share + 1, i.first * 30 / runtime);
5202 new_shares[share] = i.second;
5203 if (this->unrestricted == i.first) this->unrestricted = share;
5204 }
5205 this->shares.swap(new_shares);
5206}
5207
5208/**
5209 * Add some flow from "origin", going via "via".

Callers 1

RunMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected