gamedef.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 ModStorage;
  30. class ModStorageDatabase;
  31. namespace irr::scene {
  32. class IAnimatedMesh;
  33. class ISceneManager;
  34. }
  35. struct SubgameSpec;
  36. struct ModSpec;
  37. /*
  38. An interface for fetching game-global definitions like tool and
  39. mapnode properties
  40. */
  41. class IGameDef
  42. {
  43. public:
  44. // These are thread-safe IF they are not edited while running threads.
  45. // Thus, first they are set up and then they are only read.
  46. virtual IItemDefManager* getItemDefManager()=0;
  47. virtual const NodeDefManager* getNodeDefManager()=0;
  48. virtual ICraftDefManager* getCraftDefManager()=0;
  49. // Used for keeping track of names/ids of unknown nodes
  50. virtual u16 allocateUnknownNodeId(const std::string &name)=0;
  51. // Only usable on the server, and NOT thread-safe. It is usable from the
  52. // environment thread.
  53. virtual IRollbackManager* getRollbackManager() { return NULL; }
  54. // Shorthands
  55. // TODO: these should be made const-safe so that a const IGameDef* is
  56. // actually usable
  57. IItemDefManager *idef() { return getItemDefManager(); }
  58. const NodeDefManager *ndef() { return getNodeDefManager(); }
  59. ICraftDefManager *cdef() { return getCraftDefManager(); }
  60. IRollbackManager *rollback() { return getRollbackManager(); }
  61. virtual const std::vector<ModSpec> &getMods() const = 0;
  62. virtual const ModSpec* getModSpec(const std::string &modname) const = 0;
  63. virtual const SubgameSpec* getGameSpec() const { return nullptr; }
  64. virtual std::string getWorldPath() const { return ""; }
  65. virtual std::string getModDataPath() const { return ""; }
  66. virtual ModStorageDatabase *getModStorageDatabase() = 0;
  67. virtual bool joinModChannel(const std::string &channel) = 0;
  68. virtual bool leaveModChannel(const std::string &channel) = 0;
  69. virtual bool sendModChannelMessage(const std::string &channel,
  70. const std::string &message) = 0;
  71. virtual ModChannel *getModChannel(const std::string &channel) = 0;
  72. };