summaryrefslogtreecommitdiff
path: root/src/newgrf_airport.h
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-12-09 19:30:30 +0000
committeryexo <yexo@openttd.org>2011-12-09 19:30:30 +0000
commitc9be5d50dac64fe9fefe1a1e85d4eeaf8cc2470c (patch)
treeb9ca1f44038117b6c621e448b6e87e2a2897685b /src/newgrf_airport.h
parent42c4fdf9ab6c9123609afdf5a0dde3f3164795fd (diff)
downloadopenttd-c9be5d50dac64fe9fefe1a1e85d4eeaf8cc2470c.tar.xz
(svn r23461) -Fix: handle a missing airport newgrf as graceful as possible by not crashing when loading such savegame or when an airport is removed
Diffstat (limited to 'src/newgrf_airport.h')
-rw-r--r--src/newgrf_airport.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h
index b00c3667c..ca2ce1576 100644
--- a/src/newgrf_airport.h
+++ b/src/newgrf_airport.h
@@ -18,6 +18,7 @@
#include "newgrf_class.h"
#include "newgrf_commons.h"
#include "gfx_type.h"
+#include "tilearea_type.h"
/** Copy from station_map.h */
typedef byte StationGfx;
@@ -28,6 +29,39 @@ struct AirportTileTable {
StationGfx gfx; ///< AirportTile to use for this tile.
};
+/** Iterator to iterate over all tiles belonging to an airport spec. */
+class AirportTileTableIterator : public TileIterator {
+private:
+ const AirportTileTable *att; ///< The offsets.
+ TileIndex base_tile; ///< The tile we base the offsets off.
+
+public:
+ /**
+ * Construct the iterator.
+ * @param att The TileTable we want to iterate over.
+ * @param base_tile The basetile for all offsets.
+ */
+ AirportTileTableIterator(const AirportTileTable *att, TileIndex base_tile) : TileIterator(base_tile + ToTileIndexDiff(att->ti)), att(att), base_tile(base_tile)
+ {
+ }
+
+ FORCEINLINE TileIterator& operator ++()
+ {
+ this->att++;
+ if (this->att->ti.x == -0x80) {
+ this->tile = INVALID_TILE;
+ } else {
+ this->tile = base_tile + ToTileIndexDiff(att->ti);
+ }
+ return *this;
+ }
+
+ virtual AirportTileTableIterator *Clone() const
+ {
+ return new AirportTileTableIterator(*this);
+ }
+};
+
/** List of default airport classes. */
enum AirportClassID {
APC_BEGIN = 0, ///< Lowest valid airport class id