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

Method PassOnFlow

src/station_cmd.cpp:5233–5245  ·  view source on GitHub ↗

* Pass on some flow, remembering it as invalid, for later subtraction from * locally consumed flow. This is necessary because we can't have negative * flows and we don't want to sort the flows before adding them up. * @param origin Origin of the flow. * @param via Next hop. * @param flow Amount of flow to be passed. */

Source from the content-addressed store, hash-verified

5231 * @param flow Amount of flow to be passed.
5232 */
5233void FlowStatMap::PassOnFlow(StationID origin, StationID via, uint flow)
5234{
5235 FlowStatMap::iterator prev_it = this->find(origin);
5236 if (prev_it == this->end()) {
5237 FlowStat fs(via, flow);
5238 fs.AppendShare(StationID::Invalid(), flow);
5239 this->emplace(origin, fs);
5240 } else {
5241 prev_it->second.ChangeShare(via, flow);
5242 prev_it->second.ChangeShare(StationID::Invalid(), flow);
5243 assert(!prev_it->second.GetShares()->empty());
5244 }
5245}
5246
5247/**
5248 * Subtract invalid flows from locally consumed flow.

Callers 1

RunMethod · 0.80

Calls 7

InvalidFunction · 0.85
AppendShareMethod · 0.80
ChangeShareMethod · 0.80
GetSharesMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected