summaryrefslogtreecommitdiff
path: root/src/station_base.h
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2013-06-09 12:49:47 +0000
committerfonsinchen <fonsinchen@openttd.org>2013-06-09 12:49:47 +0000
commitdb671ffb8673c5088749663e64713d9b852ec1e5 (patch)
tree132d0af53b5101417f0ddd01feedc703d8d614a9 /src/station_base.h
parentc8f068d979251fb6963a56e3c0f9dac5b9897c72 (diff)
downloadopenttd-db671ffb8673c5088749663e64713d9b852ec1e5.tar.xz
(svn r25346) -Codechange: Glue between stations and flow stats
Diffstat (limited to 'src/station_base.h')
-rw-r--r--src/station_base.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/station_base.h b/src/station_base.h
index 200d97a97..b83c044a2 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -196,6 +196,7 @@ struct GoodsEntry {
LinkGraphID link_graph; ///< Link graph this station belongs to.
NodeID node; ///< ID of node in link graph referring to this goods entry.
+ FlowStatMap flows; ///< Planned flows through this station.
/**
* Reports whether a vehicle has ever tried to load the cargo at this station.
@@ -212,6 +213,33 @@ struct GoodsEntry {
{
return HasBit(this->acceptance_pickup, GES_PICKUP);
}
+
+ uint GetSumFlowVia(StationID via) const;
+
+ /**
+ * Get the best next hop for a cargo packet from station source.
+ * @param source Source of the packet.
+ * @return The chosen next hop or INVALID_STATION if none was found.
+ */
+ inline StationID GetVia(StationID source) const
+ {
+ FlowStatMap::const_iterator flow_it(this->flows.find(source));
+ return flow_it != this->flows.end() ? flow_it->second.GetVia() : INVALID_STATION;
+ }
+
+ /**
+ * Get the best next hop for a cargo packet from station source, optionally
+ * excluding one or two stations.
+ * @param source Source of the packet.
+ * @param excluded If this station would be chosen choose the second best one instead.
+ * @param excluded2 Second station to be excluded, if != INVALID_STATION.
+ * @return The chosen next hop or INVALID_STATION if none was found.
+ */
+ inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = INVALID_STATION) const
+ {
+ FlowStatMap::const_iterator flow_it(this->flows.find(source));
+ return flow_it != this->flows.end() ? flow_it->second.GetVia(excluded, excluded2) : INVALID_STATION;
+ }
};
/** All airport-related information. Only valid if tile != INVALID_TILE. */