Feature: [NewGRF] Related Act2 objects for airports and airport tiles.
Airports are similar two stations and industries, both of which have the town as related object.
Airport tiles are similar to industry tiles, which have the industry as related object.
This seems a sensible structure, so let's make it Airport Tile -> Airport -> Town.
(cherry picked from commit 1c620b349f)
This commit is contained in:
committed by
Jonathan G Rennison
parent
5cc623cb3c
commit
1637f6f6b0
@@ -14,6 +14,7 @@
|
||||
#include "newgrf_text.h"
|
||||
#include "station_base.h"
|
||||
#include "newgrf_class_func.h"
|
||||
#include "town.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -210,6 +211,26 @@ uint32 AirportResolverObject::GetDebugID() const
|
||||
this->st->airport.psa->StoreValue(pos, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the town scope associated with a station, if it exists.
|
||||
* On the first call, the town scope is created (if possible).
|
||||
* @return Town scope, if available.
|
||||
*/
|
||||
TownScopeResolver *AirportResolverObject::GetTown()
|
||||
{
|
||||
if (!this->town_scope) {
|
||||
Town *t = nullptr;
|
||||
if (this->airport_scope.st != nullptr) {
|
||||
t = this->airport_scope.st->town;
|
||||
} else if (this->airport_scope.tile != INVALID_TILE) {
|
||||
t = ClosestTownFromTile(this->airport_scope.tile, UINT_MAX);
|
||||
}
|
||||
if (t == nullptr) return nullptr;
|
||||
this->town_scope.reset(new TownScopeResolver(*this, t, this->airport_scope.st == nullptr));
|
||||
}
|
||||
return this->town_scope.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of the airport resolver.
|
||||
* @param tile %Tile for the callback, only valid for airporttile callbacks.
|
||||
|
||||
Reference in New Issue
Block a user