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

Method AddLinks

src/linkgraph/linkgraph_gui.cpp:213–232  ·  view source on GitHub ↗

* Add all "interesting" links between the given stations to the cache. * @param from The source station. * @param to The destination station. */

Source from the content-addressed store, hash-verified

211 * @param to The destination station.
212 */
213void 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

Callers 1

RebuildCacheMethod · 0.95

Calls 7

AddStatsMethod · 0.95
HasEdgeToMethod · 0.80
MonthlyMethod · 0.80
GetFlowViaMethod · 0.80
TravelTimeMethod · 0.80
IsValidMethod · 0.45
HasDataMethod · 0.45

Tested by

no test coverage detected