dummygamedef.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2022 TurkeyMcMac, Jude Melton-Houghton <jwmhjwmh@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #pragma once
  18. #include "gamedef.h"
  19. #include "itemdef.h"
  20. #include "nodedef.h"
  21. #include "craftdef.h"
  22. #include "content/mods.h"
  23. #include "database/database-dummy.h"
  24. class DummyGameDef : public IGameDef {
  25. public:
  26. DummyGameDef():
  27. m_itemdef(createItemDefManager()),
  28. m_nodedef(createNodeDefManager()),
  29. m_craftdef(createCraftDefManager()),
  30. m_mod_storage_database(new Database_Dummy())
  31. {
  32. }
  33. ~DummyGameDef()
  34. {
  35. delete m_mod_storage_database;
  36. delete m_craftdef;
  37. delete m_nodedef;
  38. delete m_itemdef;
  39. }
  40. IItemDefManager *getItemDefManager() override { return m_itemdef; }
  41. const NodeDefManager *getNodeDefManager() override { return m_nodedef; }
  42. NodeDefManager* getWritableNodeDefManager() { return m_nodedef; }
  43. ICraftDefManager *getCraftDefManager() override { return m_craftdef; }
  44. u16 allocateUnknownNodeId(const std::string &name) override
  45. {
  46. return m_nodedef->allocateDummy(name);
  47. }
  48. const std::vector<ModSpec> &getMods() const override
  49. {
  50. static std::vector<ModSpec> emptymodspec;
  51. return emptymodspec;
  52. }
  53. const ModSpec* getModSpec(const std::string &modname) const override { return nullptr; }
  54. ModStorageDatabase *getModStorageDatabase() override { return m_mod_storage_database; }
  55. bool joinModChannel(const std::string &channel) override { return false; }
  56. bool leaveModChannel(const std::string &channel) override { return false; }
  57. bool sendModChannelMessage(const std::string &channel, const std::string &message) override
  58. {
  59. return false;
  60. }
  61. ModChannel *getModChannel(const std::string &channel) override { return nullptr; }
  62. protected:
  63. IItemDefManager *m_itemdef = nullptr;
  64. NodeDefManager *m_nodedef = nullptr;
  65. ICraftDefManager *m_craftdef = nullptr;
  66. ModStorageDatabase *m_mod_storage_database = nullptr;
  67. };