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

Method AddEdge

src/linkgraph/linkgraph.cpp:167–177  ·  view source on GitHub ↗

* Fill an edge with values from a link. Set the restricted or unrestricted * update timestamp according to the given update mode. * @param to Destination node of the link. * @param capacity Capacity of the link. * @param usage Usage to be added. * @param mode Update mode to be used. */

Source from the content-addressed store, hash-verified

165 * @param mode Update mode to be used.
166 */
167void LinkGraph::BaseNode::AddEdge(NodeID to, uint capacity, uint usage, uint32_t travel_time, EdgeUpdateModes modes)
168{
169 assert(!this->HasEdgeTo(to));
170
171 BaseEdge &edge = *this->edges.emplace(std::upper_bound(this->edges.begin(), this->edges.end(), to), to);
172 edge.capacity = capacity;
173 edge.usage = usage;
174 edge.travel_time_sum = static_cast<uint64_t>(travel_time) * capacity;
175 if (modes.Test(EdgeUpdateMode::Unrestricted)) edge.last_unrestricted_update = TimerGameEconomy::date;
176 if (modes.Test(EdgeUpdateMode::Restricted)) edge.last_restricted_update = TimerGameEconomy::date;
177}
178
179/**
180 * Creates an edge if none exists yet or updates an existing edge.

Callers 1

UpdateEdgeMethod · 0.95

Calls 4

HasEdgeToMethod · 0.95
TestMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected