* Subtract invalid flows from locally consumed flow. * @param self ID of own station. */
| 5249 | * @param self ID of own station. |
| 5250 | */ |
| 5251 | void 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. |