diff --git a/.clang-format b/.clang-format index d2e2f2940..f1d51a04f 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ BasedOnStyle: LLVM IndentWidth: 8 UseTab: Always BreakBeforeBraces: Custom -Standard: Cpp03 +Standard: Cpp11 BraceWrapping: AfterClass: true AfterControlStatement: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 9282bd1d7..368fc11d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,16 @@ if(${CMAKE_VERSION} STREQUAL "2.8.2") message(WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!") endif() +if (CMAKE_VERSION VERSION_LESS "3.1") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}") + set (CMAKE_CXX_FLAGS "--std=gnu++0x ${CMAKE_C_FLAGS}") + endif () +else () + set(CMAKE_C_STANDARD 11) + set(CMAKE_CXX_STANDARD 11) +endif () + # This can be read from ${PROJECT_NAME} after project() is called project(minetest) set(PROJECT_NAME_CAPITALIZED "Minetest4") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b876d9b2..d0b6bf5f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,7 +23,6 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING FORCE ) - # Set some random things default to not being visible in the GUI mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) @@ -722,9 +721,9 @@ include(CheckCSourceCompiles) if(MSVC) # Visual Studio - + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11") # EHa enables SEH exceptions (used for catching segfaults) - set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MT /GS- /Zi /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP") + set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MT /GS- /Zi /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP /std:c++11") #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF") @@ -772,6 +771,15 @@ else() SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Ttext-segment=0x200000000") endif() endif() + if (CMAKE_VERSION VERSION_LESS "3.1") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}") + set (CMAKE_CXX_FLAGS "--std=gnu++0x ${CMAKE_C_FLAGS}") + endif () + else () + set(CMAKE_C_STANDARD 11) + set(CMAKE_CXX_STANDARD 11) + endif () endif() if(WIN32 AND NOT ZLIBWAPI_DLL AND CMAKE_SIZEOF_VOID_P EQUAL 4) set(OTHER_FLAGS "${OTHER_FLAGS} -DWIN32_NO_ZLIB_WINAPI") diff --git a/src/serverobject.h b/src/serverobject.h index d6072e1a3..9deaa26e5 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -203,7 +203,7 @@ public: deleted until this is 0 to keep the id preserved for the right object. */ - u16 m_known_by_count; + u16 m_known_by_count = 0; /* - Whether this object is to be removed when nobody knows about @@ -213,7 +213,7 @@ public: - This is usually set to true by the step() method when the object wants to be deleted but can be set by anything else too. */ - bool m_pending_removal; + bool m_pending_removal = true; /* Same purpose as m_pending_removal but for deactivation. @@ -222,7 +222,7 @@ public: If this is set alongside with m_pending_removal, removal takes priority. */ - bool m_pending_deactivation; + bool m_pending_deactivation = false; /* A getter that unifies the above to answer the question: @@ -234,12 +234,12 @@ public: /* Whether the object's static data has been stored to a block */ - bool m_static_exists; + bool m_static_exists = false; /* The block from which the object was loaded from, and in which a copy of the static data resides. */ - v3s16 m_static_block; + v3s16 m_static_block = v3s16(1337,1337,1337); /* Queue of messages to be sent to the client diff --git a/src/settings.h b/src/settings.h index a19c15a76..58c9832a8 100644 --- a/src/settings.h +++ b/src/settings.h @@ -90,9 +90,9 @@ struct SettingsEntry { is_group(true) {} - std::string value; + std::string value = ""; Settings *group; - bool is_group; + bool is_group = false; }; typedef UNORDERED_MAP SettingEntries; diff --git a/src/shader.h b/src/shader.h index 766871f02..d6b1a2e1f 100644 --- a/src/shader.h +++ b/src/shader.h @@ -45,11 +45,11 @@ std::string getShaderPath(const std::string &name_of_shader, const std::string &filename); struct ShaderInfo { - std::string name; - video::E_MATERIAL_TYPE base_material; - video::E_MATERIAL_TYPE material; - u8 drawtype; - u8 material_type; + std::string name = ""; + video::E_MATERIAL_TYPE base_material = video::EMT_SOLID; + video::E_MATERIAL_TYPE material = video::EMT_SOLID; + u8 drawtype = 0; + u8 material_type = 0; s32 user_data; ShaderInfo(): name(""), base_material(video::EMT_SOLID),