Go to the documentation of this file.
1 /* $Id: newgrf_class.h 24170 2012-04-22 16:28:32Z frosch $ */
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <>.
8  */
12 #ifndef NEWGRF_CLASS_H
13 #define NEWGRF_CLASS_H
15 #include "strings_type.h"
20 template <typename Tspec, typename Tid, Tid Tmax>
21 struct NewGRFClass {
22 private:
23  uint count;
24  uint ui_count;
25  Tspec **spec;
34  void ResetClass();
37  static void InsertDefaults();
39 public:
40  uint32 global_id;
43  void Insert(Tspec *spec);
46  uint GetSpecCount() const { return this->count; }
48  uint GetUISpecCount() const { return this->ui_count; }
49  int GetUIFromIndex(int index) const;
50  int GetIndexFromUI(int ui_index) const;
52  const Tspec *GetSpec(uint index) const;
55  bool IsUIAvailable(uint index) const;
57  static void Reset();
58  static Tid Allocate(uint32 global_id);
59  static void Assign(Tspec *spec);
60  static uint GetClassCount();
61  static uint GetUIClassCount();
62  static Tid GetUIClass(uint index);
63  static NewGRFClass *Get(Tid cls_id);
65  static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index);
66 };
68 #endif /* NEWGRF_CLASS_H */
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:46
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
Definition: newgrf_class.h:48
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:21
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
uint32 global_id
Global ID for class, e.g. &#39;DFLT&#39;, &#39;WAYP&#39;, etc.
Definition: newgrf_class.h:40
uint ui_count
Number of specs in this class potentially available to the user.
Definition: newgrf_class.h:24
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
static NewGRFClass< Tspec, Tid, Tmax > classes[Tmax]
The actual classes.
Definition: newgrf_class.h:32
Tspec ** spec
Array of specifications.
Definition: newgrf_class.h:25
uint count
Number of specs in this class.
Definition: newgrf_class.h:23
static void InsertDefaults()
Initialise the defaults.
Types related to strings.
StringID name
Name of this class.
Definition: newgrf_class.h:41