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

Method AddStats

src/linkgraph/linkgraph_gui.cpp:244–256  ·  view source on GitHub ↗

* Add information from a given pair of link stat and flow stat to the given * link properties. The shown usage or plan is always the maximum of all link * stats involved. * @param new_cap Capacity of the new link. * @param new_usg Usage of the new link. * @param new_plan Planned flow for the new link. * @param new_shared If the new link is shared. * @param cargo LinkProperties to write the

Source from the content-addressed store, hash-verified

242 * @param cargo LinkProperties to write the information to.
243 */
244/* static */ void LinkGraphOverlay::AddStats(CargoType new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32_t time, bool new_shared, LinkProperties &cargo)
245{
246 /* multiply the numbers by 32 in order to avoid comparing to 0 too often. */
247 if (cargo.capacity == 0 ||
248 cargo.Usage() * 32 / (cargo.capacity + 1) < std::max(new_usg, new_plan) * 32 / (new_cap + 1)) {
249 cargo.cargo = new_cargo;
250 cargo.capacity = new_cap;
251 cargo.usage = new_usg;
252 cargo.planned = new_plan;
253 cargo.time = time;
254 }
255 if (new_shared) cargo.shared = true;
256}
257
258/**
259 * Draw the linkgraph overlay or some part of it, in the area given.

Callers 1

AddLinksMethod · 0.95

Calls 1

UsageMethod · 0.80

Tested by

no test coverage detected