gamedef.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include <vector>
  19. #include "irrlichttypes.h"
  20. class IItemDefManager;
  21. class NodeDefManager;
  22. class ICraftDefManager;
  23. class ITextureSource;
  24. class IShaderSource;
  25. class IRollbackManager;
  26. class EmergeManager;
  27. class Camera;
  28. class ModChannel;
  29. class ModMetadata;
  30. class ModMetadataDatabase;
  31. namespace irr { namespace scene {
  32. class IAnimatedMesh;
  33. class ISceneManager;
  34. }}
  35. struct ModSpec;
  36. /*
  37. An interface for fetching game-global definitions like tool and
  38. mapnode properties
  39. */
  40. class IGameDef
  41. {
  42. public:
  43. // These are thread-safe IF they are not edited while running threads.
  44. // Thus, first they are set up and then they are only read.
  45. virtual IItemDefManager* getItemDefManager()=0;
  46. virtual const NodeDefManager* getNodeDefManager()=0;
  47. virtual ICraftDefManager* getCraftDefManager()=0;
  48. // Used for keeping track of names/ids of unknown nodes
  49. virtual u16 allocateUnknownNodeId(const std::string &name)=0;
  50. // Only usable on the server, and NOT thread-safe. It is usable from the
  51. // environment thread.
  52. virtual IRollbackManager* getRollbackManager() { return NULL; }
  53. // Shorthands
  54. // TODO: these should be made const-safe so that a const IGameDef* is
  55. // actually usable
  56. IItemDefManager *idef() { return getItemDefManager(); }
  57. const NodeDefManager *ndef() { return getNodeDefManager(); }
  58. ICraftDefManager *cdef() { return getCraftDefManager(); }
  59. IRollbackManager *rollback() { return getRollbackManager(); }
  60. virtual const std::vector<ModSpec> &getMods() const = 0;
  61. virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
  62. virtual std::string getWorldPath() const { return ""; }
  63. virtual bool registerModStorage(ModMetadata *storage) = 0;
  64. virtual void unregisterModStorage(const std::string &name) = 0;
  65. virtual ModMetadataDatabase *getModStorageDatabase() = 0;
  66. virtual bool joinModChannel(const std::string &channel) = 0;
  67. virtual bool leaveModChannel(const std::string &channel) = 0;
  68. virtual bool sendModChannelMessage(const std::string &channel,
  69. const std::string &message) = 0;
  70. virtual ModChannel *getModChannel(const std::string &channel) = 0;
  71. };