diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index 45b2244bd7..9fb5348c0a 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -130,8 +130,8 @@ struct AirportSpec { /** Get the index of this spec. */ uint8_t GetIndex() const { - assert(this >= specs && this < endof(specs)); - return (uint8_t)(this - specs); + assert(this >= std::begin(specs) && this < std::end(specs)); + return static_cast(std::distance(std::cbegin(specs), this)); } static const AirportSpec dummy; ///< The dummy airport.