diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a389a8b8d..0eb08ee36f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/dep/cotire/CMake") # build in Release-mode by default if not explicitly set -if( NOT CMAKE_BUILD_TYPE ) +if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config") + set(CMAKE_DEFAULT_BUILD_TYPE "RelWithDebInfo" CACHE INTERNAL "") +endif() +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake index e6c137e084..ca9bf089b0 100644 --- a/cmake/compiler/clang/settings.cmake +++ b/cmake/compiler/clang/settings.cmake @@ -1,7 +1,7 @@ # Set build-directive (used in core to tell which buildtype we used) target_compile_definitions(trinity-compile-option-interface INTERFACE - -D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") + -D_BUILD_DIRECTIVE="$") if(WITH_WARNINGS) target_compile_options(trinity-warning-interface @@ -13,6 +13,12 @@ if(WITH_WARNINGS) -Wfatal-errors -Wno-mismatched-tags -Woverloaded-virtual) + + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10) + target_compile_options(trinity-warning-interface + INTERFACE + -Wno-deprecated-copy) # warning in g3d + endif() message(STATUS "Clang: All warnings enabled") endif() @@ -27,6 +33,7 @@ endif() # -Wno-narrowing needed to suppress a warning in g3d # -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems. +# -Wno-deprecated-copy needed to suppress a warning in g3d set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1") target_compile_options(trinity-compile-option-interface INTERFACE diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index 53d81a3a49..43f2691f8b 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -1,7 +1,7 @@ # Set build-directive (used in core to tell which buildtype we used) target_compile_definitions(trinity-compile-option-interface INTERFACE - -D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") + -D_BUILD_DIRECTIVE="$") set(GCC_EXPECTED_VERSION 7.1.0) @@ -33,6 +33,10 @@ if( WITH_WARNINGS ) -Wfatal-errors -Woverloaded-virtual) + target_compile_options(trinity-warning-interface + INTERFACE + -Wno-deprecated-copy) # warning in g3d + message(STATUS "GCC: All warnings enabled") endif() diff --git a/cmake/compiler/icc/settings.cmake b/cmake/compiler/icc/settings.cmake index d14931f645..a2d2d3db36 100644 --- a/cmake/compiler/icc/settings.cmake +++ b/cmake/compiler/icc/settings.cmake @@ -1,7 +1,7 @@ # Set build-directive (used in core to tell which buildtype we used) target_compile_definitions(trinity-compile-option-interface INTERFACE - -D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") + -D_BUILD_DIRECTIVE="$") if(PLATFORM EQUAL 32) target_compile_options(trinity-compile-option-interface diff --git a/cmake/compiler/mingw/settings.cmake b/cmake/compiler/mingw/settings.cmake index 0850d8b531..933e842209 100644 --- a/cmake/compiler/mingw/settings.cmake +++ b/cmake/compiler/mingw/settings.cmake @@ -4,7 +4,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # Set build-directive (used in core to tell which buildtype we used) target_compile_definitions(trinity-compile-option-interface INTERFACE - -D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}") + -D_BUILD_DIRECTIVE="$") if(PLATFORM EQUAL 32) # Required on 32-bit systems to enable SSE2 (standard on x64) diff --git a/dep/cotire/CMake/cotire.cmake b/dep/cotire/CMake/cotire.cmake index e2025e8657..4d383e1882 100644 --- a/dep/cotire/CMake/cotire.cmake +++ b/dep/cotire/CMake/cotire.cmake @@ -2259,12 +2259,19 @@ function (cotire_generate_target_script _language _configurations _target _targe set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) endfunction() -function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) +function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _prefixFileWasGenerated _hostFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we attach the precompiled header compilation to the host file # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) + # unlike MSBuild, Ninja does not automatically create the directory for /Fp file + # so we have to do it ourselves to avoid C1083 + if (${CMAKE_GENERATOR} STREQUAL "Ninja Multi-Config") + cotire_get_intermediate_dir(_baseDir) + add_custom_command (OUTPUT "${_baseDir}/.mkdir" COMMAND ${CMAKE_COMMAND} -E touch "${_baseDir}/.mkdir") + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_baseDir}/.mkdir") + endif() set (_flags "") cotire_add_pch_compilation_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" @@ -2272,7 +2279,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") # make object file generated from host file depend on prefix header - set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") + if (_prefixFileWasGenerated) + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") + endif() # mark host file as cotired to prevent it from being used in another cotired target set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") endif() @@ -2355,7 +2364,7 @@ function (cotire_setup_prefix_file_inclusion _language _target _prefixFile _pref if (_prefixFileWasGenerated) # make object files generated from source files depend on prefix header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") - endif() + endif() endfunction() function (cotire_get_first_set_property_value _propertyValueVar _type _object) @@ -2899,7 +2908,7 @@ function (cotire_process_target_language _language _configurations _target _whol if (_pchFile) # first file in _sourceFiles is passed as the host file cotire_setup_pch_file_compilation( - ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_prefixFileWasGenerated} ${_sourceFiles}) cotire_setup_pch_file_inclusion( ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) endif() diff --git a/src/common/Logging/LogMessage.cpp b/src/common/Logging/LogMessage.cpp index f8fcdcc7ee..5f10087d1f 100644 --- a/src/common/Logging/LogMessage.cpp +++ b/src/common/Logging/LogMessage.cpp @@ -16,6 +16,7 @@ */ #include "LogMessage.h" +#include "StringFormat.h" #include "Util.h" LogMessage::LogMessage(LogLevel _level, std::string const& _type, std::string&& _text) @@ -32,9 +33,7 @@ std::string LogMessage::getTimeStr(time_t time) { tm aTm; localtime_r(&time, &aTm); - char buf[20]; - snprintf(buf, 20, "%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); - return std::string(buf); + return Trinity::StringFormat("%04d-%02d-%02d_%02d:%02d:%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); } std::string LogMessage::getTimeStr() const diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index e5d5611468..8842bc5e7c 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -206,9 +206,7 @@ std::string TimeToTimestampStr(time_t t) // HH hour (2 digits 00-23) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) - char buf[20]; - snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm.tm_year+1900, aTm.tm_mon+1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); - return std::string(buf); + return Trinity::StringFormat("%04d-%02d-%02d_%02d-%02d-%02d", aTm.tm_year + 1900, aTm.tm_mon + 1, aTm.tm_mday, aTm.tm_hour, aTm.tm_min, aTm.tm_sec); } /// Check if the string is a valid ip address representation diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index fb272eb2a0..9e0d41fef6 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -416,14 +416,6 @@ public: return !this->operator ==(right); } - inline flag96& operator=(flag96 const& right) - { - part[0] = right.part[0]; - part[1] = right.part[1]; - part[2] = right.part[2]; - return *this; - } - inline flag96 operator&(flag96 const& right) const { return flag96(part[0] & right.part[0], part[1] & right.part[1], diff --git a/src/server/game/DataStores/M2Stores.cpp b/src/server/game/DataStores/M2Stores.cpp index 1bf70a7deb..db2931ce78 100644 --- a/src/server/game/DataStores/M2Stores.cpp +++ b/src/server/game/DataStores/M2Stores.cpp @@ -155,10 +155,8 @@ bool readCamera(M2Camera const* cam, uint32 buffSize, M2Header const* header, Ci uint32 timeDiffThis = posTimestamps[i] - lastTarget.timeStamp; float xDiff = nextTarget.locations.GetPositionX() - lastTarget.locations.GetPositionX(); float yDiff = nextTarget.locations.GetPositionY() - lastTarget.locations.GetPositionY(); - float zDiff = nextTarget.locations.GetPositionZ() - lastTarget.locations.GetPositionZ(); x = lastTarget.locations.GetPositionX() + (xDiff * (float(timeDiffThis) / float(timeDiffTarget))); y = lastTarget.locations.GetPositionY() + (yDiff * (float(timeDiffThis) / float(timeDiffTarget))); - z = lastTarget.locations.GetPositionZ() + (zDiff * (float(timeDiffThis) / float(timeDiffTarget))); } float xDiff = x - thisCam.locations.GetPositionX(); float yDiff = y - thisCam.locations.GetPositionY(); @@ -203,10 +201,10 @@ void LoadM2Cameras(std::string const& dataPath) // Get file size m2file.seekg(0, std::ios::end); - std::streamoff const fileSize = m2file.tellg(); + std::streamoff fileSize = m2file.tellg(); // Reject if not at least the size of the header - if (static_cast(fileSize) < sizeof(M2Header)) + if (static_cast(fileSize) < sizeof(M2Header)) { TC_LOG_ERROR("server.loading", "Camera file %s is damaged. File is smaller than header size", filename.string().c_str()); m2file.close(); @@ -240,7 +238,7 @@ void LoadM2Cameras(std::string const& dataPath) // Read header M2Header const* header = reinterpret_cast(buffer.data()); - if (header->ofsCameras + sizeof(M2Camera) > static_cast(fileSize)) + if (header->ofsCameras + sizeof(M2Camera) > static_cast(fileSize)) { TC_LOG_ERROR("server.loading", "Camera file %s is damaged. Camera references position beyond file end", filename.string().c_str()); continue; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 0f5c1f9d70..d8ca4e47c7 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -439,7 +439,6 @@ void GameObject::Update(uint32 diff) m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY break; } - // NO BREAK for switch (m_lootState) } /* fallthrough */ case GO_READY: diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h index 6a0d13a70a..c57d45dbb7 100644 --- a/src/server/game/Movement/Spline/MoveSplineFlag.h +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -76,7 +76,6 @@ namespace Movement MoveSplineFlag() { raw() = 0; } MoveSplineFlag(uint32 f) { raw() = f; } - MoveSplineFlag(MoveSplineFlag const& f) { raw() = f.raw(); } // Constant interface diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index bba8afd467..fdaa90b92b 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -532,7 +532,6 @@ public: crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(), bird->GetMap()->GetWaterOrGroundLevel(bird->GetPhaseShift(), bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ())); /// @todo Make crunchy perform emote eat when he reaches the bird - break; } [[fallthrough]]; diff --git a/src/server/shared/Dynamic/LinkedList.h b/src/server/shared/Dynamic/LinkedList.h index 2d0596a048..35424ad82e 100644 --- a/src/server/shared/Dynamic/LinkedList.h +++ b/src/server/shared/Dynamic/LinkedList.h @@ -164,13 +164,7 @@ class LinkedListHead { // construct with node pointer _Pnode } - Iterator& operator=(Iterator const &_Right) - { - _Ptr = _Right._Ptr; - return *this; - } - - Iterator& operator=(const_pointer const &_Right) + Iterator& operator=(const_pointer const& _Right) { _Ptr = pointer(_Right); return *this; diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp index 0c60793439..74ac3866ec 100644 --- a/src/tools/vmap4_extractor/model.cpp +++ b/src/tools/vmap4_extractor/model.cpp @@ -29,9 +29,8 @@ extern HANDLE WorldMpq; -Model::Model(std::string &filename) : filename(filename), vertices(0), indices(0) +Model::Model(std::string &filename) : filename(filename), header(), vertices(nullptr), indices(nullptr) { - memset(&header, 0, sizeof(header)); } bool Model::open() @@ -147,7 +146,7 @@ void Doodad::Extract(ADT::MDDF const& doodadDef, char const* ModelInstName, uint // scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float? float sc = doodadDef.Scale / 1024.0f; - char tempname[512]; + char tempname[1036]; sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); FILE* input = fopen(tempname, "r+b"); @@ -246,7 +245,7 @@ void Doodad::ExtractSet(WMODoodadData const& doodadData, ADT::MODF const& wmo, b } } - char tempname[512]; + char tempname[1036]; sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName); FILE* input = fopen(tempname, "r+b"); if (!input) diff --git a/src/tools/vmap4_extractor/vec3d.h b/src/tools/vmap4_extractor/vec3d.h index 2c93018091..1ec7ff77ce 100644 --- a/src/tools/vmap4_extractor/vec3d.h +++ b/src/tools/vmap4_extractor/vec3d.h @@ -28,14 +28,9 @@ public: Vec3D(float x0 = 0.0f, float y0 = 0.0f, float z0 = 0.0f) : x(x0), y(y0), z(z0) {} - Vec3D(const Vec3D& v) : x(v.x), y(v.y), z(v.z) {} + Vec3D(Vec3D const& v) = default; - Vec3D& operator= (const Vec3D &v) { - x = v.x; - y = v.y; - z = v.z; - return *this; - } + Vec3D& operator=(Vec3D const& v) = default; Vec3D operator+ (const Vec3D &v) const { @@ -157,13 +152,9 @@ public: Vec2D(float x0 = 0.0f, float y0 = 0.0f) : x(x0), y(y0) {} - Vec2D(const Vec2D& v) : x(v.x), y(v.y) {} + Vec2D(Vec2D const& v) = default; - Vec2D& operator= (const Vec2D &v) { - x = v.x; - y = v.y; - return *this; - } + Vec2D& operator=(Vec2D const& v) = default; Vec2D operator+ (const Vec2D &v) const {