Codechange: Make GetRail/RoadTypeInfoIndex() a member method.

This follows a similar pattern used for cargoes, houses and objects.

Also fixes incorrect documentation of GetRoadTypeInfoIndex().
This commit is contained in:
Peter Nelson
2025-09-09 18:00:54 +01:00
committed by dP
parent 0812a641ae
commit c6f657fb62
6 changed files with 30 additions and 28 deletions

View File

@@ -19,6 +19,18 @@
#include "safeguards.h"
/**
* Get the RailType for this RailTypeInfo.
* @return RailType in static RailTypeInfo definitions.
*/
RailType RailTypeInfo::Index() const
{
extern RailTypeInfo _railtypes[RAILTYPE_END];
size_t index = this - _railtypes;
assert(index < RAILTYPE_END);
return static_cast<RailType>(index);
}
/**
* Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
*/