summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-01 11:27:39 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-01 11:27:39 +0000
commitd1fa0742a5cf4b25ef35a312ddf8918c015e9ce5 (patch)
treef9b79e6bc23b89c636bd561a097b8f9bc78d971c
parent80a75e35738c505727fc546868fb34db3cc52a56 (diff)
downloadopenttd-d1fa0742a5cf4b25ef35a312ddf8918c015e9ce5.tar.xz
(svn r4642) - Codechange: reorganise airport.h and airport_movement.h to avoid having 8 copies of the airport FTAs, and make the enums used available elsewhere.
-rw-r--r--aircraft_cmd.c3
-rw-r--r--airport.c8
-rw-r--r--airport.h75
-rw-r--r--airport_movement.h76
-rw-r--r--disaster_cmd.c2
5 files changed, 83 insertions, 81 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index fbe131399..6aaf33fda 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -772,8 +772,7 @@ static bool AircraftController(Vehicle *v)
}
// get airport moving data
- assert(v->u.air.pos < GetAirport(st->airport_type)->nofelements);
- amd = &_airport_moving_datas[st->airport_type][v->u.air.pos];
+ amd = GetAirportMovingData(st->airport_type, v->u.air.pos);
// Helicopter raise
if (amd->flag & AMED_HELI_RAISE) {
diff --git a/airport.c b/airport.c
index a3fbf3af9..42401f676 100644
--- a/airport.c
+++ b/airport.c
@@ -7,6 +7,7 @@
#include "airport.h"
#include "macros.h"
#include "variables.h"
+#include "airport_movement.h"
static AirportFTAClass* CountryAirport;
static AirportFTAClass* CityAirport;
@@ -371,6 +372,13 @@ const AirportFTAClass* GetAirport(const byte airport_type)
return Airport;
}
+const AirportMovingData *GetAirportMovingData(byte airport_type, byte position)
+{
+ assert(airport_type < lengthof(_airport_moving_datas));
+ assert(position < GetAirport(airport_type)->nofelements);
+ return &_airport_moving_datas[airport_type][position];
+}
+
uint32 GetValidAirports(void)
{
uint32 bytemask = _avail_aircraft; /// sets the first 3 bytes, 0 - 2, @see AdjustAvailAircraft()
diff --git a/airport.h b/airport.h
index 8a9d4b60b..78f11e3ed 100644
--- a/airport.h
+++ b/airport.h
@@ -3,10 +3,10 @@
#ifndef AIRPORT_H
#define AIRPORT_H
-#include "airport_movement.h"
-
enum {MAX_TERMINALS = 6};
enum {MAX_HELIPADS = 2};
+enum {MAX_ELEMENTS = 255};
+enum {MAX_HEADINGS = 18};
// Airport types
enum {
@@ -25,6 +25,76 @@ enum {
HELICOPTERS_ONLY = 2,
};
+enum {
+ AMED_NOSPDCLAMP = 1<<0,
+ AMED_TAKEOFF = 1<<1,
+ AMED_SLOWTURN = 1<<2,
+ AMED_LAND = 1<<3,
+ AMED_EXACTPOS = 1<<4,
+ AMED_BRAKE = 1<<5,
+ AMED_HELI_RAISE = 1<<6,
+ AMED_HELI_LOWER = 1<<7,
+};
+
+/* Movement States on Airports (headings target) */
+enum {
+ TO_ALL,
+ HANGAR,
+ TERM1,
+ TERM2,
+ TERM3,
+ TERM4,
+ TERM5,
+ TERM6,
+ HELIPAD1,
+ HELIPAD2,
+ TAKEOFF,
+ STARTTAKEOFF,
+ ENDTAKEOFF,
+ HELITAKEOFF,
+ FLYING,
+ LANDING,
+ ENDLANDING,
+ HELILANDING,
+ HELIENDLANDING,
+};
+
+/* Movement Blocks on Airports */
+// blocks (eg_airport_flags)
+enum {
+ TERM1_block = 1 << 0,
+ TERM2_block = 1 << 1,
+ TERM3_block = 1 << 2,
+ TERM4_block = 1 << 3,
+ TERM5_block = 1 << 4,
+ TERM6_block = 1 << 5,
+ HELIPAD1_block = 1 << 6,
+ HELIPAD2_block = 1 << 7,
+ RUNWAY_IN_OUT_block = 1 << 8,
+ RUNWAY_IN_block = 1 << 8,
+ AIRPORT_BUSY_block = 1 << 8,
+ RUNWAY_OUT_block = 1 << 9,
+ TAXIWAY_BUSY_block = 1 << 10,
+ OUT_WAY_block = 1 << 11,
+ IN_WAY_block = 1 << 12,
+ AIRPORT_ENTRANCE_block = 1 << 13,
+ TERM_GROUP1_block = 1 << 14,
+ TERM_GROUP2_block = 1 << 15,
+ HANGAR2_AREA_block = 1 << 16,
+ TERM_GROUP2_ENTER1_block = 1 << 17,
+ TERM_GROUP2_ENTER2_block = 1 << 18,
+ TERM_GROUP2_EXIT1_block = 1 << 19,
+ TERM_GROUP2_EXIT2_block = 1 << 20,
+ PRE_HELIPAD_block = 1 << 21,
+ NOTHING_block = 1 << 30,
+};
+
+typedef struct AirportMovingData {
+ int x,y;
+ byte flag;
+ byte direction;
+} AirportMovingData;
+
// Finite sTate mAchine --> FTA
typedef struct AirportFTAClass {
byte nofelements; // number of positions the airport consists of
@@ -49,6 +119,7 @@ typedef struct AirportFTA {
void InitializeAirports(void);
void UnInitializeAirports(void);
const AirportFTAClass* GetAirport(const byte airport_type);
+const AirportMovingData *GetAirportMovingData(byte airport_type, byte position);
/** Get buildable airport bitmask.
* @return get all buildable airports at this given time, bitmasked.
diff --git a/airport_movement.h b/airport_movement.h
index 5869928cc..fe62bf627 100644
--- a/airport_movement.h
+++ b/airport_movement.h
@@ -3,13 +3,6 @@
#ifndef AIRPORT_MOVEMENT_H
#define AIRPORT_MOVEMENT_H
-#include "stdafx.h"
-
-typedef struct AirportMovingData {
- int x,y;
- byte flag;
- byte direction;
-} AirportMovingData;
// state machine input struct (from external file, etc.)
// Finite sTate mAchine --> FTA
@@ -20,75 +13,6 @@ typedef struct AirportFTAbuildup {
byte next_in_chain; // next position from this position
} AirportFTAbuildup;
-enum {
- AMED_NOSPDCLAMP = 1<<0,
- AMED_TAKEOFF = 1<<1,
- AMED_SLOWTURN = 1<<2,
- AMED_LAND = 1<<3,
- AMED_EXACTPOS = 1<<4,
- AMED_BRAKE = 1<<5,
- AMED_HELI_RAISE = 1<<6,
- AMED_HELI_LOWER = 1<<7,
-};
-
-enum {MAX_ELEMENTS = 255};
-enum {MAX_HEADINGS = 18};
-
-///////////////////////////////////////////////////////////////////////
-///////***********Movement States on Airports********************//////
-// headings target
-enum {
- TO_ALL = 0,
- HANGAR = 1,
- TERM1 = 2,
- TERM2 = 3,
- TERM3 = 4,
- TERM4 = 5,
- TERM5 = 6,
- TERM6 = 7,
- HELIPAD1 = 8,
- HELIPAD2 = 9,
- TAKEOFF = 10,
- STARTTAKEOFF = 11,
- ENDTAKEOFF = 12,
- HELITAKEOFF = 13,
- FLYING = 14,
- LANDING = 15,
- ENDLANDING = 16,
- HELILANDING = 17,
- HELIENDLANDING = 18
-};
-
-///////////////////////////////////////////////////////////////////////
-///////**********Movement Blocks on Airports*********************//////
-// blocks (eg_airport_flags)
-enum {
- TERM1_block = 1 << 0,
- TERM2_block = 1 << 1,
- TERM3_block = 1 << 2,
- TERM4_block = 1 << 3,
- TERM5_block = 1 << 4,
- TERM6_block = 1 << 5,
- HELIPAD1_block = 1 << 6,
- HELIPAD2_block = 1 << 7,
- RUNWAY_IN_OUT_block = 1 << 8,
- RUNWAY_IN_block = 1 << 8,
- AIRPORT_BUSY_block = 1 << 8,
- RUNWAY_OUT_block = 1 << 9,
- TAXIWAY_BUSY_block = 1 << 10,
- OUT_WAY_block = 1 << 11,
- IN_WAY_block = 1 << 12,
- AIRPORT_ENTRANCE_block = 1 << 13,
- TERM_GROUP1_block = 1 << 14,
- TERM_GROUP2_block = 1 << 15,
- HANGAR2_AREA_block = 1 << 16,
- TERM_GROUP2_ENTER1_block = 1 << 17,
- TERM_GROUP2_ENTER2_block = 1 << 18,
- TERM_GROUP2_EXIT1_block = 1 << 19,
- TERM_GROUP2_EXIT2_block = 1 << 20,
- PRE_HELIPAD_block = 1 << 21,
- NOTHING_block = 1 << 30
-};
///////////////////////////////////////////////////////////////////////
/////*********Movement Positions on Airports********************///////
diff --git a/disaster_cmd.c b/disaster_cmd.c
index ec1301405..7ca50a7cb 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -16,7 +16,7 @@
#include "town.h"
#include "industry.h"
#include "player.h"
-#include "airport_movement.h"
+#include "airport.h"
#include "sound.h"
#include "variables.h"
#include "table/sprites.h"