]> git.lizzy.rs Git - minetest-m13.git/blob - src/gamedef.h
d0360f53ba0182a719e88a96701d7babd44f6aef
[minetest-m13.git] / src / gamedef.h
1 /*
2 Minetest-m13
3 Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef GAMEDEF_HEADER
21 #define GAMEDEF_HEADER
22
23 #include <string>
24 #include "irrlichttypes.h"
25
26 class IItemDefManager;
27 class INodeDefManager;
28 class ICraftDefManager;
29 class ITextureSource;
30
31 /*
32         An interface for fetching game-global definitions like tool and
33         mapnode properties
34 */
35
36 class IGameDef
37 {
38 public:
39         // These are thread-safe IF they are not edited while running threads.
40         // Thus, first they are set up and then they are only read.
41         virtual IItemDefManager* getItemDefManager()=0;
42         virtual INodeDefManager* getNodeDefManager()=0;
43         virtual ICraftDefManager* getCraftDefManager()=0;
44
45         // This is always thread-safe, but referencing the irrlicht texture
46         // pointers in other threads than main thread will make things explode.
47         virtual ITextureSource* getTextureSource()=0;
48         
49         // Used for keeping track of names/ids of unknown nodes
50         virtual u16 allocateUnknownNodeId(const std::string &name)=0;
51
52         // Shorthands
53         IItemDefManager* idef(){return getItemDefManager();}
54         INodeDefManager* ndef(){return getNodeDefManager();}
55         ICraftDefManager* cdef(){return getCraftDefManager();}
56         ITextureSource* tsrc(){return getTextureSource();}
57 };
58
59 #endif
60