mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 03:12:41 +01:00
(svn r13352) [0.6] -Backport from trunk (r13348, r13222, r13221, r13217):
- Fix: Industry tiles would sometimes tell they need a 'level' slope when they do not want the slope (r13348) - Fix: Attempts to make the old AI perform better (r13217, r13221, r13222)
This commit is contained in:
@@ -3377,7 +3377,8 @@ static void AiStateAirportStuff(Player *p)
|
||||
|
||||
AirportFTAClass::Flags flags = st->Airport()->flags;
|
||||
|
||||
if (!(flags & (_players_ai[p->index].build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
|
||||
/* if airport doesn't accept our kind of plane, dismiss it */
|
||||
if (!(flags & (_players_ai[p->index].build_kind == 1 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3463,12 +3464,29 @@ 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++) {
|
||||
uint flags = GetAirport(p->attr)->flags;
|
||||
if (HasBit(valid, p->attr) && (flags & AirportFTAClass::AIRPLANES) && !(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))
|
||||
|
||||
@@ -330,6 +330,20 @@ static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y)
|
||||
|
||||
static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh)
|
||||
{
|
||||
IndustryGfx gfx = GetIndustryGfx(tile);
|
||||
|
||||
/* For NewGRF industry tiles we might not be drawing a foundation. We need to
|
||||
* account for this, otherwise we might be applying a FOUNDATION_LEVELED
|
||||
* on a steep slope which is not allowed. Furthermore other structures should
|
||||
* draw the wall of the foundation in this case.
|
||||
*/
|
||||
if (gfx >= NEW_INDUSTRYTILEOFFSET) {
|
||||
const IndustryTileSpec *indts = GetIndustryTileSpec(gfx);
|
||||
if (indts->grf_prop.spritegroup != NULL && HasBit(indts->callback_flags, CBM_INDT_DRAW_FOUNDATIONS)) {
|
||||
uint32 callback_res = GetIndustryTileCallback(CBID_INDUSTRY_DRAW_FOUNDATIONS, 0, 0, gfx, GetIndustryByTile(tile), tile);
|
||||
if (callback_res == 0) return FOUNDATION_NONE;
|
||||
}
|
||||
}
|
||||
return FlatteningFoundation(tileh);
|
||||
}
|
||||
|
||||
|
||||
@@ -591,15 +591,27 @@ static const AiDefaultBlockData _airportdata_ai_5[] = {
|
||||
MKEND(),
|
||||
};
|
||||
|
||||
static const AiDefaultBlockData _airportdata_ai_6[] = {
|
||||
MKAIR(6, 0, 0),
|
||||
MKEND(),
|
||||
};
|
||||
|
||||
static const AiDefaultBlockData _airportdata_ai_7[] = {
|
||||
MKAIR(7, 0, 0),
|
||||
MKEND(),
|
||||
};
|
||||
|
||||
static const AiDefaultBlockData _airportdata_ai_8[] = {
|
||||
MKAIR(8, 0, 0),
|
||||
MKEND(),
|
||||
};
|
||||
|
||||
#undef MKAIR
|
||||
#undef MDEND
|
||||
|
||||
static const AiDefaultBlockData * const _airport_default_block_data[] = {
|
||||
_airportdata_ai_8, // helistation
|
||||
_airportdata_ai_6, // helidepot
|
||||
_airportdata_ai_7, // intercontinental airport
|
||||
_airportdata_ai_4, // international airport
|
||||
_airportdata_ai_3, // metropolitan airport
|
||||
|
||||
Reference in New Issue
Block a user