OpenTTD: src/newgrf_class.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

newgrf_class.h
Go to the documentation of this file.
1 /* $Id: newgrf_class.h 24170 2012-04-22 16:28:32Z frosch $ */
2
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 */
9
12 #ifndef NEWGRF_CLASS_H
13 #define NEWGRF_CLASS_H
14
15 #include "strings_type.h"
16
20 template <typename Tspec, typename Tid, Tid Tmax>
21 struct NewGRFClass {
22 private:
23 uint count;
24 uint ui_count;
25 Tspec **spec;
26
32 static NewGRFClass<Tspec, Tid, Tmax> classes[Tmax];
33
34 void ResetClass();
35
37 static void InsertDefaults();
38
39 public:
40 uint32 global_id;
41 StringID name;
42
43 void Insert(Tspec *spec);
44
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;
51
52 const Tspec *GetSpec(uint index) const;
53
55 bool IsUIAvailable(uint index) const;
56
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);
64
65 static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index);
66 };
67
68 #endif /* NEWGRF_CLASS_H */