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

Method FinalizeLocalConsumption

src/station_cmd.cpp:5251–5268  ·  view source on GitHub ↗

* Subtract invalid flows from locally consumed flow. * @param self ID of own station. */

Source from the content-addressed store, hash-verified

5249 * @param self ID of own station.
5250 */
5251void FlowStatMap::FinalizeLocalConsumption(StationID self)
5252{
5253 for (auto &i : *this) {
5254 FlowStat &fs = i.second;
5255 uint local = fs.GetShare(StationID::Invalid());
5256 if (local > INT_MAX) { // make sure it fits in an int
5257 fs.ChangeShare(self, -INT_MAX);
5258 fs.ChangeShare(StationID::Invalid(), -INT_MAX);
5259 local -= INT_MAX;
5260 }
5261 fs.ChangeShare(self, -(int)local);
5262 fs.ChangeShare(StationID::Invalid(), -(int)local);
5263
5264 /* If the local share is used up there must be a share for some
5265 * remote station. */
5266 assert(!fs.GetShares()->empty());
5267 }
5268}
5269
5270/**
5271 * Delete all flows at a station for specific cargo and destination.

Callers 1

RunMethod · 0.80

Calls 5

InvalidFunction · 0.85
GetShareMethod · 0.80
ChangeShareMethod · 0.80
GetSharesMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected