]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Move the codebase to C++14
authorsfan5 <sfan5@live.de>
Wed, 23 Feb 2022 19:02:58 +0000 (20:02 +0100)
committersfan5 <sfan5@live.de>
Sat, 26 Feb 2022 13:39:41 +0000 (14:39 +0100)
CMakeLists.txt
android/native/jni/Application.mk
src/CMakeLists.txt
src/modchannels.cpp
src/server.cpp
src/unittest/test_address.cpp
src/unittest/test_eventmanager.cpp
src/unittest/test_server_shutdown_state.cpp
src/util/metricsbackend.cpp

index 1da83a99cdff3c9de8e4efeda463fdd46200bd5c..827191835d5bb2baa90fe754a4c847fbded21049 100644 (file)
@@ -11,7 +11,8 @@ endif()
 project(minetest)
 set(PROJECT_NAME_CAPITALIZED "Minetest")
 
-set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
 set(GCC_MINIMUM_VERSION "5.1")
 set(CLANG_MINIMUM_VERSION "3.5")
 
index e21bca61c5daf0659a545e7545ab498ddff39814..9d959613759c2cf73038ce42ed51a1b765b6641f 100644 (file)
@@ -20,7 +20,7 @@ APP_CPPFLAGS := -g -Og -fno-omit-frame-pointer
 endif
 
 APP_CFLAGS   := $(APP_CPPFLAGS) -Wno-inconsistent-missing-override -Wno-parentheses-equality
-APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++17
+APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++14
 APP_LDFLAGS  := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe
 
 ifeq ($(APP_ABI),arm64-v8a)
index 7f207244cae7e9fd4fcfb7806e5ea406de5cace6..57baf20bd938e5b949cb59f8966b4bdb061cfc92 100644 (file)
@@ -718,7 +718,6 @@ if(MSVC)
        endif()
 else()
        # GCC or compatible compilers such as Clang
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
        if(WARN_ALL)
                set(RELEASE_WARNING_FLAGS "-Wall")
        else()
@@ -751,6 +750,7 @@ else()
        if(MINGW)
                set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions")
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
+               set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mwindows")
        endif()
 
        # Use a safe subset of flags to speed up math calculations:
@@ -787,10 +787,6 @@ else()
        if(USE_GPROF)
                set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
        endif()
-
-       if(MINGW)
-               set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mwindows")
-       endif()
 endif()
 
 
index 301dcb0923c6bd47a6c454bd030426873c18471a..9626e8e0c4250962cc0b8b0378b8c9e23dfe9a4c 100644 (file)
@@ -88,8 +88,7 @@ bool ModChannelMgr::canWriteOnChannel(const std::string &channel) const
 
 void ModChannelMgr::registerChannel(const std::string &channel)
 {
-       m_registered_channels[channel] =
-                       std::unique_ptr<ModChannel>(new ModChannel(channel));
+       m_registered_channels[channel] = std::make_unique<ModChannel>(channel);
 }
 
 bool ModChannelMgr::setChannelState(const std::string &channel, ModChannelState state)
index 685d8bb2538557036e14c92b39108afc04c3a077..d9205c89568b45c1022aa96e6c486c6b244b45b9 100644 (file)
@@ -254,7 +254,7 @@ Server::Server(
 #if USE_PROMETHEUS
        m_metrics_backend = std::unique_ptr<MetricsBackend>(createPrometheusMetricsBackend());
 #else
-       m_metrics_backend = std::unique_ptr<MetricsBackend>(new MetricsBackend());
+       m_metrics_backend = std::make_unique<MetricsBackend>();
 #endif
 
        m_uptime_counter = m_metrics_backend->addCounter("minetest_core_server_uptime", "Server uptime (in seconds)");
@@ -406,7 +406,7 @@ void Server::init()
        m_mod_storage_database = openModStorageDatabase(m_path_world);
        m_mod_storage_database->beginSave();
 
-       m_modmgr = std::unique_ptr<ServerModManager>(new ServerModManager(m_path_world));
+       m_modmgr = std::make_unique<ServerModManager>(m_path_world);
        std::vector<ModSpec> unsatisfied_mods = m_modmgr->getUnsatisfiedMods();
        // complain about mods with unsatisfied dependencies
        if (!m_modmgr->isConsistent()) {
@@ -426,7 +426,7 @@ void Server::init()
        m_script = new ServerScripting(this);
 
        // Must be created before mod loading because we have some inventory creation
-       m_inventory_mgr = std::unique_ptr<ServerInventoryManager>(new ServerInventoryManager());
+       m_inventory_mgr = std::make_unique<ServerInventoryManager>();
 
        m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME);
 
index 35d4effb66eccaaef0767d4127b1d8c6c65fae00..f46135577821d500505554c85e5b53108feac59e 100644 (file)
@@ -56,7 +56,7 @@ void TestAddress::testIsLocalhost()
        UASSERT(!Address(172, 45, 37, 68, 0).isLocalhost());
 
        // v6
-       std::unique_ptr<IPv6AddressBytes> ipv6Bytes(new IPv6AddressBytes());
+       auto ipv6Bytes = std::make_unique<IPv6AddressBytes>();
        std::vector<u8> ipv6RawAddr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
        memcpy(ipv6Bytes->bytes, &ipv6RawAddr[0], 16);
        UASSERT(Address(ipv6Bytes.get(), 0).isLocalhost())
index bb0e5933646613d3e5f63d58df7514c6bb128011..fec57f9feac43e385ecb5fb401e7542e8a91210c 100644 (file)
@@ -82,7 +82,7 @@ void TestEventManager::testDeregister()
 void TestEventManager::testRealEvent()
 {
        EventManager ev;
-       std::unique_ptr<EventManagerTest> emt(new EventManagerTest());
+       auto emt = std::make_unique<EventManagerTest>();
        ev.reg(MtEvent::PLAYER_REGAIN_GROUND, EventManagerTest::eventTest, emt.get());
 
        // Put event & verify event value
@@ -93,7 +93,7 @@ void TestEventManager::testRealEvent()
 void TestEventManager::testRealEventAfterDereg()
 {
        EventManager ev;
-       std::unique_ptr<EventManagerTest> emt(new EventManagerTest());
+       auto emt = std::make_unique<EventManagerTest>();
        ev.reg(MtEvent::PLAYER_REGAIN_GROUND, EventManagerTest::eventTest, emt.get());
 
        // Put event & verify event value
index fbb76ff6a5d3cf01e1214c2c783120f1ed620daa..50305e725b5b89618044633b81cb9cf91aab04ce 100644 (file)
@@ -26,12 +26,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class FakeServer : public Server
 {
 public:
-       // clang-format off
        FakeServer() : Server("fakeworld", SubgameSpec("fakespec", "fakespec"), true,
                                        Address(), true, nullptr)
        {
        }
-       // clang-format on
 
 private:
        void SendChatMessage(session_t peer_id, const ChatMessage &message)
@@ -95,7 +93,7 @@ void TestServerShutdownState::testTrigger()
 
 void TestServerShutdownState::testTick()
 {
-       std::unique_ptr<FakeServer> fakeServer(new FakeServer());
+       auto fakeServer = std::make_unique<FakeServer>();
        Server::ShutdownState ss;
        ss.trigger(28.0f, "testtrigger", true);
        ss.tick(0.0f, fakeServer.get());
index 4454557a3df0da369d2fa10349781dcbdde1fb5f..c3b7def626485b355883f495faa966afcd4075d5 100644 (file)
@@ -99,8 +99,7 @@ class PrometheusMetricsBackend : public MetricsBackend
 {
 public:
        PrometheusMetricsBackend(const std::string &addr) :
-                       MetricsBackend(), m_exposer(std::unique_ptr<prometheus::Exposer>(
-                                                         new prometheus::Exposer(addr))),
+                       MetricsBackend(), m_exposer(std::make_unique<prometheus::Exposer>(addr)),
                        m_registry(std::make_shared<prometheus::Registry>())
        {
                m_exposer->RegisterCollectable(m_registry);