10 #ifndef NEWGRF_CLASS_H
11 #define NEWGRF_CLASS_H
16 template <
typename Tindex>
25 template <
typename Tspec,
typename Tindex, Tindex Tmax>
32 Tindex
index =
static_cast<Tindex
>(0);
39 static inline std::vector<NewGRFClass<Tspec, Tindex, Tmax>>
classes;
45 using spec_type = Tspec;
46 using index_type = Tindex;
58 std::span<Tspec * const>
Specs()
const {
return this->
spec; }
68 Tindex Index()
const {
return this->
index; }
70 uint
GetSpecCount()
const {
return static_cast<uint
>(this->spec.size()); }
86 static const Tspec *
GetByGrf(uint32_t grfid, uint16_t local_id);
Struct containing information relating to NewGRF classes for stations and airports.
Tindex index
Index of class within the list of classes.
std::span< Tspec *const > Specs() const
Get read-only span of specs of this class.
static void Assign(Tspec *spec)
Assign a spec to one of the classes.
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
StringID name
Name of this class.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
void Insert(Tspec *spec)
Insert a spec into the class, and update its index.
uint32_t global_id
Global ID for class, e.g. 'DFLT', 'WAYP', etc.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
static uint GetUIClassCount()
Get the number of classes available to the user.
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
uint ui_count
Number of specs in this class potentially available to the user.
static const Tspec * GetByGrf(uint32_t grfid, uint16_t local_id)
Retrieve a spec by GRF location.
std::vector< Tspec * > spec
List of specifications.
uint GetSpecCount() const
Get the number of allocated specs within the class.
static uint GetClassCount()
Get the number of allocated classes.
static void InsertDefaults()
Initialise the defaults.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
static std::vector< NewGRFClass< Tspec, Tindex, Tmax > > classes
The actual classes.
static void Reset()
Reset the classes, i.e.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
uint16_t index
Index within class of this spec, invalid until inserted into class.
Tindex class_index
Class index of this spec, invalid until class is allocated.