summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-09-21 16:19:52 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-09-21 16:19:52 +0000
commit9fdb88962fed69472a88861cf08d9559e8dff2a4 (patch)
treea0337c7ce519fb69e5458bc48c48f5fdc01396fa /src/station_cmd.cpp
parentf56b8ba69eb967a1b9c8f8ab89dd70eeb00a0f72 (diff)
downloadopenttd-9fdb88962fed69472a88861cf08d9559e8dff2a4.tar.xz
(svn r26891) -Codechange: Add methods to retrieve flows from a FlowStatMap
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index eb3e5de6a..0d8236ddc 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -4457,19 +4457,57 @@ void FlowStatMap::ReleaseFlows(StationID via)
}
/**
- * Get the sum of flows via a specific station from this GoodsEntry.
+ * Get the sum of all flows from this FlowStatMap.
+ * @return sum of all flows.
+ */
+uint FlowStatMap::GetFlow() const
+{
+ uint ret = 0;
+ for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
+ ret += (--(i->second.GetShares()->end()))->first;
+ }
+ return ret;
+}
+
+/**
+ * Get the sum of flows via a specific station from this FlowStatMap.
* @param via Remote station to look for.
- * @return a FlowStat with all flows for 'via' added up.
+ * @return all flows for 'via' added up.
*/
-uint GoodsEntry::GetSumFlowVia(StationID via) const
+uint FlowStatMap::GetFlowVia(StationID via) const
{
uint ret = 0;
- for (FlowStatMap::const_iterator i = this->flows.begin(); i != this->flows.end(); ++i) {
+ for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
ret += i->second.GetShare(via);
}
return ret;
}
+/**
+ * Get the sum of flows from a specific station from this FlowStatMap.
+ * @param from Origin station to look for.
+ * @return all flows from 'from' added up.
+ */
+uint FlowStatMap::GetFlowFrom(StationID from) const
+{
+ FlowStatMap::const_iterator i = this->find(from);
+ if (i == this->end()) return 0;
+ return (--(i->second.GetShares()->end()))->first;
+}
+
+/**
+ * Get the flow from a specific station via a specific other station.
+ * @param from Origin station to look for.
+ * @param via Remote station to look for.
+ * @return flow share originating at 'from' and going to 'via'.
+ */
+uint FlowStatMap::GetFlowFromVia(StationID from, StationID via) const
+{
+ FlowStatMap::const_iterator i = this->find(from);
+ if (i == this->end()) return 0;
+ return i->second.GetShare(via);
+}
+
extern const TileTypeProcs _tile_type_station_procs = {
DrawTile_Station, // draw_tile_proc
GetSlopePixelZ_Station, // get_slope_z_proc