summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--projects/openttd_vs90.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/airport.cpp27
-rw-r--r--src/airport.h23
-rw-r--r--src/station_cmd.cpp41
-rw-r--r--src/station_map.h14
-rw-r--r--src/table/airport_defaults.h4
-rw-r--r--src/table/airporttiles.h200
9 files changed, 263 insertions, 55 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index f8f1d79f3..694d02efb 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -2176,6 +2176,10 @@
>
</File>
<File
+ RelativePath=".\..\src\table\airporttiles.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\table\airport_movement.h"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 8c9c4962e..f89f3b302 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -2173,6 +2173,10 @@
>
</File>
<File
+ RelativePath=".\..\src\table\airporttiles.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\table\airport_movement.h"
>
</File>
diff --git a/source.list b/source.list
index d8a9603b6..c656fd97f 100644
--- a/source.list
+++ b/source.list
@@ -474,6 +474,7 @@ saveload/waypoint_sl.cpp
# Tables
table/airport_defaults.h
+table/airporttiles.h
table/airport_movement.h
table/animcursors.h
table/autorail.h
diff --git a/src/airport.cpp b/src/airport.cpp
index 0de1033ff..351cb709d 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -123,10 +123,37 @@ enum AirportTiles {
};
#include "table/airport_defaults.h"
+#include "table/airporttiles.h"
AirportSpec AirportSpec::dummy = {NULL, NULL, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR};
AirportSpec AirportSpec::oilrig = {NULL, NULL, 0, 1, 1, 0, 4, MIN_YEAR, MIN_YEAR};
+
+/**
+ * Retrieve airport spec for the given airport
+ * @param type index of airport
+ * @return A pointer to the corresponding AirportSpec
+ */
+/* static */ const AirportSpec *AirportSpec::Get(byte type)
+{
+ if (type == AT_OILRIG) return &oilrig;
+ assert(type < NUM_AIRPORTS);
+ extern const AirportSpec _origin_airport_specs[];
+ return &_origin_airport_specs[type];
+}
+
+/**
+ * Retrieve airport tile spec for the given airport tile
+ * @param gfx index of airport tile
+ * @return A pointer to the corresponding AirportTileSpec
+ */
+/* static */ const AirportTileSpec *AirportTileSpec::Get(StationGfx gfx)
+{
+ assert(gfx < NUM_AIRPORTTILES);
+ extern const AirportTileSpec _origin_airporttile_specs[];
+ return &_origin_airporttile_specs[gfx];
+}
+
/* 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 20c8c8787..99e262e37 100644
--- a/src/airport.h
+++ b/src/airport.h
@@ -21,6 +21,11 @@ enum {
MAX_TERMINALS = 10, ///< maximum number of terminals per airport
MAX_HELIPADS = 4, ///< maximum number of helipads per airport
MAX_ELEMENTS = 255, ///< maximum number of aircraft positions at airport
+ NUM_AIRPORTTILES = 144, ///< total number of airport tiles
+};
+
+enum {
+ AIRPORTTILE_NOANIM = 0xFF, ///< flag to mark airport tiles as having no animation
};
/** Airport types */
@@ -61,13 +66,7 @@ struct AirportSpec {
Year min_year; ///< first year the airport is available
Year max_year; ///< last year the airport is available
- static AirportSpec *Get(byte type)
- {
- if (type == AT_OILRIG) return &oilrig;
- assert(type < NUM_AIRPORTS);
- extern AirportSpec _origin_airport_specs[NUM_AIRPORTS];
- return &_origin_airport_specs[type];
- }
+ static const AirportSpec *Get(byte type);
bool IsAvailable() const;
@@ -76,6 +75,16 @@ struct AirportSpec {
};
+/**
+ * Defines the data structure of each indivudual tile of an airport.
+ */
+struct AirportTileSpec {
+ StationGfx anim_next; ///< Next StationGfx in an animation
+ uint8 animation_speed; ///< The speed of the animation
+
+ static const AirportTileSpec *Get(StationGfx gfx);
+};
+
enum {
AMED_NOSPDCLAMP = 1 << 0,
AMED_TAKEOFF = 1 << 1,
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 3285482b4..ff3fd4b12 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2596,15 +2596,8 @@ static void TileLoop_Station(TileIndex tile)
* hardcoded.....not good */
switch (GetStationType(tile)) {
case STATION_AIRPORT:
- switch (GetStationGfx(tile)) {
- case GFX_RADAR_LARGE_FIRST:
- case GFX_WINDSACK_FIRST : // for small airport
- case GFX_RADAR_INTERNATIONAL_FIRST:
- case GFX_RADAR_METROPOLITAN_FIRST:
- case GFX_RADAR_DISTRICTWE_FIRST: // radar district W-E airport
- case GFX_WINDSACK_INTERCON_FIRST : // for intercontinental airport
- AddAnimatedTile(tile);
- break;
+ if (AirportTileSpec::Get(GetStationGfx(tile))->anim_next != AIRPORTTILE_NOANIM) {
+ AddAnimatedTile(tile);
}
break;
@@ -2623,35 +2616,17 @@ static void TileLoop_Station(TileIndex tile)
static void AnimateTile_Station(TileIndex tile)
{
- struct AnimData {
- StationGfx from; // first sprite
- StationGfx to; // last sprite
- byte delay;
- };
-
- static const AnimData data[] = {
- { GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 },
- { GFX_WINDSACK_FIRST, GFX_WINDSACK_LAST, 1 },
- { GFX_RADAR_INTERNATIONAL_FIRST, GFX_RADAR_INTERNATIONAL_LAST, 3 },
- { GFX_RADAR_METROPOLITAN_FIRST, GFX_RADAR_METROPOLITAN_LAST, 3 },
- { GFX_RADAR_DISTRICTWE_FIRST, GFX_RADAR_DISTRICTWE_LAST, 3 },
- { GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST, 1 }
- };
-
if (HasStationRail(tile)) {
AnimateStationTile(tile);
return;
}
- StationGfx gfx = GetStationGfx(tile);
-
- for (const AnimData *i = data; i != endof(data); i++) {
- if (i->from <= gfx && gfx <= i->to) {
- if ((_tick_counter & i->delay) == 0) {
- SetStationGfx(tile, gfx < i->to ? gfx + 1 : i->from);
- MarkTileDirtyByTile(tile);
- }
- break;
+ if (IsAirport(tile)) {
+ const AirportTileSpec *ats = AirportTileSpec::Get(GetStationGfx(tile));
+ uint16 mask = (1 << ats->animation_speed) - 1;
+ if (ats->anim_next != AIRPORTTILE_NOANIM && (_tick_counter & mask) == 0) {
+ SetStationGfx(tile, ats->anim_next);
+ MarkTileDirtyByTile(tile);
}
}
}
diff --git a/src/station_map.h b/src/station_map.h
index 53627b4cf..f4b3b691a 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -32,22 +32,8 @@ static inline StationID GetStationIndex(TileIndex t)
enum {
- GFX_RADAR_LARGE_FIRST = 31,
- GFX_RADAR_LARGE_LAST = 42,
- GFX_WINDSACK_FIRST = 50,
- GFX_WINDSACK_LAST = 53,
-
GFX_DOCK_BASE_WATER_PART = 4,
GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4,
-
- GFX_RADAR_INTERNATIONAL_FIRST = 66,
- GFX_RADAR_INTERNATIONAL_LAST = 77,
- GFX_RADAR_METROPOLITAN_FIRST = 78,
- GFX_RADAR_METROPOLITAN_LAST = 89,
- GFX_RADAR_DISTRICTWE_FIRST = 121,
- GFX_RADAR_DISTRICTWE_LAST = 132,
- GFX_WINDSACK_INTERCON_FIRST = 140,
- GFX_WINDSACK_INTERCON_LAST = 143,
};
/**
diff --git a/src/table/airport_defaults.h b/src/table/airport_defaults.h
index 2876b5810..84b67eb78 100644
--- a/src/table/airport_defaults.h
+++ b/src/table/airport_defaults.h
@@ -388,7 +388,7 @@ static AirportTileTable *_tile_table_helistation[] = {
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise) \
AS_GENERIC(_tile_table_##ap_name, _airport_depots_##ap_name, lengthof(_airport_depots_##ap_name), size_x, size_y, noise, catchment, min_year, max_year)
-AirportSpec _origin_airport_specs[NUM_AIRPORTS] = {
+static const AirportSpec _origin_airport_specs[] = {
AS(country, 4, 3, 0, 1959, 4, 3),
AS(city, 6, 6, 1960, MAX_YEAR, 5, 5),
AS_ND(heliport, 1, 1, 1963, MAX_YEAR, 4, 1),
@@ -400,6 +400,8 @@ AirportSpec _origin_airport_specs[NUM_AIRPORTS] = {
AS(helistation, 4, 2, 1980, MAX_YEAR, 4, 3),
};
+assert_compile(NUM_AIRPORTS == lengthof(_origin_airport_specs));
+
#undef AS
#undef AS_ND
#undef AS_GENERIC
diff --git a/src/table/airporttiles.h b/src/table/airporttiles.h
new file mode 100644
index 000000000..e3114f77a
--- /dev/null
+++ b/src/table/airporttiles.h
@@ -0,0 +1,200 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file airporttiles.h Tables with airporttile defaults. */
+
+#ifndef AIRPORTTILES_H
+#define AIRPORTTILES_H
+
+
+/** Writes all airport tile properties in the AirportTile struct */
+#define AT(anim_next, anim_speed) {anim_next, anim_speed}
+/** All default airport tiles.
+ * @see AirportTiles for a list of names. */
+static const AirportTileSpec _origin_airporttile_specs[] = {
+ /* 0..9 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 10..19 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 20..29*/
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 30..39*/
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT( 32, 2),
+ AT( 33, 2),
+ AT( 34, 2),
+ AT( 35, 2),
+ AT( 36, 2),
+ AT( 37, 2),
+ AT( 38, 2),
+ AT( 39, 2),
+ AT( 40, 2),
+
+ /* 40..49 */
+ AT( 41, 2),
+ AT( 42, 2),
+ AT( 31, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 50..59 */
+ AT( 51, 1),
+ AT( 52, 1),
+ AT( 53, 1),
+ AT( 50, 1),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 60..69 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT( 67, 2),
+ AT( 68, 2),
+ AT( 69, 2),
+ AT( 70, 2),
+
+ /* 70..79 */
+ AT( 71, 2),
+ AT( 72, 2),
+ AT( 73, 2),
+ AT( 74, 2),
+ AT( 75, 2),
+ AT( 76, 2),
+ AT( 77, 2),
+ AT( 66, 2),
+ AT( 79, 2),
+ AT( 80, 2),
+
+ /* 80..89 */
+ AT( 81, 2),
+ AT( 82, 2),
+ AT( 83, 2),
+ AT( 84, 2),
+ AT( 85, 2),
+ AT( 86, 2),
+ AT( 87, 2),
+ AT( 88, 2),
+ AT( 89, 2),
+ AT( 78, 2),
+
+ /* 90..99 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 100..109 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 110..119 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 120..129 */
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT( 122, 2),
+ AT( 123, 2),
+ AT( 124, 2),
+ AT( 125, 2),
+ AT( 126, 2),
+ AT( 127, 2),
+ AT( 128, 2),
+ AT( 129, 2),
+ AT( 130, 2),
+
+ /* 130..139 */
+ AT( 131, 2),
+ AT( 132, 2),
+ AT( 121, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+ AT(AIRPORTTILE_NOANIM, 2),
+
+ /* 140..143 */
+ AT( 141, 1),
+ AT( 142, 1),
+ AT( 143, 1),
+ AT( 140, 1),
+};
+
+assert_compile(NUM_AIRPORTTILES == lengthof(_origin_airporttile_specs));
+
+#undef AT
+
+#endif /* AIRPORTTILES_H */