(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
This commit is contained in:
@@ -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 */
|
||||
|
Reference in New Issue
Block a user