summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_cmd.c3
-rw-r--r--airport.c17
-rw-r--r--airport.h3
-rw-r--r--airport_movement.h14
4 files changed, 17 insertions, 20 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 11cfec92b..d6af6737d 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -218,8 +218,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
byte i = 0;
st = DEREF_STATION(_map2[tile]);
Airport = GetAirport(st->airport_type);
- // first element of depot array contains #of depots on the airport
- for (cur_depot=&Airport->airport_depots[1]; i != Airport->airport_depots[0]; cur_depot++) {
+ for (cur_depot = Airport->airport_depots; i != Airport->nof_depots; cur_depot++) {
if ((uint)(st->airport_tile + *cur_depot) == tile) {
assert(Airport->layout[i].heading == HANGAR);
v->u.air.pos = Airport->layout[i].position;
diff --git a/airport.c b/airport.c
index 7b6c96276..96d2473be 100644
--- a/airport.c
+++ b/airport.c
@@ -14,7 +14,7 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
const byte nofhelipads, const byte nofhelipadgroups,
const byte entry_point, const byte acc_planes,
const AirportFTAbuildup *FA,
- const TileIndex *depots);
+ const TileIndex *depots, const byte nof_depots);
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
@@ -27,23 +27,23 @@ void InitializeAirports()
{
// country airport
CountryAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
- AirportFTAClass_Constructor(CountryAirport, 2, 1, 0, 0, 16, ALL, _airport_fta_country, _airport_depots_country);
+ AirportFTAClass_Constructor(CountryAirport, 2, 1, 0, 0, 16, ALL, _airport_fta_country, _airport_depots_country, lengthof(_airport_depots_country));
// city airport
CityAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
- AirportFTAClass_Constructor(CityAirport, 3, 1, 0, 0, 19, ALL, _airport_fta_city, _airport_depots_city);
+ AirportFTAClass_Constructor(CityAirport, 3, 1, 0, 0, 19, ALL, _airport_fta_city, _airport_depots_city, lengthof(_airport_depots_city));
// metropolitan airport
MetropolitanAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
- AirportFTAClass_Constructor(MetropolitanAirport, 3, 1, 0, 0, 20, ALL, _airport_fta_metropolitan, _airport_depots_metropolitan);
+ AirportFTAClass_Constructor(MetropolitanAirport, 3, 1, 0, 0, 20, ALL, _airport_fta_metropolitan, _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan));
// international airport
InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
- AirportFTAClass_Constructor(InternationalAirport, 6, 2, 2, 1, 37, ALL, _airport_fta_international, _airport_depots_international);
+ AirportFTAClass_Constructor(InternationalAirport, 6, 2, 2, 1, 37, ALL, _airport_fta_international, _airport_depots_international, lengthof(_airport_depots_international));
// heliport, oilrig
Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
- AirportFTAClass_Constructor(Heliport, 0, 0, 1, 1, 7, HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, _airport_depots_heliport_oilrig);
+ AirportFTAClass_Constructor(Heliport, 0, 0, 1, 1, 7, HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, NULL, 0);
Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine
}
@@ -61,7 +61,7 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
const byte nofhelipads, const byte nofhelipadgroups,
const byte entry_point, const byte acc_planes,
const AirportFTAbuildup *FA,
- const TileIndex *depots)
+ const TileIndex *depots, const byte nof_depots)
{
// if there are more terminals than 6, internal variables have to be changed, so don't allow that
// same goes for helipads
@@ -89,7 +89,8 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
Airport->nofhelipadgroups = nofhelipadgroups;
Airport->acc_planes = acc_planes;
Airport->entry_point = entry_point;
- Airport->airport_depots = (const uint16*)depots;
+ Airport->airport_depots = depots;
+ Airport->nof_depots = nof_depots;
// build the state machine
diff --git a/airport.h b/airport.h
index 128bd8c3e..38bb62f45 100644
--- a/airport.h
+++ b/airport.h
@@ -32,7 +32,8 @@ typedef struct AirportFTAClass {
byte nofhelipadgroups; // helipads belong to so many groups (MAX is the nofhelipads)
byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point
byte acc_planes; // accept airplanes or helicopters or both
- const uint16 *airport_depots; // gives the position of the depots on the airports
+ const TileIndex *airport_depots; // gives the position of the depots on the airports
+ byte nof_depots; // number of depots this airport has
struct AirportFTA *layout; // state machine for airport
} AirportFTAClass;
diff --git a/airport_movement.h b/airport_movement.h
index 31029197f..5fa1dfcc2 100644
--- a/airport_movement.h
+++ b/airport_movement.h
@@ -4,10 +4,6 @@
#include "stdafx.h"
#include "macros.h"
-// don't forget to change the airport_depots too for larger mapsizes. TILE_X_BITS 16
-// won't fit in uint16 for example and overflow will occur in the checking code!
-// TrueLight -- So make it a TileIndex..
-
typedef struct AirportMovingData {
int x,y;
byte flag;
@@ -267,7 +263,7 @@ static const AirportMovingData _airport_moving_data_oilrig[9] = {
/////**********Movement Machine on Airports*********************///////
// first element of depots array tells us how many depots there are (to know size of array)
// this may be changed later when airports are moved to external file
-static const TileIndex _airport_depots_country[] = {1, TILE_XY(3,0)};
+static const TileIndex _airport_depots_country[] = {TILE_XY(3,0)};
static const AirportFTAbuildup _airport_fta_country[] = {
{ 0,HANGAR,NOTHING_block,1},
{ 1,255,AIRPORT_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM1,TERM1_block,2}, {1,TERM2,0,4}, {1,HELITAKEOFF,0,19}, {1,0,0,6},
@@ -297,7 +293,7 @@ static const AirportFTAbuildup _airport_fta_country[] = {
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
-static const TileIndex _airport_depots_city[] = {1, TILE_XY(5,0)};
+static const TileIndex _airport_depots_city[] = {TILE_XY(5,0)};
static const AirportFTAbuildup _airport_fta_city[] = {
{ 0,HANGAR,NOTHING_block,1}, {0,TAKEOFF,OUT_WAY_block,1}, {0,0,0,1},
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
@@ -331,7 +327,7 @@ static const AirportFTAbuildup _airport_fta_city[] = {
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
-static const TileIndex _airport_depots_metropolitan[] = {1, TILE_XY(5,0)};
+static const TileIndex _airport_depots_metropolitan[] = {TILE_XY(5,0)};
static const AirportFTAbuildup _airport_fta_metropolitan[] = {
{ 0,HANGAR,NOTHING_block,1},
{ 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7
@@ -367,7 +363,7 @@ static const AirportFTAbuildup _airport_fta_metropolitan[] = {
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
-static const TileIndex _airport_depots_international[] = {2, TILE_XY(0,3), TILE_XY(6,1)};
+static const TileIndex _airport_depots_international[] = {TILE_XY(0,3), TILE_XY(6,1)};
static const AirportFTAbuildup _airport_fta_international[] = {
{ 0,HANGAR,NOTHING_block,2}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER1_block,1}, {0,HELITAKEOFF,HELIPAD1_block,2}, {0,0,0,2},
{ 1,HANGAR,NOTHING_block,3}, {1,255,HANGAR2_AREA_block,1}, {1,HELITAKEOFF,HELIPAD2_block,3}, {1,0,0,3},
@@ -429,7 +425,7 @@ static const AirportFTAbuildup _airport_fta_international[] = {
{MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE
};
-static const TileIndex _airport_depots_heliport_oilrig[] = {0};
+// heliports, oilrigs don't have depots
static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = {
{0,HELIPAD1,HELIPAD1_block,1},
{1,HELITAKEOFF,NOTHING_block,0}, // takeoff