]> git.lizzy.rs Git - minetest.git/blob - src/gamedef.h
Add callback on_mapblocks_changed
[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 #pragma once
21
22 #include <string>
23 #include <vector>
24 #include "irrlichttypes.h"
25
26 class IItemDefManager;
27 class NodeDefManager;
28 class ICraftDefManager;
29 class ITextureSource;
30 class IShaderSource;
31 class IRollbackManager;
32 class EmergeManager;
33 class Camera;
34 class ModChannel;
35 class ModStorage;
36 class ModStorageDatabase;
37
38 namespace irr { namespace scene {
39         class IAnimatedMesh;
40         class ISceneManager;
41 }}
42
43 struct SubgameSpec;
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 const NodeDefManager* 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         // Only usable on the server, and NOT thread-safe. It is usable from the
63         // environment thread.
64         virtual IRollbackManager* getRollbackManager() { return NULL; }
65
66         // Shorthands
67         // TODO: these should be made const-safe so that a const IGameDef* is
68         //       actually usable
69         IItemDefManager  *idef()     { return getItemDefManager(); }
70         const NodeDefManager  *ndef() { return getNodeDefManager(); }
71         ICraftDefManager *cdef()     { return getCraftDefManager(); }
72         IRollbackManager *rollback() { return getRollbackManager(); }
73
74         virtual const std::vector<ModSpec> &getMods() const = 0;
75         virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
76         virtual const SubgameSpec* getGameSpec() const { return nullptr; }
77         virtual std::string getWorldPath() const { return ""; }
78         virtual ModStorageDatabase *getModStorageDatabase() = 0;
79
80         virtual bool joinModChannel(const std::string &channel) = 0;
81         virtual bool leaveModChannel(const std::string &channel) = 0;
82         virtual bool sendModChannelMessage(const std::string &channel,
83                 const std::string &message) = 0;
84         virtual ModChannel *getModChannel(const std::string &channel) = 0;
85 };