* Add all "interesting" links between the given stations to the cache. * @param from The source station. * @param to The destination station. */
| 211 | * @param to The destination station. |
| 212 | */ |
| 213 | void LinkGraphOverlay::AddLinks(const Station *from, const Station *to) |
| 214 | { |
| 215 | for (CargoType cargo : SetCargoBitIterator(this->cargo_mask)) { |
| 216 | if (!CargoSpec::Get(cargo)->IsValid()) continue; |
| 217 | const GoodsEntry &ge = from->goods[cargo]; |
| 218 | if (!LinkGraph::IsValidID(ge.link_graph) || |
| 219 | ge.link_graph != to->goods[cargo].link_graph) { |
| 220 | continue; |
| 221 | } |
| 222 | const LinkGraph &lg = *LinkGraph::Get(ge.link_graph); |
| 223 | if (lg[ge.node].HasEdgeTo(to->goods[cargo].node)) { |
| 224 | ConstEdge &edge = lg[ge.node][to->goods[cargo].node]; |
| 225 | this->AddStats(cargo, lg.Monthly(edge.capacity), lg.Monthly(edge.usage), |
| 226 | ge.HasData() ? ge.GetData().flows.GetFlowVia(to->index) : 0, |
| 227 | edge.TravelTime() / Ticks::DAY_TICKS, |
| 228 | from->owner == OWNER_NONE || to->owner == OWNER_NONE, |
| 229 | this->cached_links[from->index][to->index]); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Add information from a given pair of link stat and flow stat to the given |
no test coverage detected