summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-05-23 00:28:13 +0000
committersmatz <smatz@openttd.org>2008-05-23 00:28:13 +0000
commitbaeb6e5395a15a3842d9847e7d1125c3196f10f4 (patch)
tree03700dbafbb61e9d203f1686f516bf8123e63303 /src
parent11e80b2794f8256d98741254ba0939ef3ce27d51 (diff)
downloadopenttd-baeb6e5395a15a3842d9847e7d1125c3196f10f4.tar.xz
(svn r13217) -Fix: old AI was building small airports in years when they were not available in original game, causing small planes and helis everywhere
Diffstat (limited to 'src')
-rw-r--r--src/ai/default/default.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 5af37de10..2af2da82a 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -3438,12 +3438,28 @@ static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p,
static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, CommandCost *cost)
{
const AiDefaultBlockData *p;
- uint i;
- 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)->flags & AirportFTAClass::HELICOPTERS)) continue;
+ bool no_small = false;
+
+ if (!heli) {
+ /* do not build small airport if we have large available and we are not building heli route */
+ uint valid = GetValidAirports();
+ for (uint i = 0; (p = _airport_default_block_data[i]) != NULL; i++) {
+ if (HasBit(valid, p->attr) && !(GetAirport(p->attr)->flags & AirportFTAClass::SHORT_STRIP)) {
+ no_small = true;
+ break;
+ }
+ }
+ }
+
+ for (uint i = 0; (p = _airport_default_block_data[i]) != NULL; i++) {
+ uint flags = GetAirport(p->attr)->flags;
+ /* If we are doing a helicopter service, avoid building airports where they can't land */
+ if (heli && !(flags & AirportFTAClass::HELICOPTERS)) continue;
+ /* Similiar with aircraft ... */
+ if (!heli && !(flags & AirportFTAClass::AIRPLANES)) continue;
+ /* Do not build small airport if we prefer large */
+ if (no_small && (flags & AirportFTAClass::SHORT_STRIP)) continue;
*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
if (CmdSucceeded(*cost) && AiCheckAirportResources(tile, p, cargo))