summaryrefslogtreecommitdiff
path: root/src/station_base.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/station_base.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/station_base.h')
-rw-r--r--src/station_base.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/station_base.h b/src/station_base.h
index 2a7fedbf7..5ec337f56 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -17,6 +17,7 @@
#include "cargopacket.h"
#include "industry_type.h"
#include "newgrf_storage.h"
+#include "town.h"
typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
extern StationPool _station_pool;
@@ -261,4 +262,34 @@ public:
#define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var)
+/** Iterator to iterate over all tiles belonging to an airport. */
+class AirportTileIterator : public OrthogonalTileIterator {
+private:
+ const Station *st; ///< The station the airport is a part of.
+
+public:
+ /**
+ * Construct the iterator.
+ * @param ta Area, i.e. begin point and width/height of to-be-iterated area.
+ */
+ AirportTileIterator(const Station *st) : OrthogonalTileIterator(st->airport), st(st)
+ {
+ if (!st->TileBelongsToAirport(this->tile)) ++(*this);
+ }
+
+ FORCEINLINE TileIterator& operator ++()
+ {
+ (*this).OrthogonalTileIterator::operator++();
+ while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
+ (*this).OrthogonalTileIterator::operator++();
+ }
+ return *this;
+ }
+
+ virtual TileIterator *Clone() const
+ {
+ return new AirportTileIterator(*this);
+ }
+};
+
#endif /* STATION_BASE_H */