Minetest  5.4.0
gamedef.h
Go to the documentation of this file.
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 ModMetadata;
36 
37 namespace irr { namespace scene {
38  class IAnimatedMesh;
39  class ISceneManager;
40 }}
41 
42 struct ModSpec;
43 /*
44  An interface for fetching game-global definitions like tool and
45  mapnode properties
46 */
47 
48 class IGameDef
49 {
50 public:
51  // These are thread-safe IF they are not edited while running threads.
52  // Thus, first they are set up and then they are only read.
54  virtual const NodeDefManager* getNodeDefManager()=0;
56 
57  // Used for keeping track of names/ids of unknown nodes
58  virtual u16 allocateUnknownNodeId(const std::string &name)=0;
59 
60  // Only usable on the server, and NOT thread-safe. It is usable from the
61  // environment thread.
62  virtual IRollbackManager* getRollbackManager() { return NULL; }
63 
64  // Shorthands
66  const NodeDefManager *ndef() { return getNodeDefManager(); }
69 
70  virtual const std::vector<ModSpec> &getMods() const = 0;
71  virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
72  virtual std::string getWorldPath() const { return ""; }
73  virtual std::string getModStoragePath() const = 0;
74  virtual bool registerModStorage(ModMetadata *storage) = 0;
75  virtual void unregisterModStorage(const std::string &name) = 0;
76 
77  virtual bool joinModChannel(const std::string &channel) = 0;
78  virtual bool leaveModChannel(const std::string &channel) = 0;
79  virtual bool sendModChannelMessage(const std::string &channel,
80  const std::string &message) = 0;
81  virtual ModChannel *getModChannel(const std::string &channel) = 0;
82 };
Definition: camera.h:79
Definition: emerge.h:113
Definition: craftdef.h:405
Definition: gamedef.h:49
virtual std::string getWorldPath() const
Definition: gamedef.h:72
const NodeDefManager * ndef()
Definition: gamedef.h:66
IRollbackManager * rollback()
Definition: gamedef.h:68
virtual bool leaveModChannel(const std::string &channel)=0
IItemDefManager * idef()
Definition: gamedef.h:65
virtual const std::vector< ModSpec > & getMods() const =0
virtual ModChannel * getModChannel(const std::string &channel)=0
virtual bool sendModChannelMessage(const std::string &channel, const std::string &message)=0
virtual void unregisterModStorage(const std::string &name)=0
virtual u16 allocateUnknownNodeId(const std::string &name)=0
virtual IItemDefManager * getItemDefManager()=0
virtual const NodeDefManager * getNodeDefManager()=0
ICraftDefManager * cdef()
Definition: gamedef.h:67
virtual bool joinModChannel(const std::string &channel)=0
virtual bool registerModStorage(ModMetadata *storage)=0
virtual IRollbackManager * getRollbackManager()
Definition: gamedef.h:62
virtual ICraftDefManager * getCraftDefManager()=0
virtual std::string getModStoragePath() const =0
virtual const ModSpec * getModSpec(const std::string &modname) const =0
Definition: itemdef.h:105
Definition: rollback_interface.h:112
Definition: shader.h:126
Definition: tile.h:86
Definition: modchannels.h:38
Definition: mods.h:144
This class is for getting the actual properties of nodes from their content ID.
Definition: nodedef.h:510
Definition: clouds.h:32
Definition: mods.h:37