summaryrefslogtreecommitdiff
path: root/ai_new.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-08-20 17:04:10 +0000
committertruelight <truelight@openttd.org>2004-08-20 17:04:10 +0000
commitb783051b7031366ee77dc080066f1eccf4a0afe3 (patch)
tree4effd3e100a1bd5d388fd524d652ded6cf14ae2c /ai_new.c
parentf5240ffa00a25e2f0d3b6ba9694091ad493f8cc7 (diff)
downloadopenttd-b783051b7031366ee77dc080066f1eccf4a0afe3.tar.xz
(svn r96) -Fix: [AI] An industry can have no town, which caused crashes
Diffstat (limited to 'ai_new.c')
-rw-r--r--ai_new.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ai_new.c b/ai_new.c
index df4cad4b7..0c03b3893 100644
--- a/ai_new.c
+++ b/ai_new.c
@@ -234,7 +234,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type) {
int count = 0;
int j = 0;
- if (i->town->ratings[_current_player] < 0 && CHANCE16(1,4)) return false;
+ if (i->town != NULL && i->town->ratings[_current_player] < 0 && CHANCE16(1,4)) return false;
// No limits on delevering stations!
// Or for industry that does not give anything yet
@@ -487,8 +487,7 @@ static bool AiNew_CheckVehicleStation(Player *p, Station *st) {
FOR_ALL_VEHICLES(v) {
if (v->owner == _current_player) {
sched = v->schedule_ptr;
- if (sched == NULL) continue;
- while ((ord=*sched++) != 0) {
+ while (sched != NULL && (ord=*sched++) != 0) {
if ((ord & OT_MASK) == OT_GOTO_STATION && DEREF_STATION(ord >> 8) == st) {
// This vehicle has this city in his list
count++;