* Rebuild the cache for estimated destinations which is used to quickly show the "destination" entries * even if we actually don't know the destination of a certain packet from just looking at it. * @param i Cargo to recalculate the cache for. */
| 1491 | * @param i Cargo to recalculate the cache for. |
| 1492 | */ |
| 1493 | void RecalcDestinations(CargoType cargo) |
| 1494 | { |
| 1495 | const Station *st = Station::Get(this->window_number); |
| 1496 | CargoDataEntry &entry = cached_destinations.InsertOrRetrieve(cargo); |
| 1497 | entry.Clear(); |
| 1498 | |
| 1499 | if (!st->goods[cargo].HasData()) return; |
| 1500 | |
| 1501 | for (const auto &it : st->goods[cargo].GetData().flows) { |
| 1502 | StationID from = it.first; |
| 1503 | CargoDataEntry &source_entry = entry.InsertOrRetrieve(from); |
| 1504 | uint32_t prev_count = 0; |
| 1505 | for (const auto &flow_it : *it.second.GetShares()) { |
| 1506 | StationID via = flow_it.second; |
| 1507 | CargoDataEntry &via_entry = source_entry.InsertOrRetrieve(via); |
| 1508 | if (via == this->window_number) { |
| 1509 | via_entry.InsertOrRetrieve(via).Update(flow_it.first - prev_count); |
| 1510 | } else { |
| 1511 | EstimateDestinations(cargo, from, via, flow_it.first - prev_count, via_entry); |
| 1512 | } |
| 1513 | prev_count = flow_it.first; |
| 1514 | } |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | /** |
| 1519 | * Estimate the amounts of cargo per final destination for a given cargo, source station and next hop and |
no test coverage detected