summaryrefslogtreecommitdiff
path: root/ai/trolly
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-22 15:33:35 +0000
committertruelight <truelight@openttd.org>2006-08-22 15:33:35 +0000
commit0461d896123b918b492a3d16439bb46b041528cd (patch)
tree618708068f10739a382af83313db9c96b4744ef5 /ai/trolly
parent4c2abf1de53e28a5c3c6c6920efabc4653693c4c (diff)
downloadopenttd-0461d896123b918b492a3d16439bb46b041528cd.tar.xz
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
-Codechange: use IsValidXXX where ever possible Note: both changes to prepare for new pool system, which needs those changes. For every pool there are 2 ugly lines, which will be removed when done implementing new pool system. Based on FS#13 by blathijs, partly implemented.
Diffstat (limited to 'ai/trolly')
-rw-r--r--ai/trolly/trolly.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index aec49c9b8..ea41cdac3 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -231,8 +231,6 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// and sometimes it takes up to 4 months before the stats are corectly.
// This way we don't get 12 busstations in one city of 100 population ;)
FOR_ALL_STATIONS(st) {
- // Is it an active station
- if (st->xy == 0) continue;
// Do we own it?
if (st->owner == _current_player) {
// Are we talking busses?
@@ -291,9 +289,6 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type)
// else we don't do it. This is done, because stat updates can be slow
// and sometimes it takes up to 4 months before the stats are corectly.
FOR_ALL_STATIONS(st) {
- // Is it an active station
- if (st->xy == 0) continue;
-
// Do we own it?
if (st->owner == _current_player) {
// Are we talking trucks?
@@ -620,21 +615,19 @@ static void AiNew_State_FindStation(Player *p)
}
FOR_ALL_STATIONS(st) {
- if (st->xy != 0) {
- if (st->owner == _current_player) {
- if (p->ainew.tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) == FACIL_BUS_STOP) {
- if (st->town == town) {
- // Check how much cargo there is left in the station
- if ((st->goods[p->ainew.cargo].waiting_acceptance & 0xFFF) > RoadVehInfo(i)->capacity * AI_STATION_REUSE_MULTIPLER) {
- if (AiNew_CheckVehicleStation(p, st)) {
- // We did found a station that was good enough!
- new_tile = st->xy;
- direction = GetRoadStopDir(st->xy);
- break;
- }
+ if (st->owner == _current_player) {
+ if (p->ainew.tbt == AI_BUS && (FACIL_BUS_STOP & st->facilities) == FACIL_BUS_STOP) {
+ if (st->town == town) {
+ // Check how much cargo there is left in the station
+ if ((st->goods[p->ainew.cargo].waiting_acceptance & 0xFFF) > RoadVehInfo(i)->capacity * AI_STATION_REUSE_MULTIPLER) {
+ if (AiNew_CheckVehicleStation(p, st)) {
+ // We did found a station that was good enough!
+ new_tile = st->xy;
+ direction = GetRoadStopDir(st->xy);
+ break;
}
- count++;
}
+ count++;
}
}
}
@@ -1302,7 +1295,6 @@ static void AiNew_State_CheckAllVehicles(Player *p)
Vehicle *v;
FOR_ALL_VEHICLES(v) {
- if (v->type == 0) continue;
if (v->owner != p->index) continue;
// Currently, we only know how to handle road-vehicles
if (v->type != VEH_Road) continue;