Line data Source code
1 : /*
2 : Minetest
3 : Copyright (C) 2013 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 Lesser General Public License as published by
7 : the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14 :
15 : You should have received a copy of the GNU Lesser 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 : class ISoundManager;
31 : class IShaderSource;
32 : class MtEventManager;
33 : class IRollbackManager;
34 : class EmergeManager;
35 : namespace irr { namespace scene {
36 : class IAnimatedMesh;
37 : class ISceneManager;
38 : }}
39 :
40 : /*
41 : An interface for fetching game-global definitions like tool and
42 : mapnode properties
43 : */
44 :
45 1 : class IGameDef
46 : {
47 : public:
48 : // These are thread-safe IF they are not edited while running threads.
49 : // Thus, first they are set up and then they are only read.
50 : virtual IItemDefManager* getItemDefManager()=0;
51 : virtual INodeDefManager* getNodeDefManager()=0;
52 : virtual ICraftDefManager* getCraftDefManager()=0;
53 :
54 : // This is always thread-safe, but referencing the irrlicht texture
55 : // pointers in other threads than main thread will make things explode.
56 : virtual ITextureSource* getTextureSource()=0;
57 :
58 : virtual IShaderSource* getShaderSource()=0;
59 :
60 : // Used for keeping track of names/ids of unknown nodes
61 : virtual u16 allocateUnknownNodeId(const std::string &name)=0;
62 :
63 : // Only usable on the client
64 : virtual ISoundManager* getSoundManager()=0;
65 : virtual MtEventManager* getEventManager()=0;
66 0 : virtual scene::IAnimatedMesh* getMesh(const std::string &filename)
67 0 : { return NULL; }
68 : virtual scene::ISceneManager* getSceneManager()=0;
69 :
70 : // Only usable on the server, and NOT thread-safe. It is usable from the
71 : // environment thread.
72 55 : virtual IRollbackManager* getRollbackManager(){return NULL;}
73 :
74 : // Only usable on the server. Thread safe if not written while running threads.
75 0 : virtual EmergeManager *getEmergeManager() { return NULL; }
76 :
77 : // Used on the client
78 0 : virtual bool checkLocalPrivilege(const std::string &priv)
79 0 : { return false; }
80 :
81 : // Shorthands
82 203156 : IItemDefManager *idef() { return getItemDefManager(); }
83 32137759 : INodeDefManager *ndef() { return getNodeDefManager(); }
84 0 : ICraftDefManager *cdef() { return getCraftDefManager(); }
85 950086 : ITextureSource *tsrc() { return getTextureSource(); }
86 26 : ISoundManager *sound() { return getSoundManager(); }
87 : IShaderSource *shsrc() { return getShaderSource(); }
88 38 : MtEventManager *event() { return getEventManager(); }
89 55 : IRollbackManager *rollback() { return getRollbackManager();}
90 : EmergeManager *emerge() { return getEmergeManager(); }
91 : };
92 :
93 : #endif
94 :
|