summaryrefslogtreecommitdiff
path: root/src/station_cmd.cpp
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-04-08 19:28:14 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-04-08 19:28:14 +0000
commitbef953a32cd0a8bf3dad5cbbe2798dc3ab57ac5c (patch)
tree9f633a3b6904974299f030d829d5338a3ea7bbc4 /src/station_cmd.cpp
parenta9bdb92d19c1104488497f64cddffc71e044c707 (diff)
downloadopenttd-bef953a32cd0a8bf3dad5cbbe2798dc3ab57ac5c.tar.xz
(svn r26448) -Fix [FS#5970]: Avoid division by 0 when scaling flow values.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r--src/station_cmd.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 55b6fae14..d637d83c3 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -4314,9 +4314,11 @@ void FlowStat::ReleaseShare(StationID st)
/**
* Scale all shares from link graph's runtime to monthly values.
* @param runtime Time the link graph has been running without compression.
+ * @pre runtime must be greater than 0 as we don't want infinite flow values.
*/
void FlowStat::ScaleToMonthly(uint runtime)
{
+ assert(runtime > 0);
SharesMap new_shares;
uint share = 0;
for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {