diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ba99bc21..ea212bede 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ set(DEVELOPMENT_BUILD TRUE) set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") if(VERSION_EXTRA) - set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA}) + set(VERSION_STRING "${VERSION_STRING}-${VERSION_EXTRA}") elseif(DEVELOPMENT_BUILD) set(VERSION_STRING "${VERSION_STRING}-dev") endif() diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 24a9e7921..a80a3ce4e 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -850,7 +850,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) logOnce(oss, warningstream); video::ITexture *last = m_animated_meshnode->getMaterial(0).TextureLayer[0].Texture; - for (s32 i = 1; i < mat_count; i++) { + for (u32 i = 1; i < mat_count; i++) { auto &layer = m_animated_meshnode->getMaterial(i).TextureLayer[0]; if (!layer.Texture) layer.Texture = last; diff --git a/src/client/game.cpp b/src/client/game.cpp index fb993d92f..54028fd1d 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1383,7 +1383,7 @@ bool Game::createClient(const GameStartData &start_data) str += L" ["; str += text; str += L"]"; - delete text; + delete[] text; } str += L" ["; str += driver->getName(); diff --git a/src/gettext.h b/src/gettext.h index 67fd9244f..6225fef93 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -48,8 +48,7 @@ void init_gettext(const char *path, const std::string &configured_language, extern wchar_t *utf8_to_wide_c(const char *str); -// You must free the returned string! -// The returned string is allocated using new +// The returned string must be freed using delete[] inline const wchar_t *wgettext(const char *str) { // We must check here that is not an empty string to avoid trying to translate it diff --git a/src/server.cpp b/src/server.cpp index 5022221ee..c175cbcd2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -517,9 +517,7 @@ void Server::stop() // Stop threads (set run=false first so both start stopping) m_thread->stop(); - //m_emergethread.setRun(false); m_thread->wait(); - //m_emergethread.stop(); infostream<<"Server: Threads stopped"<= 2.0) { - counter = 0.0; + counter -= dtime; + if (counter <= 0.0f) { + counter = 2.0f; m_emerge->startThreads(); } diff --git a/src/settings.cpp b/src/settings.cpp index 818d2bc41..cf7ec1b72 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -88,7 +88,7 @@ void SettingsHierarchy::onLayerCreated(int layer, Settings *obj) void SettingsHierarchy::onLayerRemoved(int layer) { - assert(layer >= 0 && layer < layers.size()); + assert(layer >= 0 && layer < (int)layers.size()); layers[layer] = nullptr; if (this == &g_hierarchy && layer == (int)SL_GLOBAL) g_settings = nullptr; diff --git a/src/unittest/test_gettext.cpp b/src/unittest/test_gettext.cpp index 98f73ec62..338a416d7 100644 --- a/src/unittest/test_gettext.cpp +++ b/src/unittest/test_gettext.cpp @@ -7,13 +7,12 @@ class TestGettext : public TestBase public: TestGettext() { TestManager::registerTestModule(this); - } + } const char *getName() { return "TestGettext"; } void runTests(IGameDef *gamedef); - void testSnfmtgettext(); void testFmtgettext(); }; @@ -24,24 +23,21 @@ void TestGettext::runTests(IGameDef *gamedef) TEST(testFmtgettext); } +// Make sure updatepo.sh does not pick up the strings +#define dummyname fmtgettext + void TestGettext::testFmtgettext() { - std::string buf = fmtgettext("Viewing range changed to %d", 12); - UASSERTEQ(std::string, buf, "Viewing range changed to 12"); - buf = fmtgettext( - "You are about to join this server with the name \"%s\" for the " - "first time.\n" - "If you proceed, a new account using your credentials will be " - "created on this server.\n" - "Please retype your password and click 'Register and Join' to " - "confirm account creation, or click 'Cancel' to abort." - , "A"); - UASSERTEQ(std::string, buf, - "You are about to join this server with the name \"A\" for the " - "first time.\n" - "If you proceed, a new account using your credentials will be " - "created on this server.\n" - "Please retype your password and click 'Register and Join' to " - "confirm account creation, or click 'Cancel' to abort." - ); + std::string buf = dummyname("sample text %d", 12); + UASSERTEQ(std::string, buf, "sample text 12"); + + std::string src, expect; + src = "You are about to join this server with the name \"%s\".\n"; + expect = "You are about to join this server with the name \"foo\".\n"; + for (int i = 0; i < 20; i++) { + src.append("loooong text"); + expect.append("loooong text"); + } + buf = dummyname(src.c_str(), "foo"); + UASSERTEQ(const std::string &, buf, expect); } diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp index 039110d54..743fe4462 100644 --- a/src/unittest/test_utilities.cpp +++ b/src/unittest/test_utilities.cpp @@ -392,9 +392,9 @@ void TestUtilities::testIsPowerOfTwo() UASSERT(is_power_of_two(2) == true); UASSERT(is_power_of_two(3) == false); for (int exponent = 2; exponent <= 31; ++exponent) { - UASSERT(is_power_of_two((1 << exponent) - 1) == false); - UASSERT(is_power_of_two((1 << exponent)) == true); - UASSERT(is_power_of_two((1 << exponent) + 1) == false); + UASSERT(is_power_of_two((1U << exponent) - 1) == false); + UASSERT(is_power_of_two((1U << exponent)) == true); + UASSERT(is_power_of_two((1U << exponent) + 1) == false); } UASSERT(is_power_of_two(U32_MAX) == false); } @@ -629,4 +629,4 @@ void TestUtilities::testBase64() UASSERT(base64_is_valid("AAA=A") == false); UASSERT(base64_is_valid("AAAA=A") == false); UASSERT(base64_is_valid("AAAAA=A") == false); -} \ No newline at end of file +}