From f34534465a40f758f7496ba924da0f559dd800ab Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Tue, 4 Jul 2023 22:18:42 +0200 Subject: [PATCH] Build: enable C++20 and updated all compiler requirements * ported some header and cmake updates from master branch --- cmake/compiler/clang/settings.cmake | 18 ++ cmake/compiler/gcc/settings.cmake | 4 +- cmake/compiler/msvc/settings.cmake | 27 +- cmake/macros/ConfigureBaseTargets.cmake | 2 +- cmake/platform/win/settings.cmake | 2 +- dep/g3dlite/CMakeLists.txt | 1 - dep/g3dlite/G3D-v9.0 hotfix10.diff | 20 ++ dep/g3dlite/G3D-v9.0 hotfix11.diff | 13 + dep/g3dlite/G3D-v9.0 hotfix12.diff | 192 ++++++++++++ dep/g3dlite/G3D-v9.0 hotfix13.diff | 35 ++- dep/g3dlite/G3D-v9.0 hotfix14.diff | 12 + dep/g3dlite/G3D-v9.0 hotfix15.diff | 288 ++++++++++++++++++ dep/g3dlite/G3D-v9.0 hotfix16.diff | 14 + dep/g3dlite/G3D-v9.0 hotfix17.diff | 13 + dep/g3dlite/Readme.txt | 8 + dep/g3dlite/include/G3D/Array.h | 4 +- dep/g3dlite/include/G3D/AtomicInt32.h | 58 ++-- dep/g3dlite/include/G3D/Matrix3.h | 2 +- dep/g3dlite/include/G3D/Ray.h | 2 +- dep/g3dlite/include/G3D/System.h | 40 ++- dep/g3dlite/include/G3D/g3dmath.h | 1 + dep/g3dlite/include/G3D/platform.h | 2 +- dep/g3dlite/source/FileSystem.cpp | 3 + dep/g3dlite/source/System.cpp | 13 +- dep/g3dlite/source/debugAssert.cpp | 2 +- src/common/DataStores/DBCFileLoader.cpp | 2 + src/common/Debugging/Errors.cpp | 2 + .../Debugging/WheatyExceptionReport.cpp | 6 +- src/common/Debugging/WheatyExceptionReport.h | 4 +- src/common/PrecompiledHeaders/commonPCH.h | 2 +- src/common/Threading/ProcessPriority.cpp | 1 + src/common/Utilities/Util.cpp | 2 + src/server/database/Database/Field.cpp | 1 + .../Database/MySQLPreparedStatement.cpp | 1 + .../Database/MySQLPreparedStatement.h | 1 - .../database/Database/MySQLWorkaround.h | 5 + src/server/database/Database/QueryResult.cpp | 1 + src/server/database/Database/Transaction.cpp | 1 + .../database/PrecompiledHeaders/databasePCH.h | 16 +- .../game/AuctionHouse/AuctionHouseMgr.cpp | 6 +- .../AuctionHouseBot/AuctionHouseBotBuyer.cpp | 4 +- src/server/game/Battlefield/Battlefield.cpp | 2 +- src/server/game/DataStores/M2Stores.cpp | 1 + .../game/Entities/Object/MovementInfo.h | 8 +- src/server/game/Handlers/MailHandler.cpp | 2 +- src/server/game/Instances/InstanceSaveMgr.cpp | 4 +- .../game/Movement/Spline/MoveSpline.cpp | 2 +- src/server/game/PrecompiledHeaders/gamePCH.h | 4 +- .../Skills/Archaeology/ArchaeologySites.cpp | 6 +- src/server/game/Tickets/TicketMgr.cpp | 2 +- .../Stratholme/boss_maleki_the_pallid.cpp | 2 +- .../Kalimdor/Firelands/boss_baleroc.cpp | 6 +- .../TempleOfAhnQiraj/boss_twinemperors.cpp | 4 +- .../scripts/Kalimdor/zone_bloodmyst_isle.cpp | 14 +- .../TrialOfTheCrusader/boss_twin_valkyr.cpp | 6 +- .../trial_of_the_crusader.cpp | 4 +- .../Northrend/Naxxramas/boss_maexxna.cpp | 2 +- .../Ulduar/HallsOfLightning/boss_ionar.cpp | 2 +- .../UtgardePinnacle/boss_svala.cpp | 8 +- src/server/scripts/Northrend/zone_dalaran.cpp | 2 +- .../botanica/boss_warp_splinter.cpp | 4 +- src/server/scripts/World/npcs_special.cpp | 2 +- .../shared/DataStores/DB2StorageLoader.cpp | 1 + src/server/shared/Packets/ByteBuffer.cpp | 1 + src/server/worldserver/Main.cpp | 4 +- src/tools/vmap4_extractor/vmapexport.cpp | 1 + src/tools/vmap4_extractor/wmo.cpp | 1 + 67 files changed, 792 insertions(+), 134 deletions(-) create mode 100644 dep/g3dlite/G3D-v9.0 hotfix10.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix11.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix12.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix14.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix15.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix16.diff create mode 100644 dep/g3dlite/G3D-v9.0 hotfix17.diff diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake index 5210c6f834..ddfc0baa9a 100644 --- a/cmake/compiler/clang/settings.cmake +++ b/cmake/compiler/clang/settings.cmake @@ -3,6 +3,14 @@ target_compile_definitions(trinity-compile-option-interface INTERFACE -D_BUILD_DIRECTIVE="$") +set(CLANG_EXPECTED_VERSION 11.0.0) + +if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION) + message(FATAL_ERROR "Clang: TrinityCore requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}") +else() + message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!") +endif() + if(WITH_WARNINGS) target_compile_options(trinity-warning-interface INTERFACE @@ -52,3 +60,13 @@ if(BUILD_SHARED_LIBS) message(STATUS "Clang: Disallow undefined symbols") endif() + +# speedup PCH builds by forcing template instantiations during PCH generation +set(CMAKE_REQUIRED_FLAGS "-fpch-instantiate-templates") +check_cxx_source_compiles("int main() { return 0; }" CLANG_HAS_PCH_INSTANTIATE_TEMPLATES) +unset(CMAKE_REQUIRED_FLAGS) +if(CLANG_HAS_PCH_INSTANTIATE_TEMPLATES) + target_compile_options(trinity-compile-option-interface + INTERFACE + -fpch-instantiate-templates) +endif() diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index b70d927b71..44a21e6736 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -3,10 +3,12 @@ target_compile_definitions(trinity-compile-option-interface INTERFACE -D_BUILD_DIRECTIVE="$") -set(GCC_EXPECTED_VERSION 7.1.0) +set(GCC_EXPECTED_VERSION 10.0.0) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_EXPECTED_VERSION) message(FATAL_ERROR "GCC: TrinityCore requires version ${GCC_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}") +else() + message(STATUS "GCC: Minimum version required is ${GCC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!") endif() if(PLATFORM EQUAL 32) diff --git a/cmake/compiler/msvc/settings.cmake b/cmake/compiler/msvc/settings.cmake index 95895fe649..f3a4f8dc9d 100644 --- a/cmake/compiler/msvc/settings.cmake +++ b/cmake/compiler/msvc/settings.cmake @@ -1,11 +1,16 @@ # set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(MSVC_EXPECTED_VERSION 19.24) -set(MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2019 16.4") +set(MSVC_EXPECTED_VERSION 19.30) +set(MSVC_EXPECTED_VERSION_STRING "Microsoft Visual Studio 2022 17") -if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION) - message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}") +# This file is also used by compilers that pretend to be MSVC but report their own version number - don't version check them +if(NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION) + message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}") + else() + message(STATUS "MSVC: Minimum version required is ${MSVC_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!") + endif() endif() # CMake sets warning flags by default, however we manage it manually @@ -21,6 +26,11 @@ target_compile_options(trinity-warning-interface INTERFACE /W3) +# disable permissive mode to make msvc more eager to reject code that other compilers don't already accept +target_compile_options(trinity-compile-option-interface + INTERFACE + /permissive-) + # set up output paths ofr static libraries etc (commented out - shown here as an example only) #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -77,12 +87,9 @@ endif() # that the program will eventually be linked with a conforming operator new implementation, # and can omit all of these extra null checks from your program. # http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx -if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0)) - # makes this flag a requirement to build TC at all - target_compile_options(trinity-compile-option-interface - INTERFACE - /Zc:throwingNew) -endif() +target_compile_options(trinity-compile-option-interface + INTERFACE + /Zc:throwingNew) # Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns target_compile_definitions(trinity-compile-option-interface diff --git a/cmake/macros/ConfigureBaseTargets.cmake b/cmake/macros/ConfigureBaseTargets.cmake index 52322c62f4..e70a204936 100644 --- a/cmake/macros/ConfigureBaseTargets.cmake +++ b/cmake/macros/ConfigureBaseTargets.cmake @@ -19,7 +19,7 @@ add_library(trinity-feature-interface INTERFACE) target_compile_features(trinity-feature-interface INTERFACE - cxx_std_17) + cxx_std_20) # An interface library to make the warnings level available to other targets # This interface taget is set-up through the platform specific script diff --git a/cmake/platform/win/settings.cmake b/cmake/platform/win/settings.cmake index 625464c703..d30d81479a 100644 --- a/cmake/platform/win/settings.cmake +++ b/cmake/platform/win/settings.cmake @@ -1,6 +1,6 @@ add_definitions(-D_WIN32_WINNT=0x0601) -if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake) elseif(CMAKE_CXX_PLATFORM_ID MATCHES "MinGW") include(${CMAKE_SOURCE_DIR}/cmake/compiler/mingw/settings.cmake) diff --git a/dep/g3dlite/CMakeLists.txt b/dep/g3dlite/CMakeLists.txt index fef2d21cb3..90d2280cc7 100644 --- a/dep/g3dlite/CMakeLists.txt +++ b/dep/g3dlite/CMakeLists.txt @@ -8,7 +8,6 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - set(g3dlib_STAT_SRCS source/AABox.cpp source/Any.cpp diff --git a/dep/g3dlite/G3D-v9.0 hotfix10.diff b/dep/g3dlite/G3D-v9.0 hotfix10.diff new file mode 100644 index 0000000000..343ac7090f --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix10.diff @@ -0,0 +1,20 @@ +diff --git a/dep/g3dlite/include/G3D/Array.h b/dep/g3dlite/include/G3D/Array.h +index c562f5c920f7..c86b20fd7e97 100644 +--- a/dep/g3dlite/include/G3D/Array.h ++++ b/dep/g3dlite/include/G3D/Array.h +@@ -346,6 +346,7 @@ class Array { + + /** Resizes this to match the size of \a other and then copies the data from other using memcpy. This is only safe for POD types */ + void copyPOD(const Array& other) { ++ static_assert(std::is_standard_layout_v && std::is_trivial_v, "copyPOD called on non-POD type"); + if (numAllocated < other.num) { + m_memoryManager->free(data); + data = NULL; +@@ -364,6 +365,7 @@ class Array { + /** Resizes this to just barely match the size of \a other + itself and then copies the data to the end of the array from other using memcpy. + This is only safe for POD types */ + void appendPOD(const Array& other) { ++ static_assert(std::is_standard_layout_v && std::is_trivial_v, "appendPOD called on non-POD type"); + const size_t oldSize = num; + num += other.num; + if (numAllocated < num) { diff --git a/dep/g3dlite/G3D-v9.0 hotfix11.diff b/dep/g3dlite/G3D-v9.0 hotfix11.diff new file mode 100644 index 0000000000..5c94416d64 --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix11.diff @@ -0,0 +1,13 @@ +diff --git a/dep/g3dlite/source/fileutils.cpp b/dep/g3dlite/source/fileutils.cpp +index 2788adad3bcd..f5310084cec7 100644 +--- a/dep/g3dlite/source/fileutils.cpp ++++ b/dep/g3dlite/source/fileutils.cpp +@@ -490,7 +490,7 @@ void parseFilename( + + } + +- } else if ((f.size() >= 2) & isSlash(f[0]) && isSlash(f[1])) { ++ } else if ((f.size() >= 2) && isSlash(f[0]) && isSlash(f[1])) { + + // e.g. //foo + root = f.substr(0, 2); diff --git a/dep/g3dlite/G3D-v9.0 hotfix12.diff b/dep/g3dlite/G3D-v9.0 hotfix12.diff new file mode 100644 index 0000000000..6594539f24 --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix12.diff @@ -0,0 +1,192 @@ +diff --git a/dep/g3dlite/include/G3D/AtomicInt32.h b/dep/g3dlite/include/G3D/AtomicInt32.h +index 7b56e001ae29..9824d426d741 100644 +--- a/dep/g3dlite/include/G3D/AtomicInt32.h ++++ b/dep/g3dlite/include/G3D/AtomicInt32.h +@@ -76,12 +76,16 @@ class AtomicInt32 { + + # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) + +- int32 old; +- asm volatile ("lock; xaddl %0,%1" +- : "=r"(old), "=m"(m_value) /* outputs */ +- : "0"(x), "m"(m_value) /* inputs */ +- : "memory", "cc"); +- return old; ++# if defined(__aarch64__) ++ return __sync_fetch_and_add(&m_value, x); ++# else ++ int32 old; ++ asm volatile ("lock; xaddl %0,%1" ++ : "=r"(old), "=m"(m_value) /* outputs */ ++ : "0"(x), "m"(m_value) /* inputs */ ++ : "memory", "cc"); ++ return old; ++# endif + + # elif defined(G3D_OSX) + +@@ -115,14 +119,18 @@ class AtomicInt32 { + // Note: returns the newly decremented value + return InterlockedDecrement(&m_value); + # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) +- unsigned char nz; +- +- asm volatile ("lock; decl %1;\n\t" +- "setnz %%al" +- : "=a" (nz) +- : "m" (m_value) +- : "memory", "cc"); +- return nz; ++# if defined(__aarch64__) ++ return __sync_sub_and_fetch(&m_value, 1); ++# else ++ unsigned char nz; ++ ++ asm volatile ("lock; decl %1;\n\t" ++ "setnz %%al" ++ : "=a" (nz) ++ : "m" (m_value) ++ : "memory", "cc"); ++ return nz; ++# endif + # elif defined(G3D_OSX) + // Note: returns the newly decremented value + return OSAtomicDecrement32(&m_value); +@@ -143,17 +151,21 @@ class AtomicInt32 { + # if defined(G3D_WINDOWS) + return InterlockedCompareExchange(&m_value, exchange, comperand); + # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX) +- // Based on Apache Portable Runtime +- // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx +- int32 ret; +- asm volatile ("lock; cmpxchgl %1, %2" +- : "=a" (ret) +- : "r" (exchange), "m" (m_value), "0"(comperand) +- : "memory", "cc"); +- return ret; +- +- // Note that OSAtomicCompareAndSwap32 does not return a useful value for us +- // so it can't satisfy the cmpxchgl contract. ++# if defined(__aarch64__) ++ return __sync_val_compare_and_swap(&m_value, comperand, exchange); ++# else ++ // Based on Apache Portable Runtime ++ // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx ++ int32 ret; ++ asm volatile ("lock; cmpxchgl %1, %2" ++ : "=a" (ret) ++ : "r" (exchange), "m" (m_value), "0"(comperand) ++ : "memory", "cc"); ++ return ret; ++ ++ // Note that OSAtomicCompareAndSwap32 does not return a useful value for us ++ // so it can't satisfy the cmpxchgl contract. ++# endif + # endif + } + +diff --git a/dep/g3dlite/include/G3D/System.h b/dep/g3dlite/include/G3D/System.h +index 4624dd916474..9ed88957d755 100644 +--- a/dep/g3dlite/include/G3D/System.h ++++ b/dep/g3dlite/include/G3D/System.h +@@ -21,6 +21,10 @@ + #include "G3D/FileNotFound.h" + #include + ++#if defined(__aarch64__) ++#include ++#endif ++ + #ifdef G3D_OSX + #define Zone OSX_Zone + # include +@@ -497,15 +501,37 @@ class System { + #elif defined(G3D_LINUX) + + inline uint64 System::getCycleCount() { +- uint32 timehi, timelo; ++# if defined(__aarch64__) ++# if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount ++ uint32_t pmccntr; ++ uint32_t pmuseren; ++ uint32_t pmcntenset; ++ // Read the user mode perf monitor counter access permissions. ++ __asm__ __volatile__("mrc p15, 0, %w0, c9, c14, 0" : "=r"(pmuseren)); ++ if (pmuseren & 1) { // Allows reading perfmon counters for user mode code. ++ __asm__ __volatile__("mrc p15, 0, %w0, c9, c12, 1" : "=r"(pmcntenset)); ++ if (pmcntenset & 0x80000000ul) { // Is it counting? ++ __asm__ __volatile__("mrc p15, 0, %w0, c9, c13, 0" : "=r"(pmccntr)); ++ // The counter is set up to count every 64th cycle ++ return static_cast(pmccntr) * 64; // Should optimize to << 6 ++ } ++ } ++# endif + +- __asm__ __volatile__ ( +- "rdtsc " +- : "=a" (timelo), +- "=d" (timehi) +- : ); ++ struct timeval tv; ++ gettimeofday(&tv, nullptr); ++ return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; ++# else ++ uint32 timehi, timelo; ++ ++ __asm__ __volatile__ ( ++ "rdtsc " ++ : "=a" (timelo), ++ "=d" (timehi) ++ : ); + +- return ((uint64)timehi << 32) + (uint64)timelo; ++ return ((uint64)timehi << 32) + (uint64)timelo; ++# endif + } + + #elif defined(G3D_OSX) +diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h +index 439495ab1315..d043f21491ad 100644 +--- a/dep/g3dlite/include/G3D/platform.h ++++ b/dep/g3dlite/include/G3D/platform.h +@@ -273,7 +273,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\ + # define __stdcall __attribute__((stdcall)) + # endif + +-# elif defined(__x86_64__) ++# elif defined(__x86_64__) || defined(__arm) || defined(__aarch64__) + + # ifndef __cdecl + # define __cdecl +diff --git a/dep/g3dlite/source/System.cpp b/dep/g3dlite/source/System.cpp +index b841e23c497e..4a75d320b8d3 100644 +--- a/dep/g3dlite/source/System.cpp ++++ b/dep/g3dlite/source/System.cpp +@@ -79,8 +79,9 @@ + #endif + + // SIMM include ++#if !defined(__aarch64__) + #include +- ++#endif + + namespace G3D { + +@@ -1697,6 +1698,16 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui + edx = regs[3]; + } + ++#elif defined(__aarch64__) || defined(G3D_OSX) && ! defined(G3D_OSX_INTEL) ++ ++// non-x86 CPU; no CPUID ++void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) { ++ eax = 0; ++ ebx = 0; ++ ecx = 0; ++ edx = 0; ++} ++ + #else + + // See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well diff --git a/dep/g3dlite/G3D-v9.0 hotfix13.diff b/dep/g3dlite/G3D-v9.0 hotfix13.diff index a2127a2907..b02e2242be 100644 --- a/dep/g3dlite/G3D-v9.0 hotfix13.diff +++ b/dep/g3dlite/G3D-v9.0 hotfix13.diff @@ -1,12 +1,25 @@ -diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h -index 1c42513b45..05d9b11ed5 100644 ---- a/dep/g3dlite/include/G3D/Vector3.h -+++ b/dep/g3dlite/include/G3D/Vector3.h -@@ -128,7 +128,6 @@ public: - Axis primaryAxis() const; +diff --git a/dep/g3dlite/include/G3D/g3dmath.h b/dep/g3dlite/include/G3D/g3dmath.h +index 54cc6ed370..002cd3858d 100644 +--- a/dep/g3dlite/include/G3D/g3dmath.h ++++ b/dep/g3dlite/include/G3D/g3dmath.h +@@ -27,6 +27,7 @@ + #include "G3D/platform.h" + #include + #include ++#include + #include + #include + #include +diff --git a/dep/g3dlite/source/debugAssert.cpp b/dep/g3dlite/source/debugAssert.cpp +index cfccf9a0cc..3c3e43a0af 100644 +--- a/dep/g3dlite/source/debugAssert.cpp ++++ b/dep/g3dlite/source/debugAssert.cpp +@@ -99,7 +99,7 @@ static void createErrorMessage( + } - // assignment and comparison -- Vector3& operator=(const Vector3& rkVector) = default; - Vector3& operator=(const Any& a); - bool operator== (const Vector3& rkVector) const; - bool operator!= (const Vector3& rkVector) const; + // Make sure the message got translated into something. +- LPTSTR realLastErr; ++ LPCTSTR realLastErr; + if (NULL != formatMsg) { + realLastErr = formatMsg; + } else { diff --git a/dep/g3dlite/G3D-v9.0 hotfix14.diff b/dep/g3dlite/G3D-v9.0 hotfix14.diff new file mode 100644 index 0000000000..a2127a2907 --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix14.diff @@ -0,0 +1,12 @@ +diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h +index 1c42513b45..05d9b11ed5 100644 +--- a/dep/g3dlite/include/G3D/Vector3.h ++++ b/dep/g3dlite/include/G3D/Vector3.h +@@ -128,7 +128,6 @@ public: + Axis primaryAxis() const; + + // assignment and comparison +- Vector3& operator=(const Vector3& rkVector) = default; + Vector3& operator=(const Any& a); + bool operator== (const Vector3& rkVector) const; + bool operator!= (const Vector3& rkVector) const; diff --git a/dep/g3dlite/G3D-v9.0 hotfix15.diff b/dep/g3dlite/G3D-v9.0 hotfix15.diff new file mode 100644 index 0000000000..d385def554 --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix15.diff @@ -0,0 +1,288 @@ +diff --git a/dep/g3dlite/include/G3D/AABox.h b/dep/g3dlite/include/G3D/AABox.h +index 7a47ea63aa..97a47cf986 100644 +--- a/dep/g3dlite/include/G3D/AABox.h ++++ b/dep/g3dlite/include/G3D/AABox.h +@@ -17,14 +17,14 @@ + + #include "G3D/platform.h" + #include "G3D/debug.h" +-#include "G3D/Array.h" +-#include "G3D/Plane.h" +-#include "G3D/Sphere.h" + #include "G3D/Vector3.h" + + namespace G3D { + + class Any; ++template class Array; ++class Plane; ++class Sphere; + + /** + An axis-aligned box. +@@ -221,7 +221,7 @@ public: + + */ + bool culledBy +- (const Array& plane, ++ (const Array& plane, + int32& cullingPlaneIndex, + const uint32 testMask, + uint32& childMask) const; +@@ -230,7 +230,7 @@ public: + Conservative culling test that does not produce a mask for children. + */ + bool culledBy +- (const Array& plane, ++ (const Array& plane, + int32& cullingPlaneIndex = dummy, + const uint32 testMask = 0xFFFFFFFF) const; + +diff --git a/dep/g3dlite/include/G3D/AtomicInt32.h b/dep/g3dlite/include/G3D/AtomicInt32.h +index 9824d426d7..51561e3dcc 100644 +--- a/dep/g3dlite/include/G3D/AtomicInt32.h ++++ b/dep/g3dlite/include/G3D/AtomicInt32.h +@@ -12,7 +12,9 @@ + #include "G3D/platform.h" + #include "G3D/g3dmath.h" + +-#if defined(G3D_OSX) ++#if defined(G3D_WINDOWS) ++# include ++#elif defined(G3D_OSX) + # include + #endif + +diff --git a/dep/g3dlite/include/G3D/HashTrait.h b/dep/g3dlite/include/G3D/HashTrait.h +index 1de3777bae..6199f4504e 100644 +--- a/dep/g3dlite/include/G3D/HashTrait.h ++++ b/dep/g3dlite/include/G3D/HashTrait.h +@@ -13,7 +13,6 @@ + #define G3D_HashTrait_h + + #include "G3D/platform.h" +-#include "G3D/Crypto.h" + #include "G3D/g3dmath.h" + #include "G3D/uint128.h" + #include +diff --git a/dep/g3dlite/include/G3D/Random.h b/dep/g3dlite/include/G3D/Random.h +index 9d911806a9..359755044a 100644 +--- a/dep/g3dlite/include/G3D/Random.h ++++ b/dep/g3dlite/include/G3D/Random.h +@@ -159,6 +159,7 @@ public: + static Random& common(); + }; + ++Random& commonRandom(); + } + + #endif +diff --git a/dep/g3dlite/include/G3D/System.h b/dep/g3dlite/include/G3D/System.h +index 9ed88957d7..81c83527c9 100644 +--- a/dep/g3dlite/include/G3D/System.h ++++ b/dep/g3dlite/include/G3D/System.h +@@ -21,6 +21,10 @@ + #include "G3D/FileNotFound.h" + #include + ++#ifdef G3D_WINDOWS ++#include ++#endif ++ + #if defined(__aarch64__) + #include + #endif +diff --git a/dep/g3dlite/include/G3D/Vector2.h b/dep/g3dlite/include/G3D/Vector2.h +index 65cf7fa8f2..696889d630 100644 +--- a/dep/g3dlite/include/G3D/Vector2.h ++++ b/dep/g3dlite/include/G3D/Vector2.h +@@ -19,20 +19,21 @@ + + #include "G3D/platform.h" + #include "G3D/g3dmath.h" +-#include "G3D/Table.h" + #include "G3D/HashTrait.h" + #include "G3D/Vector2int16.h" + #include "G3D/Vector2unorm16.h" +-#include "G3D/Random.h" + + namespace G3D { + ++class Random; + class Vector2; + class Vector3; + class Vector4; + class Vector2int32; + class Any; + ++Random& commonRandom(); ++ + /** + Do not subclass-- this implementation makes assumptions about the + memory layout. +@@ -210,7 +211,7 @@ public: + } + + /** Uniformly distributed random vector on the unit sphere */ +- static Vector2 random(Random& r = Random::common()); ++ static Vector2 random(Random& r = commonRandom()); + + // Special values. + // Intentionally not inlined: see Matrix3::identity() for details. +diff --git a/dep/g3dlite/include/G3D/Vector3.h b/dep/g3dlite/include/G3D/Vector3.h +index 05d9b11ed5..c79f70b916 100644 +--- a/dep/g3dlite/include/G3D/Vector3.h ++++ b/dep/g3dlite/include/G3D/Vector3.h +@@ -17,9 +17,7 @@ + + #include "G3D/platform.h" + #include "G3D/g3dmath.h" +-#include "G3D/Random.h" + #include "G3D/Vector2.h" +-#include "G3D/Table.h" + #include "G3D/HashTrait.h" + #include "G3D/PositionTrait.h" + #include "G3D/Vector2.h" +@@ -365,7 +363,7 @@ public: + Distribution rendered by G3D::DirectionHistogram: + \image html vector3-random.png + */ +- static Vector3 random(Random& r = Random::common()); ++ static Vector3 random(Random& r = commonRandom()); + + /** \brief Random unit vector, distributed according to \f$\max(\cos \theta,0)\f$. + +@@ -380,9 +378,9 @@ public: + + @cite Henrik Wann Jensen, Realistic Image Synthesis using Photon Mapping eqn 2.24 + */ +- static Vector3 cosHemiRandom(const Vector3& n, Random& r = Random::common()); ++ static Vector3 cosHemiRandom(const Vector3& n, Random& r = commonRandom()); + +- static Vector3 cosSphereRandom(const Vector3& n, Random& r = Random::common()); ++ static Vector3 cosSphereRandom(const Vector3& n, Random& r = commonRandom()); + + /** \brief Random unit vector, distributed according to \f$\max(\cos^k \theta,0)\f$. + +@@ -397,7 +395,7 @@ public: + + @cite Ashikhmin and Shirley, An anisotropic Phong BRDF model, Journal of Graphics Tools, 2002 + */ +- static Vector3 cosPowHemiRandom(const Vector3& n, const float k, Random& r = Random::common()); ++ static Vector3 cosPowHemiRandom(const Vector3& n, const float k, Random& r = commonRandom()); + + /** + \brief Random vector distributed over the hemisphere about normal. +@@ -405,7 +403,7 @@ public: + Distribution rendered by G3D::DirectionHistogram: + \image html vector3-hemirandom.png + */ +- static Vector3 hemiRandom(const Vector3& normal, Random& r = Random::common()); ++ static Vector3 hemiRandom(const Vector3& normal, Random& r = commonRandom()); + + inline float sum() const { + return x + y + z; +diff --git a/dep/g3dlite/include/G3D/Vector4.h b/dep/g3dlite/include/G3D/Vector4.h +index 24521efc93..0f0ea459df 100644 +--- a/dep/g3dlite/include/G3D/Vector4.h ++++ b/dep/g3dlite/include/G3D/Vector4.h +@@ -19,7 +19,6 @@ + #include "G3D/g3dmath.h" + #include "G3D/Vector3.h" + #include "G3D/Vector2.h" +-#include "G3D/Table.h" + #include "G3D/HashTrait.h" + #include "G3D/PositionTrait.h" + #include +diff --git a/dep/g3dlite/include/G3D/debugAssert.h b/dep/g3dlite/include/G3D/debugAssert.h +index edff671061..197312bd12 100644 +--- a/dep/g3dlite/include/G3D/debugAssert.h ++++ b/dep/g3dlite/include/G3D/debugAssert.h +@@ -32,6 +32,7 @@ + #include + + #ifdef _MSC_VER ++#include + // conditional expression is constant + # pragma warning (disable : 4127) + #endif +@@ -116,7 +117,7 @@ namespace _internal { + #ifdef G3D_DEBUG + + # if defined(_MSC_VER) +-# define rawBreak() ::DebugBreak(); ++# define rawBreak() ::__debugbreak(); + # elif defined(__i386__) + // gcc on intel + # define rawBreak() __asm__ __volatile__ ( "int $3" ); +diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h +index d043f21491..9202fe41d0 100644 +--- a/dep/g3dlite/include/G3D/platform.h ++++ b/dep/g3dlite/include/G3D/platform.h +@@ -190,6 +190,7 @@ These control the version of Winsock used by G3D. + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_Compiler_Reference.asp + // + ++#if 0 + // DLL runtime + #ifndef _DLL + #define _DLL +@@ -227,6 +228,8 @@ These control the version of Winsock used by G3D. + # undef WIN32_LEAN_AND_MEAN + # undef NOMINMAX + ++#endif // 0 ++ + # ifdef _G3D_INTERNAL_HIDE_WINSOCK_ + # undef _G3D_INTERNAL_HIDE_WINSOCK_ + # undef _WINSOCKAPI_ +diff --git a/dep/g3dlite/source/Random.cpp b/dep/g3dlite/source/Random.cpp +index cbfa07dec0..a31d52a557 100644 +--- a/dep/g3dlite/source/Random.cpp ++++ b/dep/g3dlite/source/Random.cpp +@@ -227,4 +227,9 @@ void Random::sphere(float& x, float& y, float& z) { + z *= s; + } + ++Random& commonRandom() ++{ ++ return Random::common(); ++} ++ + } // G3D +diff --git a/dep/g3dlite/source/Vector2.cpp b/dep/g3dlite/source/Vector2.cpp +index a6edea9a83..194cd3090d 100644 +--- a/dep/g3dlite/source/Vector2.cpp ++++ b/dep/g3dlite/source/Vector2.cpp +@@ -23,6 +23,7 @@ + #include "G3D/TextInput.h" + #include "G3D/TextOutput.h" + #include "G3D/Any.h" ++#include "G3D/Random.h" + + namespace G3D { + +diff --git a/dep/g3dlite/source/Vector3.cpp b/dep/g3dlite/source/Vector3.cpp +index e2d9643e5c..ccbf7d6a0b 100644 +--- a/dep/g3dlite/source/Vector3.cpp ++++ b/dep/g3dlite/source/Vector3.cpp +@@ -28,6 +28,7 @@ + #include "G3D/Vector4.h" + #include "G3D/Vector3int32.h" + #include "G3D/Any.h" ++#include "G3D/Random.h" + + namespace G3D { + +diff --git a/dep/g3dlite/source/debugAssert.cpp b/dep/g3dlite/source/debugAssert.cpp +index 3c3e43a0af..ff843fb7ee 100644 +--- a/dep/g3dlite/source/debugAssert.cpp ++++ b/dep/g3dlite/source/debugAssert.cpp +@@ -23,6 +23,7 @@ + #include + + #ifdef _MSC_VER ++#include + // disable: "C++ exception handler used" + # pragma warning (push) + # pragma warning (disable : 4530) diff --git a/dep/g3dlite/G3D-v9.0 hotfix16.diff b/dep/g3dlite/G3D-v9.0 hotfix16.diff new file mode 100644 index 0000000000..5e33c19617 --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix16.diff @@ -0,0 +1,14 @@ +diff --git a/dep/g3dlite/source/FileSystem.cpp b/dep/g3dlite/source/FileSystem.cpp +index 06e6ff00a5e3..0898af795348 100644 +--- a/dep/g3dlite/source/FileSystem.cpp ++++ b/dep/g3dlite/source/FileSystem.cpp +@@ -35,6 +35,9 @@ + # include + # include + # define _getcwd getcwd ++# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++# define stat64 stat ++# endif + # define _stat stat + # define stricmp strcasecmp + # define strnicmp strncasecmp diff --git a/dep/g3dlite/G3D-v9.0 hotfix17.diff b/dep/g3dlite/G3D-v9.0 hotfix17.diff new file mode 100644 index 0000000000..cb5367c65f --- /dev/null +++ b/dep/g3dlite/G3D-v9.0 hotfix17.diff @@ -0,0 +1,13 @@ +diff --git a/dep/g3dlite/source/FileSystem.cpp b/dep/g3dlite/source/FileSystem.cpp +index 0898af7953..ff5da02344 100644 +--- a/dep/g3dlite/source/FileSystem.cpp ++++ b/dep/g3dlite/source/FileSystem.cpp +@@ -35,7 +35,7 @@ + # include + # include + # define _getcwd getcwd +-# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) + # define stat64 stat + # endif + # define _stat stat diff --git a/dep/g3dlite/Readme.txt b/dep/g3dlite/Readme.txt index e94dbaabd7..5477030e5c 100644 --- a/dep/g3dlite/Readme.txt +++ b/dep/g3dlite/Readme.txt @@ -17,3 +17,11 @@ G3D-v9.0 hotfix4.diff - 2015-07-02 - backport G3D10 fix G3D-v9.0 hotfix5.diff - 2015-07-31 - fix MSVC 2015 warning: dep/g3dlite/include/G3D/Quat.h(352): warning C4458: declaration of 'x' hides class member G3D-v9.0 hotfix6.diff - 2015-11-04 - fix adding std::shared_ptr, std::weak_ptr, std::dynamic_pointer_cast, std::static_pointer_cast and std::enable_shared_from_this to global namespace G3D-v9.0 hotfix7.diff - 2016-10-10 - fix warning on clang 3.8 backported from G3D 10 +G3D-v9.0 hotfix8.diff - 2017-03-07 - fix MSVC 2017 build +G3D-v9.0 hotfix9.diff - 2020-07-13 - warning fixes +G3D-v9.0 hotfix10.diff - 2017-11-11 - static analysis issue fix +G3D-v9.0 hotfix11.diff - 2017-11-11 - static analysis issue fix +G3D-v9.0 hotfix12.diff - 2020-02-23 - ARM64 build fix +G3D-v9.0 hotfix13.diff - 2020-08-04 - MSVC build fix with /permissive- +G3D-v9.0 hotfix14.diff - 2022-01-16 - warning fixes +G3D-v9.0 hotfix16.diff - 2022-02-11 - Fix *BSD compile errors diff --git a/dep/g3dlite/include/G3D/Array.h b/dep/g3dlite/include/G3D/Array.h index c86b20fd7e..788237dce5 100644 --- a/dep/g3dlite/include/G3D/Array.h +++ b/dep/g3dlite/include/G3D/Array.h @@ -346,7 +346,7 @@ public: /** Resizes this to match the size of \a other and then copies the data from other using memcpy. This is only safe for POD types */ void copyPOD(const Array& other) { - static_assert(std::is_pod::value, "copyPOD called on non-POD type"); + static_assert(std::is_standard_layout_v && std::is_trivial_v, "copyPOD called on non-POD type"); if (numAllocated < other.num) { m_memoryManager->free(data); data = NULL; @@ -365,7 +365,7 @@ public: /** Resizes this to just barely match the size of \a other + itself and then copies the data to the end of the array from other using memcpy. This is only safe for POD types */ void appendPOD(const Array& other) { - static_assert(std::is_pod::value, "appendPOD called on non-POD type"); + static_assert(std::is_standard_layout_v && std::is_trivial_v, "appendPOD called on non-POD type"); const size_t oldSize = num; num += other.num; if (numAllocated < num) { diff --git a/dep/g3dlite/include/G3D/AtomicInt32.h b/dep/g3dlite/include/G3D/AtomicInt32.h index 7b56e001ae..9824d426d7 100644 --- a/dep/g3dlite/include/G3D/AtomicInt32.h +++ b/dep/g3dlite/include/G3D/AtomicInt32.h @@ -76,12 +76,16 @@ public: # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) - int32 old; - asm volatile ("lock; xaddl %0,%1" - : "=r"(old), "=m"(m_value) /* outputs */ - : "0"(x), "m"(m_value) /* inputs */ - : "memory", "cc"); - return old; +# if defined(__aarch64__) + return __sync_fetch_and_add(&m_value, x); +# else + int32 old; + asm volatile ("lock; xaddl %0,%1" + : "=r"(old), "=m"(m_value) /* outputs */ + : "0"(x), "m"(m_value) /* inputs */ + : "memory", "cc"); + return old; +# endif # elif defined(G3D_OSX) @@ -115,14 +119,18 @@ public: // Note: returns the newly decremented value return InterlockedDecrement(&m_value); # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) - unsigned char nz; +# if defined(__aarch64__) + return __sync_sub_and_fetch(&m_value, 1); +# else + unsigned char nz; - asm volatile ("lock; decl %1;\n\t" - "setnz %%al" - : "=a" (nz) - : "m" (m_value) - : "memory", "cc"); - return nz; + asm volatile ("lock; decl %1;\n\t" + "setnz %%al" + : "=a" (nz) + : "m" (m_value) + : "memory", "cc"); + return nz; +# endif # elif defined(G3D_OSX) // Note: returns the newly decremented value return OSAtomicDecrement32(&m_value); @@ -143,17 +151,21 @@ public: # if defined(G3D_WINDOWS) return InterlockedCompareExchange(&m_value, exchange, comperand); # elif defined(G3D_LINUX) || defined(G3D_FREEBSD) || defined(G3D_OSX) - // Based on Apache Portable Runtime - // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx - int32 ret; - asm volatile ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (exchange), "m" (m_value), "0"(comperand) - : "memory", "cc"); - return ret; +# if defined(__aarch64__) + return __sync_val_compare_and_swap(&m_value, comperand, exchange); +# else + // Based on Apache Portable Runtime + // http://koders.com/c/fid3B6631EE94542CDBAA03E822CA780CBA1B024822.aspx + int32 ret; + asm volatile ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (exchange), "m" (m_value), "0"(comperand) + : "memory", "cc"); + return ret; - // Note that OSAtomicCompareAndSwap32 does not return a useful value for us - // so it can't satisfy the cmpxchgl contract. + // Note that OSAtomicCompareAndSwap32 does not return a useful value for us + // so it can't satisfy the cmpxchgl contract. +# endif # endif } diff --git a/dep/g3dlite/include/G3D/Matrix3.h b/dep/g3dlite/include/G3D/Matrix3.h index 13cd41040f..be2c3fac61 100644 --- a/dep/g3dlite/include/G3D/Matrix3.h +++ b/dep/g3dlite/include/G3D/Matrix3.h @@ -349,7 +349,7 @@ public: // "You might be tempted to write [...] them as inline functions // inside their respective header files, but this is something you // must definitely not do. An inline function can be duplicated - // in every file in which it appears œóõ½ and this duplication + // in every file in which it appears and this duplication // includes the static object definition. Because inline functions // automatically default to internal linkage, this would result in // having multiple static objects across the various translation diff --git a/dep/g3dlite/include/G3D/Ray.h b/dep/g3dlite/include/G3D/Ray.h index 1ca77c242d..79afc7616e 100644 --- a/dep/g3dlite/include/G3D/Ray.h +++ b/dep/g3dlite/include/G3D/Ray.h @@ -36,7 +36,7 @@ private: /** The following are for the "ray slope" optimization from "Fast Ray / Axis-Aligned Bounding Box Overlap Tests using Ray Slopes" - by Martin Eisemann, Thorsten Grosch, Stefan M�üller and Marcus Magnor + by Martin Eisemann, Thorsten Grosch, Stefan Müller and Marcus Magnor Computer Graphics Lab, TU Braunschweig, Germany and University of Koblenz-Landau, Germany */ enum Classification {MMM, MMP, MPM, MPP, PMM, PMP, PPM, PPP, POO, MOO, OPO, OMO, OOP, OOM, OMM, OMP, OPM, OPP, MOM, MOP, POM, POP, MMO, MPO, PMO, PPO}; diff --git a/dep/g3dlite/include/G3D/System.h b/dep/g3dlite/include/G3D/System.h index 4624dd9164..9ed88957d7 100644 --- a/dep/g3dlite/include/G3D/System.h +++ b/dep/g3dlite/include/G3D/System.h @@ -21,6 +21,10 @@ #include "G3D/FileNotFound.h" #include +#if defined(__aarch64__) +#include +#endif + #ifdef G3D_OSX #define Zone OSX_Zone # include @@ -497,15 +501,37 @@ public: #elif defined(G3D_LINUX) inline uint64 System::getCycleCount() { - uint32 timehi, timelo; +# if defined(__aarch64__) +# if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount + uint32_t pmccntr; + uint32_t pmuseren; + uint32_t pmcntenset; + // Read the user mode perf monitor counter access permissions. + __asm__ __volatile__("mrc p15, 0, %w0, c9, c14, 0" : "=r"(pmuseren)); + if (pmuseren & 1) { // Allows reading perfmon counters for user mode code. + __asm__ __volatile__("mrc p15, 0, %w0, c9, c12, 1" : "=r"(pmcntenset)); + if (pmcntenset & 0x80000000ul) { // Is it counting? + __asm__ __volatile__("mrc p15, 0, %w0, c9, c13, 0" : "=r"(pmccntr)); + // The counter is set up to count every 64th cycle + return static_cast(pmccntr) * 64; // Should optimize to << 6 + } + } +# endif - __asm__ __volatile__ ( - "rdtsc " - : "=a" (timelo), - "=d" (timehi) - : ); + struct timeval tv; + gettimeofday(&tv, nullptr); + return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; +# else + uint32 timehi, timelo; - return ((uint64)timehi << 32) + (uint64)timelo; + __asm__ __volatile__ ( + "rdtsc " + : "=a" (timelo), + "=d" (timehi) + : ); + + return ((uint64)timehi << 32) + (uint64)timelo; +# endif } #elif defined(G3D_OSX) diff --git a/dep/g3dlite/include/G3D/g3dmath.h b/dep/g3dlite/include/G3D/g3dmath.h index 54cc6ed370..002cd3858d 100644 --- a/dep/g3dlite/include/G3D/g3dmath.h +++ b/dep/g3dlite/include/G3D/g3dmath.h @@ -27,6 +27,7 @@ #include "G3D/platform.h" #include #include +#include #include #include #include diff --git a/dep/g3dlite/include/G3D/platform.h b/dep/g3dlite/include/G3D/platform.h index 439495ab13..d043f21491 100644 --- a/dep/g3dlite/include/G3D/platform.h +++ b/dep/g3dlite/include/G3D/platform.h @@ -273,7 +273,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {\ # define __stdcall __attribute__((stdcall)) # endif -# elif defined(__x86_64__) +# elif defined(__x86_64__) || defined(__arm) || defined(__aarch64__) # ifndef __cdecl # define __cdecl diff --git a/dep/g3dlite/source/FileSystem.cpp b/dep/g3dlite/source/FileSystem.cpp index 06e6ff00a5..0898af7953 100644 --- a/dep/g3dlite/source/FileSystem.cpp +++ b/dep/g3dlite/source/FileSystem.cpp @@ -35,6 +35,9 @@ # include # include # define _getcwd getcwd +# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# define stat64 stat +# endif # define _stat stat # define stricmp strcasecmp # define strnicmp strncasecmp diff --git a/dep/g3dlite/source/System.cpp b/dep/g3dlite/source/System.cpp index b841e23c49..4a75d320b8 100644 --- a/dep/g3dlite/source/System.cpp +++ b/dep/g3dlite/source/System.cpp @@ -79,8 +79,9 @@ #endif // SIMM include +#if !defined(__aarch64__) #include - +#endif namespace G3D { @@ -1697,6 +1698,16 @@ void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, ui edx = regs[3]; } +#elif defined(__aarch64__) || defined(G3D_OSX) && ! defined(G3D_OSX_INTEL) + +// non-x86 CPU; no CPUID +void System::cpuid(CPUIDFunction func, uint32& eax, uint32& ebx, uint32& ecx, uint32& edx) { + eax = 0; + ebx = 0; + ecx = 0; + edx = 0; +} + #else // See http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well diff --git a/dep/g3dlite/source/debugAssert.cpp b/dep/g3dlite/source/debugAssert.cpp index cfccf9a0cc..3c3e43a0af 100644 --- a/dep/g3dlite/source/debugAssert.cpp +++ b/dep/g3dlite/source/debugAssert.cpp @@ -99,7 +99,7 @@ static void createErrorMessage( } // Make sure the message got translated into something. - LPTSTR realLastErr; + LPCTSTR realLastErr; if (NULL != formatMsg) { realLastErr = formatMsg; } else { diff --git a/src/common/DataStores/DBCFileLoader.cpp b/src/common/DataStores/DBCFileLoader.cpp index 329622502f..ee237c3bef 100644 --- a/src/common/DataStores/DBCFileLoader.cpp +++ b/src/common/DataStores/DBCFileLoader.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "DBCFileLoader.h" #include "Errors.h" diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp index 06692eeb7c..b00402d5ff 100644 --- a/src/common/Debugging/Errors.cpp +++ b/src/common/Debugging/Errors.cpp @@ -35,10 +35,12 @@ #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS #include +#include #define Crash(message) \ ULONG_PTR execeptionArgs[] = { reinterpret_cast(strdup(message)), reinterpret_cast(_ReturnAddress()) }; \ RaiseException(EXCEPTION_ASSERTION_FAILURE, 0, 2, execeptionArgs); #else +#include // should be easily accessible in gdb extern "C" { TC_COMMON_API char const* TrinityAssertionFailedMessage = nullptr; } #define Crash(message) \ diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 04edcc5cae..ecc1ba3cff 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -14,7 +14,7 @@ #pragma warning(disable:4311) #include #include -#include +#include #include #define _NO_CVCONST_H #include @@ -771,7 +771,7 @@ PEXCEPTION_POINTERS pExceptionInfo) // Given an exception code, returns a pointer to a static string with a // description of the exception //====================================================================== -LPTSTR WheatyExceptionReport::GetExceptionString(DWORD dwCode) +LPCTSTR WheatyExceptionReport::GetExceptionString(DWORD dwCode) { #define EXCEPTION(x) case EXCEPTION_##x: return _T(#x); @@ -1108,7 +1108,7 @@ DWORD dwTypeIndex, DWORD_PTR offset, bool & bHandled, char const* Name, -char* /*suffix*/, +char const* /*suffix*/, bool newSymbol, bool logChildren) { diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index c250670f8a..062ddf1346 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -167,7 +167,7 @@ class WheatyExceptionReport static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount); // Helper functions - static LPTSTR GetExceptionString(DWORD dwCode); + static LPCTSTR GetExceptionString(DWORD dwCode); static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len, DWORD& section, DWORD_PTR& offset); @@ -177,7 +177,7 @@ class WheatyExceptionReport static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME64 *); - static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool &, char const*, char*, bool, bool); + static void DumpTypeIndex(DWORD64, DWORD, DWORD_PTR, bool &, char const*, char const*, bool, bool); static void FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize, size_t countOverride = 0); diff --git a/src/common/PrecompiledHeaders/commonPCH.h b/src/common/PrecompiledHeaders/commonPCH.h index 614a2d1836..e2dd51298f 100644 --- a/src/common/PrecompiledHeaders/commonPCH.h +++ b/src/common/PrecompiledHeaders/commonPCH.h @@ -29,7 +29,7 @@ #include "VMapDefinitions.h" #include "WorldModel.h" #include -#include +#include #include #include #include diff --git a/src/common/Threading/ProcessPriority.cpp b/src/common/Threading/ProcessPriority.cpp index 3428a56258..aafc1c49b0 100644 --- a/src/common/Threading/ProcessPriority.cpp +++ b/src/common/Threading/ProcessPriority.cpp @@ -21,6 +21,7 @@ #ifdef _WIN32 // Windows #include #elif defined(__linux__) +#include #include #include #define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0 diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 9115863082..68bfe601f5 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -122,6 +122,8 @@ time_t LocalTimeToUTCTime(time_t time) { #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) return time + _timezone; +#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) + return timegm(gmtime(&time)); #else return time + timezone; #endif diff --git a/src/server/database/Database/Field.cpp b/src/server/database/Database/Field.cpp index 9791dcf628..e47d362929 100644 --- a/src/server/database/Database/Field.cpp +++ b/src/server/database/Database/Field.cpp @@ -18,6 +18,7 @@ #include "Field.h" #include "Log.h" #include "MySQLHacks.h" +#include Field::Field() { diff --git a/src/server/database/Database/MySQLPreparedStatement.cpp b/src/server/database/Database/MySQLPreparedStatement.cpp index 2e84880490..b8901bc207 100644 --- a/src/server/database/Database/MySQLPreparedStatement.cpp +++ b/src/server/database/Database/MySQLPreparedStatement.cpp @@ -20,6 +20,7 @@ #include "Log.h" #include "MySQLHacks.h" #include "PreparedStatement.h" +#include #include MySQLPreparedStatement::MySQLPreparedStatement(MySQLStmt* stmt, std::string queryString) : diff --git a/src/server/database/Database/MySQLPreparedStatement.h b/src/server/database/Database/MySQLPreparedStatement.h index 46926ed858..05c045d21c 100644 --- a/src/server/database/Database/MySQLPreparedStatement.h +++ b/src/server/database/Database/MySQLPreparedStatement.h @@ -20,7 +20,6 @@ #include "DatabaseEnvFwd.h" #include "Define.h" -#include "MySQLWorkaround.h" #include #include diff --git a/src/server/database/Database/MySQLWorkaround.h b/src/server/database/Database/MySQLWorkaround.h index 0b588bb947..b9e15c260e 100644 --- a/src/server/database/Database/MySQLWorkaround.h +++ b/src/server/database/Database/MySQLWorkaround.h @@ -15,7 +15,12 @@ * with this program. If not, see . */ +#ifndef MySQLWorkaround_h__ +#define MySQLWorkaround_h__ + #ifdef _WIN32 // hack for broken mysql.h not including the correct winsock header for SOCKET definition, fixed in 5.7 #include #endif #include + +#endif // MySQLWorkaround_h__ diff --git a/src/server/database/Database/QueryResult.cpp b/src/server/database/Database/QueryResult.cpp index f7d51b8368..4ba1aefce4 100644 --- a/src/server/database/Database/QueryResult.cpp +++ b/src/server/database/Database/QueryResult.cpp @@ -21,6 +21,7 @@ #include "Log.h" #include "MySQLHacks.h" #include "MySQLWorkaround.h" +#include namespace { diff --git a/src/server/database/Database/Transaction.cpp b/src/server/database/Database/Transaction.cpp index e796f48818..7c5eca208a 100644 --- a/src/server/database/Database/Transaction.cpp +++ b/src/server/database/Database/Transaction.cpp @@ -23,6 +23,7 @@ #include #include #include +#include std::mutex TransactionTask::_deadlockLock; diff --git a/src/server/database/PrecompiledHeaders/databasePCH.h b/src/server/database/PrecompiledHeaders/databasePCH.h index 1717eb3428..d8c2af9bb0 100644 --- a/src/server/database/PrecompiledHeaders/databasePCH.h +++ b/src/server/database/PrecompiledHeaders/databasePCH.h @@ -15,18 +15,6 @@ * with this program. If not, see . */ -#include "Define.h" -#include "Errors.h" -#include "Field.h" +#include "DatabaseEnv.h" #include "Log.h" -#include "MySQLConnection.h" -#include "PreparedStatement.h" -#include "QueryResult.h" -#include "SQLOperation.h" -#include "Transaction.h" -#ifdef _WIN32 // hack for broken mysql.h not including the correct winsock header for SOCKET definition, fixed in 5.7 -#include -#endif -#include -#include -#include +#include "MySQLHacks.h" diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 37ff3d31dd..05e5ba708d 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -91,7 +91,7 @@ uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 uint32 MSV = pItem->GetTemplate()->GetSellPrice(); if (MSV <= 0) - return AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT); + return AsUnderlyingType(AH_MINIMUM_DEPOSIT) * sWorld->getRate(RATE_AUCTION_DEPOSIT); float multiplier = CalculatePct(float(entry->DepositRate), 3); uint32 timeHr = (((time / 60) / 60) / 12); @@ -113,8 +113,8 @@ uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 TC_LOG_DEBUG("auctionHouse", "Deposit: " UI64FMTD, deposit); TC_LOG_DEBUG("auctionHouse", "Deposit rm: %f", remainderbase * count); - if (deposit < AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT)) - return AH_MINIMUM_DEPOSIT * sWorld->getRate(RATE_AUCTION_DEPOSIT); + if (deposit < AsUnderlyingType(AH_MINIMUM_DEPOSIT) * sWorld->getRate(RATE_AUCTION_DEPOSIT)) + return AsUnderlyingType(AH_MINIMUM_DEPOSIT) * sWorld->getRate(RATE_AUCTION_DEPOSIT); else return deposit; } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index 9074adb318..b670d25a80 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -386,7 +386,7 @@ uint32 AuctionBotBuyer::GetChanceMultiplier(uint32 quality) // Buys the auction and does necessary actions to complete the buyout void AuctionBotBuyer::BuyEntry(AuctionEntry* auction, AuctionHouseObject* auctionHouse) { - TC_LOG_DEBUG("ahbot", "AHBot: Entry %u bought at %.2fg", auction->Id, float(auction->buyout) / GOLD); + TC_LOG_DEBUG("ahbot", "AHBot: Entry %u bought at %.2fg", auction->Id, float(auction->buyout) / float(GOLD)); CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); @@ -417,7 +417,7 @@ void AuctionBotBuyer::BuyEntry(AuctionEntry* auction, AuctionHouseObject* auctio // Bids on the auction and does the necessary actions for bidding void AuctionBotBuyer::PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice) { - TC_LOG_DEBUG("ahbot", "AHBot: Bid placed to entry %u, %.2fg", auction->Id, float(bidPrice) / GOLD); + TC_LOG_DEBUG("ahbot", "AHBot: Bid placed to entry %u, %.2fg", auction->Id, float(bidPrice) / float(GOLD)); CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 6f5e0da4f7..3bebb1e270 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -982,7 +982,7 @@ bool BfCapturePoint::Update(uint32 diff) } // get the difference of numbers - float fact_diff = ((float) m_activePlayers[TEAM_ALLIANCE].size() - (float) m_activePlayers[TEAM_HORDE].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL; + float fact_diff = ((float) m_activePlayers[TEAM_ALLIANCE].size() - (float) m_activePlayers[TEAM_HORDE].size()) * diff / float(BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL); if (G3D::fuzzyEq(fact_diff, 0.0f)) return false; diff --git a/src/server/game/DataStores/M2Stores.cpp b/src/server/game/DataStores/M2Stores.cpp index db2931ce78..fd2ce938dd 100644 --- a/src/server/game/DataStores/M2Stores.cpp +++ b/src/server/game/DataStores/M2Stores.cpp @@ -23,6 +23,7 @@ #include "M2Stores.h" #include "World.h" #include +#include #include #include #include diff --git a/src/server/game/Entities/Object/MovementInfo.h b/src/server/game/Entities/Object/MovementInfo.h index 0e32a41cd2..0a10dbd0f9 100644 --- a/src/server/game/Entities/Object/MovementInfo.h +++ b/src/server/game/Entities/Object/MovementInfo.h @@ -46,10 +46,10 @@ struct MovementInfo ObjectGuid guid; Position pos; - int8 seat; - uint32 time; - uint32 time2; - uint32 vehicleId; + int8 seat = -1; + uint32 time = 0; + uint32 time2 = 0; + uint32 vehicleId = 0; } transport; // swimming/flying diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index e7b0767fd7..f98d748edc 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -718,7 +718,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recvData) data << uint32((*itr)->stationery); // stationery (Stationery.dbc) data << uint64((*itr)->money); // Gold data << uint32((*itr)->checked); // flags - data << float(float((*itr)->expire_time - GameTime::GetGameTime()) / DAY); // Time + data << float(float((*itr)->expire_time - GameTime::GetGameTime()) / float(DAY)); // Time data << uint32((*itr)->mailTemplateId); // mail template (MailTemplate.dbc) data << (*itr)->subject; // Subject string - once 00, when mail type = 3, max 256 data << (*itr)->body; // message? max 8000 diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index f536a6dd40..8e1dfecf54 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -387,7 +387,7 @@ void InstanceSaveManager::LoadResetTimes() continue; // the reset_delay must be at least one day - uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY); + uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * float(DAY)); if (period < DAY) period = DAY; @@ -444,7 +444,7 @@ time_t InstanceSaveManager::GetSubsequentResetTime(uint32 mapid, Difficulty diff } time_t diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; - time_t period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME)) / DAY) * DAY); + time_t period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME)) / float(DAY)) * float(DAY)); if (period < DAY) period = DAY; diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 42afd95d7d..9e6f17a4cd 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -270,7 +270,7 @@ bool MoveSplineInitArgs::_checkPathBounds() const for (uint32 i = 1; i < path.size()-1; ++i) { offset = path[i] - middle; - if (std::fabs(offset.x) >= MAX_OFFSET || std::fabs(offset.y) >= MAX_OFFSET || std::fabs(offset.z) >= MAX_OFFSET) + if (std::fabs(offset.x) >= float(MAX_OFFSET) || std::fabs(offset.y) >= float(MAX_OFFSET) || std::fabs(offset.z) >= float(MAX_OFFSET)) { TC_LOG_ERROR("misc", "MoveSplineInitArgs::_checkPathBounds check failed"); return false; diff --git a/src/server/game/PrecompiledHeaders/gamePCH.h b/src/server/game/PrecompiledHeaders/gamePCH.h index 76b59ecf7b..d1ce13af98 100644 --- a/src/server/game/PrecompiledHeaders/gamePCH.h +++ b/src/server/game/PrecompiledHeaders/gamePCH.h @@ -20,12 +20,10 @@ #include "Creature.h" #include "DBCStores.h" #include "DatabaseEnv.h" -#include "Errors.h" -#include "GameObject.h" #include "Log.h" -#include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" +#include "SpellMgr.h" #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" diff --git a/src/server/game/Skills/Archaeology/ArchaeologySites.cpp b/src/server/game/Skills/Archaeology/ArchaeologySites.cpp index 28a2a31427..b98fb8d01b 100644 --- a/src/server/game/Skills/Archaeology/ArchaeologySites.cpp +++ b/src/server/game/Skills/Archaeology/ArchaeologySites.cpp @@ -103,17 +103,17 @@ void Archaeology::UseSite() float ground = _player->GetMap()->GetHeight(_player->GetPhaseShift(), x, y, z + 5.0f); float angle = 0.0f; - if (dist > DIST_CLOSE) + if (dist > float(DIST_CLOSE)) { angle = std::atan2(_site[position].Y - _player->GetPositionY(), _site[position].X - _player->GetPositionX()); static float const pi = float(M_PI); - if (dist < DIST_MED) + if (dist < float(DIST_MED)) { surveyGoID = CLOSE_SURVEYBOT; // within the med radius -> green light angle += frand(-pi / 12.f, pi / 12.f); } - else if (dist < DIST_FAR) + else if (dist < float(DIST_FAR)) { surveyGoID = MED_SURVEYBOT; // within the far radius -> yellow light angle += frand(-pi / 6.f, pi / 6.f); diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 364630955f..8f052eea89 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -30,7 +30,7 @@ #include "WorldPacket.h" #include "WorldSession.h" -inline float GetAge(uint64 t) { return float(GameTime::GetGameTime() - t) / DAY; } +inline float GetAge(uint64 t) { return float(GameTime::GetGameTime() - t) / float(DAY); } /////////////////////////////////////////////////////////////////////////////////////////////////// // GM ticket diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp index d10eea337f..c2c38bbf3a 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_maleki_the_pallid.cpp @@ -90,7 +90,7 @@ public: case EVENT_FROSTBOLT: if (rand32() % 90) DoCastVictim(SPELL_FROSTBOLT); - _events.ScheduleEvent(EVENT_FROSTBOLT, 3.5 * IN_MILLISECONDS); + _events.ScheduleEvent(EVENT_FROSTBOLT, 3.5 * AsUnderlyingType(IN_MILLISECONDS)); break; case EVENT_ICETOMB: if (rand32() % 65) diff --git a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp index 1f2402e99e..eabd319716 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp @@ -144,11 +144,11 @@ class boss_baleroc : public CreatureScript BossAI::JustEngagedWith(who); Talk(EMOTE_AGGRO); instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me); - events.ScheduleEvent(EVENT_INCENDIARY_SOUL, 8.5*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_INCENDIARY_SOUL, 8.5 * AsUnderlyingType(IN_MILLISECONDS)); events.ScheduleEvent(EVENT_SHARDS_OF_TORMENT, 5 * IN_MILLISECONDS); if (me->GetMap()->IsHeroic()) events.ScheduleEvent(EVENT_COUNTDOWN, 26 * IN_MILLISECONDS); - events.ScheduleEvent(EVENT_BLADE, 30.5*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_BLADE, 30.5 * AsUnderlyingType(IN_MILLISECONDS)); events.ScheduleEvent(EVENT_BERSERK, 6 * MINUTE*IN_MILLISECONDS); //Reset our achievement list. We do this here and not in reset, as the debuff may have been spread after the boss has reset. @@ -265,7 +265,7 @@ class boss_baleroc : public CreatureScript DoCast(me->GetVictim(), SPELL_BLAZE_OF_GLORY, false); DoCast(SPELL_INCENDIARY_SOUL); } - events.ScheduleEvent(EVENT_INCENDIARY_SOUL, 11.5*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_INCENDIARY_SOUL, 11.5 * AsUnderlyingType(IN_MILLISECONDS)); break; case EVENT_SHARDS_OF_TORMENT: Talk(EMOTE_SHARDS_OF_TORMENT); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index c60544bc59..ee5bceb707 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -299,8 +299,8 @@ struct boss_twinemperorsAI : public BossAI if (me->CanCreatureAttack(who)) { float attackRadius = me->GetAttackDistance(who); - if (attackRadius < PULL_RANGE) - attackRadius = PULL_RANGE; + if (attackRadius < float(PULL_RANGE)) + attackRadius = float(PULL_RANGE); if (me->IsWithinDistInMap(who, attackRadius) && me->GetDistanceZ(who) <= /*CREATURE_Z_ATTACK_RANGE*/7 /*there are stairs*/) { //if (who->HasStealthAura()) diff --git a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp index 0a1bc77ced..d520b278db 100644 --- a/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp +++ b/src/server/scripts/Kalimdor/zone_bloodmyst_isle.cpp @@ -506,12 +506,12 @@ public: break; case PHASE_PLANT_FIRST_STAND: // plant first explosives stage 1 stand me->SetStandState(UNIT_STAND_STATE_STAND); - _moveTimer = 0.5* IN_MILLISECONDS; + _moveTimer = 0.5* AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_PLANT_FIRST_WORK; break; case PHASE_PLANT_FIRST_WORK: // plant first explosives stage 2 work Talk(SAY_LEGOSO_4); - _moveTimer = 17.5 * IN_MILLISECONDS; + _moveTimer = 17.5 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_PLANT_FIRST_FINISH; break; case PHASE_PLANT_FIRST_FINISH: // plant first explosives finish @@ -525,7 +525,7 @@ public: // force runoff movement so he will not screw up next waypoint me->GetMotionMaster()->MovePoint(WP_EXPLOSIVES_FIRST_RUNOFF, -1955.6f, -10669.8f, 110.65f, false); Talk(SAY_LEGOSO_5); - _moveTimer = 1.5 * IN_MILLISECONDS; + _moveTimer = 1.5 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_CONTINUE; break; case PHASE_PLANT_FIRST_TIMER_1: // first explosives detonate timer 1 @@ -731,7 +731,7 @@ public: SetEscortPaused(true); me->SetFacingToObject(player); Talk(SAY_LEGOSO_1); - _moveTimer = 2.5 * IN_MILLISECONDS; + _moveTimer = 2.5 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_CONTINUE; break; case WP_EXPLOSIVES_FIRST_POINT: @@ -751,7 +751,7 @@ public: break; case WP_DEBUG_1: SetEscortPaused(true); - _moveTimer = 0.5 * IN_MILLISECONDS; + _moveTimer = 0.5 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_WP_26; break; case WP_SIRONAS_HILL: @@ -778,12 +778,12 @@ public: } case WP_EXPLOSIVES_SECOND_BATTLEROAR: SetEscortPaused(true); - _moveTimer = 0.2 * IN_MILLISECONDS; + _moveTimer = 0.2 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_MEET_SIRONAS_ROAR; break; case WP_EXPLOSIVES_SECOND_PLANT: SetEscortPaused(true); - _moveTimer = 0.5 * IN_MILLISECONDS; + _moveTimer = 0.5 * AsUnderlyingType(IN_MILLISECONDS); _phase = PHASE_PLANT_SECOND_KNEEL; break; case WP_EXPLOSIVES_SECOND_DETONATE: diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 8a685f70a0..5dae961039 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -539,7 +539,7 @@ struct npc_unleashed_ballAI : public ScriptedAI void Initialize() { - RangeCheckTimer = 0.5*IN_MILLISECONDS; + RangeCheckTimer = 0.5* AsUnderlyingType(IN_MILLISECONDS); } void MoveToNextPoint() @@ -608,7 +608,7 @@ class npc_unleashed_dark : public CreatureScript me->GetMotionMaster()->MoveIdle(); me->DespawnOrUnsummon(1*IN_MILLISECONDS); } - RangeCheckTimer = 0.5*IN_MILLISECONDS; + RangeCheckTimer = 0.5* AsUnderlyingType(IN_MILLISECONDS); } else RangeCheckTimer -= diff; @@ -640,7 +640,7 @@ class npc_unleashed_light : public CreatureScript me->GetMotionMaster()->MoveIdle(); me->DespawnOrUnsummon(1*IN_MILLISECONDS); } - RangeCheckTimer = 0.5*IN_MILLISECONDS; + RangeCheckTimer = 0.5* AsUnderlyingType(IN_MILLISECONDS); } else RangeCheckTimer -= diff; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp index 7f14513521..1597297a8f 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/trial_of_the_crusader.cpp @@ -378,12 +378,12 @@ class boss_lich_king_toc : public CreatureScript case 5060: Talk(SAY_STAGE_4_05); me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL); - _updateTimer = 2.5*IN_MILLISECONDS; + _updateTimer = 2.5* AsUnderlyingType(IN_MILLISECONDS); _instance->SetData(TYPE_EVENT, 5070); break; case 5070: me->CastSpell(me, 68198, false); - _updateTimer = 1.5*IN_MILLISECONDS; + _updateTimer = 1.5* AsUnderlyingType(IN_MILLISECONDS); _instance->SetData(TYPE_EVENT, 5080); break; case 5080: diff --git a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp index ed266830c9..fe0ca0f1e3 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_maexxna.cpp @@ -214,7 +214,7 @@ public: victimGUID = guid; if (Unit* victim = ObjectAccessor::GetUnit(*me, victimGUID)) { - visibleTimer = (me->GetDistance2d(victim)/WEB_WRAP_MOVE_SPEED + 0.5f) * IN_MILLISECONDS; + visibleTimer = (me->GetDistance2d(victim)/WEB_WRAP_MOVE_SPEED + 0.5f) * AsUnderlyingType(IN_MILLISECONDS); victim->CastSpell(victim, SPELL_WEB_WRAP, me->GetGUID()); } } diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp index 7c82b054b9..03836542a8 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp @@ -356,7 +356,7 @@ public: Creature* ionar = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_IONAR)); if (ionar && ionar->IsAlive()) { - if (me->GetDistance(ionar) > DATA_MAX_SPARK_DISTANCE) + if (me->GetDistance(ionar) > float(DATA_MAX_SPARK_DISTANCE)) { Position pos = ionar->GetPosition(); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index ab5f94b396..d1d54dd6a4 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -260,7 +260,7 @@ class boss_svala : public CreatureScript { case EVENT_INTRO_SVALA_TALK_0: Talk(SAY_SVALA_INTRO_0); - events.ScheduleEvent(EVENT_INTRO_ARTHAS_TALK_0, 8.1 * IN_MILLISECONDS, 0, INTRO); + events.ScheduleEvent(EVENT_INTRO_ARTHAS_TALK_0, 8.1 * AsUnderlyingType(IN_MILLISECONDS), 0, INTRO); break; case EVENT_INTRO_ARTHAS_TALK_0: if (Creature* arthas = ObjectAccessor::GetCreature(*me, _arthasGUID)) @@ -287,12 +287,12 @@ class boss_svala : public CreatureScript (*itr)->GetMotionMaster()->MovePoint(1, spectatorWP[0]); } } - events.ScheduleEvent(EVENT_INTRO_TRANSFORM_1, 4.2 * IN_MILLISECONDS, 0, INTRO); + events.ScheduleEvent(EVENT_INTRO_TRANSFORM_1, 4.2 * AsUnderlyingType(IN_MILLISECONDS), 0, INTRO); break; } case EVENT_INTRO_TRANSFORM_1: me->CastSpell(me, SPELL_SVALA_TRANSFORMING1, false); - events.ScheduleEvent(EVENT_INTRO_TRANSFORM_2, 6.2 * IN_MILLISECONDS, 0, INTRO); + events.ScheduleEvent(EVENT_INTRO_TRANSFORM_2, 6.2 * AsUnderlyingType(IN_MILLISECONDS), 0, INTRO); break; case EVENT_INTRO_TRANSFORM_2: me->CastSpell(me, SPELL_SVALA_TRANSFORMING2, false); @@ -320,7 +320,7 @@ class boss_svala : public CreatureScript me->SetFacingTo(1.58f); if (Creature* arthas = ObjectAccessor::GetCreature(*me, _arthasGUID)) arthas->SetVisible(false); - events.ScheduleEvent(EVENT_INTRO_RELOCATE_SVALA, 13.8 * IN_MILLISECONDS, 0, INTRO); + events.ScheduleEvent(EVENT_INTRO_RELOCATE_SVALA, 13.8 * AsUnderlyingType(IN_MILLISECONDS), 0, INTRO); break; case EVENT_INTRO_RELOCATE_SVALA: { diff --git a/src/server/scripts/Northrend/zone_dalaran.cpp b/src/server/scripts/Northrend/zone_dalaran.cpp index 38555d0c9a..ca4ccc8428 100644 --- a/src/server/scripts/Northrend/zone_dalaran.cpp +++ b/src/server/scripts/Northrend/zone_dalaran.cpp @@ -214,7 +214,7 @@ class npc_minigob_manabonk : public CreatureScript Position pos = me->GetRandomNearPosition(frand(15, 40)); me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ); events.ScheduleEvent(EVENT_DESPAWN, 3 * IN_MILLISECONDS); - events.ScheduleEvent(EVENT_DESPAWN_VISUAL, 2.5*IN_MILLISECONDS); + events.ScheduleEvent(EVENT_DESPAWN_VISUAL, 2.5* AsUnderlyingType(IN_MILLISECONDS)); break; } case EVENT_DESPAWN_VISUAL: diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp index 7fdd21c84a..3d706dcce6 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp @@ -192,8 +192,8 @@ class boss_warp_splinter : public CreatureScript { float angle = (float(M_PI) / 3) * i; - float X = Treant_Spawn_Pos_X + TREANT_SPAWN_DIST * std::cos(angle); - float Y = Treant_Spawn_Pos_Y + TREANT_SPAWN_DIST * std::sin(angle); + float X = Treant_Spawn_Pos_X + float(TREANT_SPAWN_DIST) * std::cos(angle); + float Y = Treant_Spawn_Pos_Y + float(TREANT_SPAWN_DIST) * std::sin(angle); float O = - me->GetAngle(X, Y); if (Creature* pTreant = me->SummonCreature(CREATURE_TREANT, treant_pos[i][0], treant_pos[i][1], treant_pos[i][2], O, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000)) diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 9d5dbc86cd..0042f7a476 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -2573,7 +2573,7 @@ class npc_train_wrecker : public CreatureScript { me->SetFacingTo(target->GetOrientation()); me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H); - _timer = 1.5 * IN_MILLISECONDS; + _timer = 1.5 * AsUnderlyingType(IN_MILLISECONDS); _nextAction = EVENT_DO_WRECK; } else diff --git a/src/server/shared/DataStores/DB2StorageLoader.cpp b/src/server/shared/DataStores/DB2StorageLoader.cpp index 0c8f4d60c5..14d96be550 100644 --- a/src/server/shared/DataStores/DB2StorageLoader.cpp +++ b/src/server/shared/DataStores/DB2StorageLoader.cpp @@ -21,6 +21,7 @@ #include "Database/DatabaseEnv.h" #include "Errors.h" #include "Log.h" +#include DB2FileLoader::DB2FileLoader() { diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index 86a2a74688..104eaff25d 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -22,6 +22,7 @@ #include "Log.h" #include "Util.h" #include +#include #include ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(InitialBitPos), _curbitval(0), _storage(buffer.Move()) diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 938f8168f8..6d0fad82ee 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -420,7 +420,7 @@ void ShutdownCLIThread(std::thread* cliThread) { // if CancelSynchronousIo() fails, print the error and try with old way DWORD errorCode = GetLastError(); - LPSTR errorBuffer; + LPCSTR errorBuffer; DWORD formatReturnCode = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorCode, 0, (LPTSTR)&errorBuffer, 0, nullptr); @@ -430,7 +430,7 @@ void ShutdownCLIThread(std::thread* cliThread) TC_LOG_DEBUG("server.worldserver", "Error cancelling I/O of CliThread, error code %u, detail: %s", uint32(errorCode), errorBuffer); if (!formatReturnCode) - LocalFree(errorBuffer); + LocalFree((LPSTR)errorBuffer); // send keyboard input to safely unblock the CLI thread INPUT_RECORD b[4]; diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 7d45e06b8e..8e68139153 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -22,6 +22,7 @@ #include "mpqfile.h" #include "vmapexport.h" #include "Banner.h" +#include #include #ifdef _WIN32 diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp index bc0ec616f9..75c59d8a08 100644 --- a/src/tools/vmap4_extractor/wmo.cpp +++ b/src/tools/vmap4_extractor/wmo.cpp @@ -22,6 +22,7 @@ #include "vec3d.h" #include "VMapDefinitions.h" #include "wmo.h" +#include #include #include #include