summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-06-12 14:53:57 +0000
committeryexo <yexo@openttd.org>2009-06-12 14:53:57 +0000
commit4b349579877e13eff8fc48ae9e003222f794cdba (patch)
tree841c4b0bfdff66629fbcb4ebcf89a0a501d25608
parent88a20b7ea2734eb3d79b21b7a8ac8926f18967a1 (diff)
downloadopenttd-4b349579877e13eff8fc48ae9e003222f794cdba.tar.xz
(svn r16566) -Codechange: enumify all airport tiles
-rw-r--r--src/airport.cpp199
-rw-r--r--src/airport.h3
-rw-r--r--src/station_cmd.cpp96
3 files changed, 203 insertions, 95 deletions
diff --git a/src/airport.cpp b/src/airport.cpp
index d099cc34b..fb96e9fb4 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -11,6 +11,205 @@
#include "date_func.h"
#include "settings_type.h"
+
+/* 8-66 are mapped to 0-58, 83+ are mapped to 59+ */
+enum AirportTiles {
+ APT_APRON = 8,
+ APT_APRON_FENCE_NW = 9,
+ APT_APRON_FENCE_SW = 10,
+ APT_STAND = 11,
+ APT_APRON_W = 12,
+ APT_APRON_S = 13,
+ APT_APRON_VER_CROSSING_S = 14,
+ APT_APRON_HOR_CROSSING_W = 15,
+ APT_APRON_VER_CROSSING_N = 16,
+ APT_APRON_HOR_CROSSING_E = 17,
+ APT_APRON_E = 18,
+ APT_ARPON_N = 19,
+ APT_APRON_HOR = 20,
+ APT_APRON_N_FENCE_SW = 21,
+ APT_RUNWAY_1 = 22,
+ APT_RUNWAY_2 = 23,
+ APT_RUNWAY_3 = 24,
+ APT_RUNWAY_4 = 25,
+ APT_RUNWAY_END_FENCE_SE = 26,
+ APT_BUILDING_2 = 27,
+ APT_TOWER_FENCE_SW = 28,
+ APT_ROUND_TERMINAL = 29,
+ APT_BUILDING_3 = 30,
+ APT_BUILDING_1 = 31,
+ APT_DEPOT_SE = 32,
+ APT_STAND_1 = 33,
+ APT_STAND_PIER_NE = 34,
+ APT_PIER_NW_NE = 35,
+ APT_PIER = 36,
+ APT_EMPTY = 37,
+ APT_EMPTY_FENCE_NE = 38,
+ APT_RADAR_GRASS_FENCE_SW = 39,
+ /* 40-50 are for turning the radar */
+ APT_RADIO_TOWER_FENCE_NE = 51,
+ APT_SMALL_BUILDING_3 = 52,
+ APT_SMALL_BUILDING_2 = 53,
+ APT_SMALL_BUILDING_1 = 54,
+ APT_GRASS_FENCE_SW = 55,
+ APT_GRASS_2 = 56,
+ APT_GRASS_1 = 57,
+ APT_GRASS_FENCE_NE_FLAG = 58,
+ /* 59-61 are for flag animation */
+ APT_RUNWAY_SMALL_NEAR_END = 62,
+ APT_RUNWAY_SMALL_MIDDLE = 63,
+ APT_RUNWAY_SMALL_FAR_END = 64,
+ APT_SMALL_DEPOT_SE = 65,
+ APT_HELIPORT = 66,
+ APT_RUNWAY_END = 83,
+ APT_RUNWAY_5 = 84,
+ APT_TOWER = 85,
+ APT_SMALL_DEPOT_SE_2 = 86, // unused (copy of 65)
+ APT_APRON_FENCE_NE = 87,
+ APT_RUNWAY_END_FENCE_NW = 88,
+ APT_RUNWAY_FENCE_NW = 89,
+ APT_RADAR_FENCE_SW = 90,
+ /* 91-101 are for turning the radar */
+ APT_RADAR_FENCE_NE = 102,
+ /* 103-113 are for turning the radar */
+ APT_HELIPAD_1 = 114,
+ APT_HELIPAD_2_FENCE_NW = 115,
+ APT_HELIPAD_2 = 116,
+ APT_APRON_FENCE_NE_SW = 117,
+ APT_RUNWAY_END_FENCE_NW_SW = 118,
+ APT_RUNWAY_END_FENCE_SE_SW = 119,
+ APT_RUNWAY_END_FENCE_NE_NW = 120,
+ APT_RUNWAY_END_FENCE_NE_SE = 121,
+ APT_HELIPAD_2_FENCE_NE_SE = 122,
+ APT_APRON_FENCE_SE_SW = 123,
+ APT_LOW_BUILDING_FENCE_N = 124,
+ APT_ROT_RUNWAY_FENCE_NE = 125, // unused
+ APT_ROT_RUNWAY_END_FENCE_NE= 126, // unused
+ APT_ROT_RUNWAY_FENCE_SW = 127, // unused
+ APT_ROT_RUNWAY_END_FENCE_SW= 128, // unused
+ APT_DEPOT_SW = 129, // unused
+ APT_DEPOT_NW = 130, // unused
+ APT_DEPOT_NE = 131, // unused
+ APT_HELIPAD_2_FENCE_SE_SW = 132, // unused
+ APT_HELIPAD_2_FENCE_SE = 133, // unused
+ APT_LOW_BUILDING_FENCE_NW = 134,
+ APT_LOW_BUILDING_FENCE_NE = 135, // unused
+ APT_LOW_BUILDING_FENCE_SW = 136, // unused
+ APT_LOW_BUILDING_FENCE_SE = 137, // unused
+ APT_STAND_FENCE_NE = 138, // unused
+ APT_STAND_FENCE_SE = 139, // unused
+ APT_STAND_FENCE_SW = 140, // unused
+ APT_APRON_FENCE_NE_2 = 141, // unused (copy of 87)
+ APT_APRON_FENCE_SE = 142,
+ APT_HELIPAD_2_FENCE_NW_SW = 143, // unused
+ APT_HELIPAD_2_FENCE_SW = 144, // unused
+ APT_RADAR_FENCE_SE = 145, // unused
+ /* 146-156 used for radar rotation */
+ APT_HELIPAD_3_FENCE_SE_SW = 157,
+ APT_HELIPAD_3_FENCE_NW_SW = 158,
+ APT_HELIPAD_3_FENCE_NW = 159,
+ APT_LOW_BUILDING = 160,
+ APT_APRON_FENCE_NE_SE = 161,
+ APT_APRON_HALF_EAST = 162,
+ APT_APRON_HALF_WEST = 163,
+ APT_GRASS_FENCE_NE_FLAG_2 = 164,
+ APT_GRASS_2_FENCE_NE_FLAG = 165,
+ /* 166-169 used for flag animation */
+};
+
+/** Tiles for Country Airfield (small) */
+static const byte _airport_sections_country[] = {
+ APT_SMALL_BUILDING_1, APT_SMALL_BUILDING_2, APT_SMALL_BUILDING_3, APT_SMALL_DEPOT_SE,
+ APT_GRASS_FENCE_NE_FLAG, APT_GRASS_1, APT_GRASS_2, APT_GRASS_FENCE_SW,
+ APT_RUNWAY_SMALL_FAR_END, APT_RUNWAY_SMALL_MIDDLE, APT_RUNWAY_SMALL_MIDDLE, APT_RUNWAY_SMALL_NEAR_END
+};
+
+/** Tiles for City Airport (large) */
+static const byte _airport_sections_town[] = {
+ APT_BUILDING_1, APT_APRON_FENCE_NW, APT_STAND_1, APT_APRON_FENCE_NW, APT_APRON_FENCE_NW, APT_DEPOT_SE,
+ APT_BUILDING_2, APT_PIER, APT_ROUND_TERMINAL, APT_STAND_PIER_NE, APT_APRON, APT_APRON_FENCE_SW,
+ APT_BUILDING_3, APT_STAND, APT_PIER_NW_NE, APT_APRON_S, APT_APRON_HOR, APT_APRON_N_FENCE_SW,
+ APT_RADIO_TOWER_FENCE_NE, APT_APRON_W, APT_APRON_VER_CROSSING_S, APT_APRON_HOR_CROSSING_E, APT_ARPON_N, APT_TOWER_FENCE_SW,
+ APT_EMPTY_FENCE_NE, APT_APRON_S, APT_APRON_HOR_CROSSING_W, APT_APRON_VER_CROSSING_N, APT_APRON_E, APT_RADAR_GRASS_FENCE_SW,
+ APT_RUNWAY_END_FENCE_SE, APT_RUNWAY_1, APT_RUNWAY_2, APT_RUNWAY_3, APT_RUNWAY_4, APT_RUNWAY_END_FENCE_SE
+};
+
+/** Tiles for Metropolitain Airport (large) - 2 runways */
+static const byte _airport_sections_metropolitan[] = {
+ APT_BUILDING_1, APT_APRON_FENCE_NW, APT_STAND_1, APT_APRON_FENCE_NW, APT_APRON_FENCE_NW, APT_DEPOT_SE,
+ APT_BUILDING_2, APT_PIER, APT_ROUND_TERMINAL, APT_STAND_PIER_NE, APT_APRON, APT_APRON_FENCE_SW,
+ APT_BUILDING_3, APT_STAND, APT_PIER_NW_NE, APT_APRON_S, APT_APRON_HOR, APT_APRON_N_FENCE_SW,
+ APT_RADAR_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_TOWER_FENCE_SW,
+ APT_RUNWAY_END, APT_RUNWAY_5, APT_RUNWAY_5, APT_RUNWAY_5, APT_RUNWAY_5, APT_RUNWAY_END,
+ APT_RUNWAY_END_FENCE_SE, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_END_FENCE_SE
+};
+
+/** Tiles for International Airport (large) - 2 runways */
+static const byte _airport_sections_international[] = {
+ APT_RUNWAY_END_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_END_FENCE_NW,
+ APT_RADIO_TOWER_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_DEPOT_SE,
+ APT_BUILDING_3, APT_APRON, APT_STAND, APT_BUILDING_2, APT_STAND, APT_APRON, APT_APRON_FENCE_SW,
+ APT_DEPOT_SE, APT_APRON, APT_STAND, APT_BUILDING_2, APT_STAND, APT_APRON, APT_HELIPAD_1,
+ APT_APRON_FENCE_NE, APT_APRON, APT_STAND, APT_TOWER, APT_STAND, APT_APRON, APT_HELIPAD_1,
+ APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_RADAR_FENCE_SW,
+ APT_RUNWAY_END_FENCE_SE, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_END_FENCE_SE
+};
+
+/** Tiles for Intercontinental Airport (vlarge) - 4 runways */
+static const byte _airport_sections_intercontinental[] = {
+ APT_RADAR_FENCE_NE, APT_RUNWAY_END_FENCE_NE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_END_FENCE_NW_SW,
+ APT_RUNWAY_END_FENCE_NE_NW, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_END_FENCE_SE_SW, APT_APRON_FENCE_NE_SW,
+ APT_APRON_FENCE_NE, APT_SMALL_BUILDING_1, APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON, APT_RADIO_TOWER_FENCE_NE, APT_APRON_FENCE_NE_SW,
+ APT_APRON_FENCE_NE, APT_APRON_HALF_EAST, APT_APRON_FENCE_NE, APT_TOWER, APT_HELIPAD_2, APT_HELIPAD_2, APT_APRON, APT_APRON_FENCE_NW, APT_APRON_FENCE_SW,
+ APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_STAND, APT_BUILDING_1, APT_STAND, APT_APRON, APT_LOW_BUILDING, APT_DEPOT_SE,
+ APT_DEPOT_SE, APT_LOW_BUILDING, APT_APRON, APT_STAND, APT_BUILDING_2, APT_STAND, APT_APRON, APT_APRON, APT_APRON_FENCE_SW,
+ APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_STAND, APT_BUILDING_3, APT_STAND, APT_APRON, APT_APRON, APT_APRON_FENCE_SW,
+ APT_APRON_FENCE_NE, APT_APRON_FENCE_SE, APT_APRON, APT_STAND, APT_ROUND_TERMINAL, APT_STAND, APT_APRON_FENCE_SW, APT_APRON_HALF_WEST, APT_APRON_FENCE_SW,
+ APT_APRON_FENCE_NE, APT_GRASS_FENCE_NE_FLAG_2, APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON_FENCE_SW, APT_EMPTY, APT_APRON_FENCE_NE_SW,
+ APT_APRON_FENCE_NE, APT_RUNWAY_END_FENCE_NE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_FENCE_NW, APT_RUNWAY_END_FENCE_SE_SW,
+ APT_RUNWAY_END_FENCE_NE_SE, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_END_FENCE_SE_SW, APT_EMPTY
+};
+
+
+/** Tiles for Commuter Airfield (small) */
+static const byte _airport_sections_commuter[] = {
+ APT_TOWER, APT_BUILDING_3, APT_HELIPAD_2_FENCE_NW, APT_HELIPAD_2_FENCE_NW, APT_DEPOT_SE,
+ APT_APRON_FENCE_NE, APT_APRON, APT_APRON, APT_APRON, APT_APRON_FENCE_SW,
+ APT_APRON_FENCE_NE, APT_STAND, APT_STAND, APT_STAND, APT_APRON_FENCE_SW,
+ APT_RUNWAY_END_FENCE_SE, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_2, APT_RUNWAY_END_FENCE_SE
+};
+
+/** Tiles for Heliport */
+static const byte _airport_sections_heliport[] = {
+ APT_HELIPORT,
+};
+
+/** Tiles for Helidepot */
+static const byte _airport_sections_helidepot[] = {
+ APT_LOW_BUILDING_FENCE_N, APT_DEPOT_SE,
+ APT_HELIPAD_2_FENCE_NE_SE, APT_APRON_FENCE_SE_SW
+};
+
+/** Tiles for Helistation */
+static const byte _airport_sections_helistation[] = {
+ APT_DEPOT_SE, APT_LOW_BUILDING_FENCE_NW, APT_HELIPAD_3_FENCE_NW, APT_HELIPAD_3_FENCE_NW_SW,
+ APT_APRON_FENCE_NE_SE, APT_APRON_FENCE_SE, APT_APRON_FENCE_SE, APT_HELIPAD_3_FENCE_SE_SW
+};
+
+const byte * const _airport_sections[] = {
+ _airport_sections_country, // Country Airfield (small)
+ _airport_sections_town, // City Airport (large)
+ _airport_sections_heliport, // Heliport
+ _airport_sections_metropolitan, // Metropolitain Airport (large)
+ _airport_sections_international, // International Airport (xlarge)
+ _airport_sections_commuter, // Commuter Airport (small)
+ _airport_sections_helidepot, // Helidepot
+ _airport_sections_intercontinental, // Intercontinental Airport (xxlarge)
+ _airport_sections_helistation, // Helistation
+};
+
+assert_compile(NUM_AIRPORTS == lengthof(_airport_sections));
+
/* Uncomment this to print out a full report of the airport-structure
* You should either use
* - true: full-report, print out every state and choice with string-names
diff --git a/src/airport.h b/src/airport.h
index 47f852a17..e459187f8 100644
--- a/src/airport.h
+++ b/src/airport.h
@@ -27,6 +27,7 @@ enum {
AT_HELIDEPOT = 6,
AT_INTERCON = 7,
AT_HELISTATION = 8,
+ NUM_AIRPORTS = 9,
AT_OILRIG = 15,
AT_DUMMY = 255
};
@@ -200,4 +201,6 @@ const AirportFTAClass *GetAirport(const byte airport_type);
*/
uint32 GetValidAirports();
+extern const byte * const _airport_sections[];
+
#endif /* AIRPORT_H */
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 0c4ee2de4..fd4f505a8 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1599,99 +1599,6 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
return ret;
}
-/* FIXME -- need to move to its corresponding Airport variable*/
-
-/* Country Airfield (small) */
-static const byte _airport_sections_country[] = {
- 54, 53, 52, 65,
- 58, 57, 56, 55,
- 64, 63, 63, 62
-};
-
-/* City Airport (large) */
-static const byte _airport_sections_town[] = {
- 31, 9, 33, 9, 9, 32,
- 27, 36, 29, 34, 8, 10,
- 30, 11, 35, 13, 20, 21,
- 51, 12, 14, 17, 19, 28,
- 38, 13, 15, 16, 18, 39,
- 26, 22, 23, 24, 25, 26
-};
-
-/* Metropolitain Airport (large) - 2 runways */
-static const byte _airport_sections_metropolitan[] = {
- 31, 9, 33, 9, 9, 32,
- 27, 36, 29, 34, 8, 10,
- 30, 11, 35, 13, 20, 21,
- 102, 8, 8, 8, 8, 28,
- 83, 84, 84, 84, 84, 83,
- 26, 23, 23, 23, 23, 26
-};
-
-/* International Airport (large) - 2 runways */
-static const byte _airport_sections_international[] = {
- 88, 89, 89, 89, 89, 89, 88,
- 51, 8, 8, 8, 8, 8, 32,
- 30, 8, 11, 27, 11, 8, 10,
- 32, 8, 11, 27, 11, 8, 114,
- 87, 8, 11, 85, 11, 8, 114,
- 87, 8, 8, 8, 8, 8, 90,
- 26, 23, 23, 23, 23, 23, 26
-};
-
-/* Intercontinental Airport (vlarge) - 4 runways */
-static const byte _airport_sections_intercontinental[] = {
- 102, 120, 89, 89, 89, 89, 89, 89, 118,
- 120, 23, 23, 23, 23, 23, 23, 119, 117,
- 87, 54, 87, 8, 8, 8, 8, 51, 117,
- 87, 162, 87, 85, 116, 116, 8, 9, 10,
- 87, 8, 8, 11, 31, 11, 8, 160, 32,
- 32, 160, 8, 11, 27, 11, 8, 8, 10,
- 87, 8, 8, 11, 30, 11, 8, 8, 10,
- 87, 142, 8, 11, 29, 11, 10, 163, 10,
- 87, 164, 87, 8, 8, 8, 10, 37, 117,
- 87, 120, 89, 89, 89, 89, 89, 89, 119,
- 121, 23, 23, 23, 23, 23, 23, 119, 37
-};
-
-
-/* Commuter Airfield (small) */
-static const byte _airport_sections_commuter[] = {
- 85, 30, 115, 115, 32,
- 87, 8, 8, 8, 10,
- 87, 11, 11, 11, 10,
- 26, 23, 23, 23, 26
-};
-
-/* Heliport */
-static const byte _airport_sections_heliport[] = {
- 66,
-};
-
-/* Helidepot */
-static const byte _airport_sections_helidepot[] = {
- 124, 32,
- 122, 123
-};
-
-/* Helistation */
-static const byte _airport_sections_helistation[] = {
- 32, 134, 159, 158,
- 161, 142, 142, 157
-};
-
-static const byte * const _airport_sections[] = {
- _airport_sections_country, // Country Airfield (small)
- _airport_sections_town, // City Airport (large)
- _airport_sections_heliport, // Heliport
- _airport_sections_metropolitan, // Metropolitain Airport (large)
- _airport_sections_international, // International Airport (xlarge)
- _airport_sections_commuter, // Commuter Airport (small)
- _airport_sections_helidepot, // Helidepot
- _airport_sections_intercontinental, // Intercontinental Airport (xxlarge)
- _airport_sections_helistation // Helistation
-};
-
/**
* Computes the minimal distance from town's xy to any airport's tile.
* @param afc airport's description
@@ -1793,7 +1700,6 @@ void UpdateAirportsNoise()
}
}
-
/** Place an Airport.
* @param tile tile where airport will be built
* @param flags operation to perform
@@ -1813,7 +1719,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (distant_join && (!_settings_game.station.distant_join_stations || !Station::IsValidID(station_to_join))) return CMD_ERROR;
/* Check if a valid, buildable airport was chosen for construction */
- if (p1 >= lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
+ if (p1 >= NUM_AIRPORTS || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
if (!CheckIfAuthorityAllowsNewStation(tile, flags)) {
return CMD_ERROR;