Silence uninitialised variable warnings in SSE blitters
[openttd/fttd.git] / src / newgrf_class.h
blob71b5608d84cca4d1ea1af5649613b32519acb309
1 /* $Id$ */
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 <http://www.gnu.org/licenses/>.
8 */
10 /** @file newgrf_class.h Header file for classes to be used by e.g. NewGRF stations and airports */
12 #ifndef NEWGRF_CLASS_H
13 #define NEWGRF_CLASS_H
15 #include "strings_type.h"
17 /**
18 * Struct containing information relating to NewGRF classes for stations and airports.
20 template <typename Tspec, typename Tid, Tid Tmax>
21 struct NewGRFClass {
22 private:
23 uint count; ///< Number of specs in this class.
24 uint ui_count; ///< Number of specs in this class potentially available to the user.
25 Tspec **spec; ///< Array of specifications.
27 /**
28 * The actual classes.
29 * @note We store pointers to membes of this array in various places outside this class (e.g. to 'name' for GRF string resolving).
30 * Thus this must be a static array, and cannot be a self-resizing SmallVector or similar.
32 static NewGRFClass<Tspec, Tid, Tmax> classes[Tmax];
34 void ResetClass();
36 /** Initialise the defaults. */
37 static void InsertDefaults();
39 public:
40 uint32 global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc.
41 StringID name; ///< Name of this class.
43 void Insert(Tspec *spec);
45 /** Get the number of allocated specs within the class. */
46 uint GetSpecCount() const { return this->count; }
47 /** Get the number of potentially user-available specs within the class. */
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;
54 /** Check whether the spec will be available to the user at some point in time. */
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);
68 #endif /* NEWGRF_CLASS_H */