src/airport.cpp
author richk
Tue, 21 Aug 2007 19:33:49 +0000
branchNewGRF_ports
changeset 6856 0e8e4ebf23ff
parent 6854 92ca286e9466
child 6871 5a9dc001e1ad
permissions -rw-r--r--
(svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2159
diff changeset
     2
6443
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6413
diff changeset
     3
/** @file airport.cpp */
b8f06d8eb7be (svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents: 6413
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1299
diff changeset
     6
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1093
diff changeset
     7
#include "debug.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 222
diff changeset
     8
#include "map.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include "airport.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1891
diff changeset
    10
#include "macros.h"
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 1891
diff changeset
    11
#include "variables.h"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 4171
diff changeset
    12
#include "date.h"
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    13
#include "helpers.hpp"
6818
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
    14
#include "newgrf_fsmports.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
6854
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    16
/* static */ AirportFTAClass *AirportFTAClass::oil_rig; ///< "Special" holding pattern used for oil rigs.
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    17
/* static */ AirportFTAClass *AirportFTAClass::dummy;   ///< A dummy holding pattern to be used when an airport has been removed, but the order to go to the airport has not been removed.
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    18
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    19
/* Uncomment this to print out a full report of the airport-structure
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    20
 * You should either use
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    21
 * - true: full-report, print out every state and choice with string-names
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    22
 * OR
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    23
 * - false: give a summarized report which only shows current and next position */
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    24
//#define DEBUG_AIRPORT false
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    25
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    26
static byte AirportTestFTA(uint num_positions, const AirportFTA *layout, const byte *terminals);
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    27
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    28
#ifdef DEBUG_AIRPORT
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents: 6837
diff changeset
    29
static void AirportPrintOut(uint nof_elements, const AirportFTA *layout, bool full_report);
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    30
#endif
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    31
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    32
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    33
AirportFTAClass::~AirportFTAClass()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
{
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    35
	for (uint i = 0; i < num_positions; i++) {
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    36
		AirportFTA *current = layout[i].next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
		while (current != NULL) {
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    38
			AirportFTA *next = current->next;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
			free(current);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
			current = next;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
		};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	}
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    43
	free(layout);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    46
static byte AirportTestFTA(uint num_positions, const AirportFTA *layout, const byte *terminals)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
{
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    48
	uint next_position = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    50
	for (uint i = 0; i < num_positions; i++) {
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    51
		uint position = layout[i].position;
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    52
		if (position != next_position) return i;
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    53
		const AirportFTA *first = &layout[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
6413
3d660a812fbd (svn r8822) -Fix
tron
parents: 6367
diff changeset
    55
		for (const AirportFTA *current = first; current != NULL; current = current->next) {
4844
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    56
			/* A heading must always be valid. The only exceptions are
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    57
			 * - multiple choices as start, identified by a special value of 255
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    58
			 * - terminal group which is identified by a special value of 255 */
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    59
			if (current->heading > MAX_HEADINGS) {
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    60
				if (current->heading != 255) return i;
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    61
				if (current == first && current->next == NULL) return i;
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
    62
				if (current != first && current->next_position > terminals[0]) return i;
4844
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    63
			}
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    64
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    65
			/* If there is only one choice, it must be at the end */
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    66
			if (current->heading == 0 && current->next != NULL) return i;
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    67
			/* Obviously the elements of the linked list must have the same identifier */
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    68
			if (position != current->position) return i;
4844
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    69
			/* A next position must be within bounds */
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    70
			if (current->next_position >= num_positions) return i;
4844
15faacbff622 (svn r6770) -Codechange: Make the airport checking a bit stricter...fix unnoticed errors:
Darkvater
parents: 4843
diff changeset
    71
		}
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    72
		next_position++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	return MAX_ELEMENTS;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
    77
#ifdef DEBUG_AIRPORT
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2186
diff changeset
    78
static const char* const _airport_heading_strings[] = {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	"TO_ALL",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	"HANGAR",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
	"TERM1",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	"TERM2",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	"TERM3",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	"TERM4",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	"TERM5",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	"TERM6",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	"HELIPAD1",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	"HELIPAD2",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	"TAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	"STARTTAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	"ENDTAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	"HELITAKEOFF",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	"FLYING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	"LANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	"ENDLANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	"HELILANDING",
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	"HELIENDLANDING",
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3876
diff changeset
    98
	"TERM7",
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3876
diff changeset
    99
	"TERM8",
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3876
diff changeset
   100
	"HELIPAD3",
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3876
diff changeset
   101
	"HELIPAD4",
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4294
diff changeset
   102
	"DUMMY" // extra heading for 255
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   105
static uint AirportBlockToString(uint32 block)
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   106
{
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   107
	uint i = 0;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   108
	if (block & 0xffff0000) { block >>= 16; i += 16; }
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   109
	if (block & 0x0000ff00) { block >>=  8; i +=  8; }
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   110
	if (block & 0x000000f0) { block >>=  4; i +=  4; }
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   111
	if (block & 0x0000000c) { block >>=  2; i +=  2; }
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   112
	if (block & 0x00000002) { i += 1; }
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   113
	return i;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   114
}
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4059
diff changeset
   115
6183
5d864a25ae2b (svn r8570) -Fix
tron
parents: 6175
diff changeset
   116
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents: 6837
diff changeset
   117
static void AirportPrintOut(uint nof_elements, const AirportFTA *layout, bool full_report)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
{
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   119
	if (!full_report) printf("(P = Current Position; NP = Next Position)\n");
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   120
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents: 6837
diff changeset
   121
	for (uint i = 0; i < nof_elements; i++) {
6413
3d660a812fbd (svn r8822) -Fix
tron
parents: 6367
diff changeset
   122
		for (const AirportFTA *current = &layout[i]; current != NULL; current = current->next) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
			if (full_report) {
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   124
				byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading;
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   125
				printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position,
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   126
					    current->next_position, _airport_heading_strings[heading],
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   127
							AirportBlockToString(current->block));
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2186
diff changeset
   128
			} else {
4843
724322df355a (svn r6769) -Codechange: Minor syntax, const correctness, variable localization, coding
Darkvater
parents: 4842
diff changeset
   129
				printf("P:%2d NP:%2d", current->position, current->next_position);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
		printf("\n");
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
}
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2186
diff changeset
   135
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
6818
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   137
std::list<uint16> GetAvailableAirports()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
{
6818
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   139
	std::list<uint16> airports;
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   140
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   141
	for (uint i = 0; i < GetNumFSMportsClasses(); i++) {
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   142
		for (uint j = 0; j < GetNumCustomFSMports((FSMportsClassID)i); j++) {
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   143
			const FSMportsSpec *spec = GetCustomFSMportsSpec((FSMportsClassID)i, j);
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   144
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   145
			if (!HASBIT(spec->callbackmask, CBM_STATION_AVAIL) ||
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   146
					GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, spec, NULL, INVALID_TILE) != 0) {
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   147
				airports.push_back(i << 8 | j);
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   148
			}
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   149
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	}
6818
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   151
8c977ca780fe (svn r10898) [NewGRF_ports] -Codechange: replace GetAirport and GetValidAiports by GetAvailableAirports which gives a list of available airports that (primarily) AIs can iterate over.
rubidium
parents: 6769
diff changeset
   152
	return airports;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}