#include "test.h"
+#include "client/sound.h"
#include "nodedef.h"
#include "itemdef.h"
#include "gamedef.h"
+#include "modchannels.h"
#include "mods.h"
+#include "util/numeric.h"
content_t t_CONTENT_STONE;
content_t t_CONTENT_GRASS;
~TestGameDef();
IItemDefManager *getItemDefManager() { return m_itemdef; }
- INodeDefManager *getNodeDefManager() { return m_nodedef; }
+ const NodeDefManager *getNodeDefManager() { return m_nodedef; }
ICraftDefManager *getCraftDefManager() { return m_craftdef; }
ITextureSource *getTextureSource() { return m_texturesrc; }
IShaderSource *getShaderSource() { return m_shadersrc; }
virtual std::string getModStoragePath() const { return "."; }
virtual bool registerModStorage(ModMetadata *meta) { return true; }
virtual void unregisterModStorage(const std::string &name) {}
+ bool joinModChannel(const std::string &channel);
+ bool leaveModChannel(const std::string &channel);
+ bool sendModChannelMessage(const std::string &channel, const std::string &message);
+ ModChannel *getModChannel(const std::string &channel)
+ {
+ return m_modchannel_mgr->getModChannel(channel);
+ }
private:
IItemDefManager *m_itemdef = nullptr;
- INodeDefManager *m_nodedef = nullptr;
+ const NodeDefManager *m_nodedef = nullptr;
ICraftDefManager *m_craftdef = nullptr;
ITextureSource *m_texturesrc = nullptr;
IShaderSource *m_shadersrc = nullptr;
scene::ISceneManager *m_scenemgr = nullptr;
IRollbackManager *m_rollbackmgr = nullptr;
EmergeManager *m_emergemgr = nullptr;
+ std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
};
-TestGameDef::TestGameDef()
+TestGameDef::TestGameDef() :
+ m_modchannel_mgr(new ModChannelMgr())
{
m_itemdef = createItemDefManager();
m_nodedef = createNodeDefManager();
void TestGameDef::defineSomeNodes()
{
IWritableItemDefManager *idef = (IWritableItemDefManager *)m_itemdef;
- IWritableNodeDefManager *ndef = (IWritableNodeDefManager *)m_nodedef;
+ NodeDefManager *ndef = (NodeDefManager *)m_nodedef;
ItemDefinition itemdef;
ContentFeatures f;
"{default_stone.png";
f = ContentFeatures();
f.name = itemdef.name;
- for(int i = 0; i < 6; i++)
- f.tiledef[i].name = "default_stone.png";
+ for (TileDef &tiledef : f.tiledef)
+ tiledef.name = "default_stone.png";
f.is_ground_content = true;
idef->registerItem(itemdef);
t_CONTENT_STONE = ndef->set(f.name, f);
f.liquid_viscosity = 4;
f.is_ground_content = true;
f.groups["liquids"] = 3;
- for(int i = 0; i < 6; i++)
- f.tiledef[i].name = "default_water.png";
+ for (TileDef &tiledef : f.tiledef)
+ tiledef.name = "default_water.png";
idef->registerItem(itemdef);
t_CONTENT_WATER = ndef->set(f.name, f);
f.light_source = LIGHT_MAX-1;
f.is_ground_content = true;
f.groups["liquids"] = 3;
- for(int i = 0; i < 6; i++)
- f.tiledef[i].name = "default_lava.png";
+ for (TileDef &tiledef : f.tiledef)
+ tiledef.name = "default_lava.png";
idef->registerItem(itemdef);
t_CONTENT_LAVA = ndef->set(f.name, f);
"{default_brick.png";
f = ContentFeatures();
f.name = itemdef.name;
- for(int i = 0; i < 6; i++)
- f.tiledef[i].name = "default_brick.png";
+ for (TileDef &tiledef : f.tiledef)
+ tiledef.name = "default_brick.png";
f.is_ground_content = true;
idef->registerItem(itemdef);
t_CONTENT_BRICK = ndef->set(f.name, f);
}
+bool TestGameDef::joinModChannel(const std::string &channel)
+{
+ return m_modchannel_mgr->joinChannel(channel, PEER_ID_SERVER);
+}
+
+bool TestGameDef::leaveModChannel(const std::string &channel)
+{
+ return m_modchannel_mgr->leaveChannel(channel, PEER_ID_SERVER);
+}
+
+bool TestGameDef::sendModChannelMessage(const std::string &channel,
+ const std::string &message)
+{
+ if (!m_modchannel_mgr->channelRegistered(channel))
+ return false;
+
+ return true;
+}
+
////
//// run_tests
////
bool run_tests()
{
- DSTACK(FUNCTION_NAME);
-
u64 t1 = porting::getTimeMs();
TestGameDef gamedef;