summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-13 05:12:36 +0000
committerrubidium <rubidium@openttd.org>2008-08-13 05:12:36 +0000
commit08e7da71f520649359bbe40656a7c93e6ac2e1b0 (patch)
tree52a8477c52359e84033ce430194d603296d08b66 /src
parentc773d33cc3c5fa577f1308ab980fafb4703a5dbb (diff)
downloadopenttd-08e7da71f520649359bbe40656a7c93e6ac2e1b0.tar.xz
(svn r14062) -Fix [FS#2226]: division by 0 in newai.
Diffstat (limited to 'src')
-rw-r--r--src/ai/trolly/trolly.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index 849afb318..a195a4020 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -884,6 +884,7 @@ static int AiNew_HowManyVehicles(Player *p)
length = _players_ainew[p->index].path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16;
+ if (tiles_a_day == 0) tiles_a_day = 1;
// We want a vehicle in a station once a month at least, so, calculate it!
// (the * 2 is because we have 2 stations ;))
amount = length * 2 * 2 / tiles_a_day / 30;
@@ -900,6 +901,7 @@ static int AiNew_HowManyVehicles(Player *p)
length = _players_ainew[p->index].path_info.route_length;
// Calculating tiles a day a vehicle moves is not easy.. this is how it must be done!
tiles_a_day = RoadVehInfo(i)->max_speed * DAY_TICKS / 256 / 16;
+ if (tiles_a_day == 0) tiles_a_day = 1;
if (_players_ainew[p->index].from_deliver) {
max_cargo = GetIndustry(_players_ainew[p->index].from_ic)->last_month_production[0];
} else {