mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r1708) - Fix: FindNearestHangar() will no longer return a hangar where a jet will crash if it is a jet, that is searching
- Codechange: Since planes move in strait lines in 8 directions, GetTileDistAdv() is used instead of manhatten distance in FindNearestHangar()
This commit is contained in:
parent
dce0bbad6c
commit
41ca1be4ff
@ -37,16 +37,17 @@ static const SpriteID _aircraft_sprite[] = {
|
|||||||
// bit 16 is set in the return value if the player do not have any airports with a hangar (like helipads only)
|
// bit 16 is set in the return value if the player do not have any airports with a hangar (like helipads only)
|
||||||
static uint32 FindNearestHangar(Vehicle *v)
|
static uint32 FindNearestHangar(Vehicle *v)
|
||||||
{
|
{
|
||||||
/* TODO add a check to see if the aircraft can land at the airport */
|
|
||||||
Station *st;
|
Station *st;
|
||||||
uint32 temp_distance, distance = 65000;
|
uint temp_distance, distance = 0xFFFF;
|
||||||
uint16 index_to_target = 0;
|
uint16 index_to_target = 0;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
|
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
|
||||||
if (GetAirport(st->airport_type)->terminals != NULL) {
|
if (GetAirport(st->airport_type)->terminals != NULL) {
|
||||||
TileIndex airport_tile = st->airport_tile;
|
// don't crash the planes if we know they can't land at the airport
|
||||||
temp_distance = abs((v->x_pos >> 4) - TileX(airport_tile)) + abs((v->y_pos >> 4) - TileY(airport_tile));
|
if (HASBIT(v->subtype,1) && st->airport_type == AT_SMALL && !_cheats.no_jetcrash.value) continue;
|
||||||
|
|
||||||
|
temp_distance = GetTileDistAdv(v->tile, st->airport_tile);
|
||||||
if (temp_distance < distance) {
|
if (temp_distance < distance) {
|
||||||
distance = temp_distance;
|
distance = temp_distance;
|
||||||
index_to_target = st->index;
|
index_to_target = st->index;
|
||||||
|
Loading…
Reference in New Issue
Block a user