summaryrefslogtreecommitdiff
path: root/src/ai/default
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-02-15 20:16:33 +0000
committertron <tron@openttd.org>2007-02-15 20:16:33 +0000
commit16df3786233048ca5efd61d5bee80746f82914cb (patch)
tree5a513b927712a1ad28c59a6e84193e9ca2bbc851 /src/ai/default
parentab08096aab2746c607d24b544e8e21f1a8bd6d33 (diff)
downloadopenttd-16df3786233048ca5efd61d5bee80746f82914cb.tar.xz
(svn r8747) -Fix
-Codechange: Make the encoding of accepted aircraft types of airports a bit more sensible and move the enum into struct AirportFTAClass
Diffstat (limited to 'src/ai/default')
-rw-r--r--src/ai/default/default.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index f1e8063bf..f015de8be 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -3244,7 +3244,6 @@ static void AiStateDeleteRoadBlocks(Player *p)
static void AiStateAirportStuff(Player *p)
{
const Station* st;
- byte acc_planes;
int i;
AiBuildRec *aib;
byte rule;
@@ -3268,16 +3267,11 @@ static void AiStateAirportStuff(Player *p)
// Do we own the airport? (Oilrigs aren't owned, though.)
if (st->owner != OWNER_NONE && st->owner != _current_player) continue;
- acc_planes = GetAirport(st->airport_type)->acc_planes;
+ AirportFTAClass::Flags flags = GetAirport(st->airport_type)->flags;
- // Dismiss heliports, unless we are checking an oilrig.
- if (acc_planes == HELICOPTERS_ONLY && (p->ai.build_kind != 1 || i != 1))
- continue;
-
- // Dismiss country airports if we are doing the other
- // endpoint of an oilrig route.
- if (acc_planes == AIRCRAFT_ONLY && (p->ai.build_kind == 1 && i == 0))
+ if (!(flags & (p->ai.build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::PLANES))) {
continue;
+ }
// Dismiss airports too far away.
if (DistanceMax(st->airport_tile, aib->spec_tile) > aib->rand_rng)
@@ -3298,7 +3292,7 @@ static void AiStateAirportStuff(Player *p)
* broken because they will probably need different
* tileoff values etc), no matter that
* IsHangarTile() makes no sense. --pasky */
- if (acc_planes == HELICOPTERS_ONLY) {
+ if (!(flags & AirportFTAClass::PLANES)) {
/* Heliports should have maybe own rulesets but
* OTOH we don't want AI to pick them up when
* looking for a suitable airport type to build.
@@ -3372,7 +3366,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli,
for (i = 0; (p = _airport_default_block_data[i]) != NULL; i++) {
// If we are doing a helicopter service, avoid building
// airports where they can't land.
- if (heli && GetAirport(p->attr)->acc_planes == AIRCRAFT_ONLY) continue;
+ if (heli && !(GetAirport(p->attr)->flags & AirportFTAClass::HELICOPTERS)) continue;
*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo))