#include "test.h"
+#include "client/sound.h"
#include "nodedef.h"
#include "itemdef.h"
#include "gamedef.h"
-#include "mods.h"
+#include "modchannels.h"
+#include "content/mods.h"
#include "util/numeric.h"
+#include "porting.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; }
ISoundManager *getSoundManager() { return m_soundmgr; }
- MtEventManager *getEventManager() { return m_eventmgr; }
scene::ISceneManager *getSceneManager() { return m_scenemgr; }
IRollbackManager *getRollbackManager() { return m_rollbackmgr; }
EmergeManager *getEmergeManager() { return m_emergemgr; }
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;
ISoundManager *m_soundmgr = nullptr;
- MtEventManager *m_eventmgr = 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;
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;
return m_test_dir;
char buf[32];
- snprintf(buf, sizeof(buf), "%08X", myrand());
+ porting::mt_snprintf(buf, sizeof(buf), "%08X", myrand());
m_test_dir = fs::TempPath() + DIR_DELIM "mttest_" + buf;
if (!fs::CreateDir(m_test_dir))
std::string TestBase::getTestTempFile()
{
char buf[32];
- snprintf(buf, sizeof(buf), "%08X", myrand());
+ porting::mt_snprintf(buf, sizeof(buf), "%08X", myrand());
return getTestTempDirectory() + DIR_DELIM + buf + ".tmp";
}
// Create one with no heightmaps
ServerMapSector sector(&parent, v2s16(1,1));
- UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
- UASSERT(sector.getBlockNoCreateNoEx(1) == 0);
+ UASSERT(sector.getBlockNoCreateNoEx(0) == nullptr);
+ UASSERT(sector.getBlockNoCreateNoEx(1) == nullptr);
MapBlock * bref = sector.createBlankBlock(-2);
- UASSERT(sector.getBlockNoCreateNoEx(0) == 0);
+ UASSERT(sector.getBlockNoCreateNoEx(0) == nullptr);
UASSERT(sector.getBlockNoCreateNoEx(-2) == bref);
//TODO: Check for AlreadyExistsException