mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use AirportSpec::index instead of GetIndex().
GetIndex() used pointer arithmetic to determine the index, which is already known.pull/12864/head
parent
891e53c72e
commit
53c96df94b
|
@ -64,7 +64,7 @@ static void PlaceAirport(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (_selected_airport_index == -1) return;
|
if (_selected_airport_index == -1) return;
|
||||||
|
|
||||||
uint8_t airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
|
uint8_t airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->index;
|
||||||
uint8_t layout = _selected_airport_layout;
|
uint8_t layout = _selected_airport_layout;
|
||||||
bool adjacent = _ctrl_pressed;
|
bool adjacent = _ctrl_pressed;
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ public:
|
||||||
if (as->IsAvailable()) {
|
if (as->IsAvailable()) {
|
||||||
_selected_airport_class = cls.Index();
|
_selected_airport_class = cls.Index();
|
||||||
this->vscroll->SetCount(cls.GetSpecCount());
|
this->vscroll->SetCount(cls.GetSpecCount());
|
||||||
this->SelectOtherAirport(as->GetIndex());
|
this->SelectOtherAirport(as->index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ AirportResolverObject::AirportResolverObject(TileIndex tile, Station *st, uint8_
|
||||||
|
|
||||||
SpriteID GetCustomAirportSprite(const AirportSpec *as, uint8_t layout)
|
SpriteID GetCustomAirportSprite(const AirportSpec *as, uint8_t layout)
|
||||||
{
|
{
|
||||||
AirportResolverObject object(INVALID_TILE, nullptr, as->GetIndex(), layout);
|
AirportResolverObject object(INVALID_TILE, nullptr, as->index, layout);
|
||||||
const SpriteGroup *group = object.Resolve();
|
const SpriteGroup *group = object.Resolve();
|
||||||
if (group == nullptr) return as->preview_sprite;
|
if (group == nullptr) return as->preview_sprite;
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ uint16_t GetAirportCallback(CallbackID callback, uint32_t param1, uint32_t param
|
||||||
*/
|
*/
|
||||||
StringID GetAirportTextCallback(const AirportSpec *as, uint8_t layout, uint16_t callback)
|
StringID GetAirportTextCallback(const AirportSpec *as, uint8_t layout, uint16_t callback)
|
||||||
{
|
{
|
||||||
AirportResolverObject object(INVALID_TILE, nullptr, as->GetIndex(), layout, (CallbackID)callback);
|
AirportResolverObject object(INVALID_TILE, nullptr, as->index, layout, (CallbackID)callback);
|
||||||
uint16_t cb_res = object.ResolveCallback();
|
uint16_t cb_res = object.ResolveCallback();
|
||||||
if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED;
|
if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED;
|
||||||
if (cb_res > 0x400) {
|
if (cb_res > 0x400) {
|
||||||
|
|
|
@ -128,13 +128,6 @@ struct AirportSpec : NewGRFSpecBase<AirportClassID> {
|
||||||
|
|
||||||
static void ResetAirports();
|
static void ResetAirports();
|
||||||
|
|
||||||
/** Get the index of this spec. */
|
|
||||||
uint8_t GetIndex() const
|
|
||||||
{
|
|
||||||
assert(this >= std::begin(specs) && this < std::end(specs));
|
|
||||||
return static_cast<uint8_t>(std::distance(std::cbegin(specs), this));
|
|
||||||
}
|
|
||||||
|
|
||||||
static const AirportSpec dummy; ///< The dummy airport.
|
static const AirportSpec dummy; ///< The dummy airport.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue