Add ModStorageAPI to client side modding (#5396)
[oweals/minetest.git] / src / gamedef.h
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 <vector>
25 #include "irrlichttypes.h"
26
27 class IItemDefManager;
28 class INodeDefManager;
29 class ICraftDefManager;
30 class ITextureSource;
31 class ISoundManager;
32 class IShaderSource;
33 class MtEventManager;
34 class IRollbackManager;
35 class EmergeManager;
36 class Camera;
37 class ModMetadata;
38
39 namespace irr { namespace scene {
40         class IAnimatedMesh;
41         class ISceneManager;
42 }}
43
44 struct ModSpec;
45 /*
46         An interface for fetching game-global definitions like tool and
47         mapnode properties
48 */
49
50 class IGameDef
51 {
52 public:
53         // These are thread-safe IF they are not edited while running threads.
54         // Thus, first they are set up and then they are only read.
55         virtual IItemDefManager* getItemDefManager()=0;
56         virtual INodeDefManager* getNodeDefManager()=0;
57         virtual ICraftDefManager* getCraftDefManager()=0;
58
59         // Used for keeping track of names/ids of unknown nodes
60         virtual u16 allocateUnknownNodeId(const std::string &name)=0;
61
62         virtual MtEventManager* getEventManager()=0;
63
64         // Only usable on the server, and NOT thread-safe. It is usable from the
65         // environment thread.
66         virtual IRollbackManager* getRollbackManager() { return NULL; }
67
68         // Shorthands
69         IItemDefManager  *idef()     { return getItemDefManager(); }
70         INodeDefManager  *ndef()     { return getNodeDefManager(); }
71         ICraftDefManager *cdef()     { return getCraftDefManager(); }
72
73         MtEventManager   *event()    { return getEventManager(); }
74         IRollbackManager *rollback() { return getRollbackManager(); }
75
76         virtual const std::vector<ModSpec> &getMods() const = 0;
77         virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
78         virtual std::string getWorldPath() const { return ""; }
79         virtual std::string getModStoragePath() const = 0;
80         virtual bool registerModStorage(ModMetadata *storage) = 0;
81         virtual void unregisterModStorage(const std::string &name) = 0;
82 };
83
84 #endif
85