Build: enable C++20 and updated all compiler requirements

* ported some header and cmake updates from master branch
This commit is contained in:
Ovahlord committed 2023-07-04 23:49:57 +02:00
1 parent 185c80dd96
commit f34534465a
67 files changed
+792 -134

No files matched your search

+18
View File
@@ -3,6 +3,14 @@ target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="$<CONFIG>")
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()
+3 -1
View File
@@ -3,10 +3,12 @@ target_compile_definitions(trinity-compile-option-interface
INTERFACE
-D_BUILD_DIRECTIVE="$<CONFIG>")
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)
+17 -10
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)
-1
View File
@@ -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
+20
View File
@@ -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<T>& other) {
+ static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "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<T>& other) {
+ static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "appendPOD called on non-POD type");
const size_t oldSize = num;
num += other.num;
if (numAllocated < num) {
+13
View File
@@ -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);
+192
View File
@@ -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 <string>
+#if defined(__aarch64__)
+#include <sys/time.h>
+#endif
+
#ifdef G3D_OSX
#define Zone OSX_Zone
# include <CoreServices/CoreServices.h>
@@ -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<uint64>(pmccntr) * 64; // Should optimize to << 6
+ }
+ }
+# endif
- __asm__ __volatile__ (
- "rdtsc "
- : "=a" (timelo),
- "=d" (timehi)
- : );
+ struct timeval tv;
+ gettimeofday(&tv, nullptr);
+ return static_cast<uint64>(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 <xmmintrin.h>
-
+#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
+24 -11
View File
@@ -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 <ctype.h>
#include <float.h>
+#include <algorithm>
#include <limits>
#include <stdlib.h>
#include <stdint.h>
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 {
+12
View File
@@ -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;
+288
View File
@@ -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 T, size_t MIN_ELEMENTS> class Array;
+class Plane;
+class Sphere;
/**
An axis-aligned box.
@@ -221,7 +221,7 @@ public:
*/
bool culledBy
- (const Array<Plane>& plane,
+ (const Array<Plane, 10>& 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>& plane,
+ (const Array<Plane, 10>& 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 <Windows.h>
+#elif defined(G3D_OSX)
# include <libkern/OSAtomic.h>
#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 <typeinfo>
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 <string>
+#ifdef G3D_WINDOWS
+#include <Windows.h>
+#endif
+
#if defined(__aarch64__)
#include <sys/time.h>
#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 <string>
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 <cstdlib>
#ifdef _MSC_VER
+#include <intrin.h>
// 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 <cstdlib>
#ifdef _MSC_VER
+#include <Windows.h>
// disable: "C++ exception handler used"
# pragma warning (push)
# pragma warning (disable : 4530)
+14
View File
@@ -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 <fnmatch.h>
# include <unistd.h>
# 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
+13
View File
@@ -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 <fnmatch.h>
# include <unistd.h>
# 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
+8
View File
@@ -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
+2 -2
View File
@@ -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<T>& other) {
static_assert(std::is_pod<T>::value, "copyPOD called on non-POD type");
static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "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<T>& other) {
static_assert(std::is_pod<T>::value, "appendPOD called on non-POD type");
static_assert(std::is_standard_layout_v<T> && std::is_trivial_v<T>, "appendPOD called on non-POD type");
const size_t oldSize = num;
num += other.num;
if (numAllocated < num) {
+35 -23
View File
@@ -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
}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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};
+33 -7
View File
@@ -21,6 +21,10 @@
#include "G3D/FileNotFound.h"
#include <string>
#if defined(__aarch64__)
#include <sys/time.h>
#endif
#ifdef G3D_OSX
#define Zone OSX_Zone
# include <CoreServices/CoreServices.h>
@@ -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<uint64>(pmccntr) * 64; // Should optimize to << 6
}
}
# endif
__asm__ __volatile__ (
"rdtsc "
: "=a" (timelo),
"=d" (timehi)
: );
struct timeval tv;
gettimeofday(&tv, nullptr);
return static_cast<uint64>(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)
+1
View File
@@ -27,6 +27,7 @@
#include "G3D/platform.h"
#include <ctype.h>
#include <float.h>
#include <algorithm>
#include <limits>
#include <stdlib.h>
#include <stdint.h>
+1 -1
View File
@@ -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
+3
View File
@@ -35,6 +35,9 @@
# include <fnmatch.h>
# include <unistd.h>
# 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
+12 -1
View File
@@ -79,8 +79,9 @@
#endif
// SIMM include
#if !defined(__aarch64__)
#include <xmmintrin.h>
#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
+1 -1
View File
@@ -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 {
+2
View File
@@ -18,6 +18,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits>
#include <cstring>
#include "DBCFileLoader.h"
#include "Errors.h"
+2
View File
@@ -35,10 +35,12 @@
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include <Windows.h>
#include <intrin.h>
#define Crash(message) \
ULONG_PTR execeptionArgs[] = { reinterpret_cast<ULONG_PTR>(strdup(message)), reinterpret_cast<ULONG_PTR>(_ReturnAddress()) }; \
RaiseException(EXCEPTION_ASSERTION_FAILURE, 0, 2, execeptionArgs);
#else
#include <cstring>
// should be easily accessible in gdb
extern "C" { TC_COMMON_API char const* TrinityAssertionFailedMessage = nullptr; }
#define Crash(message) \
@@ -14,7 +14,7 @@
#pragma warning(disable:4311)
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <cstdio>
#include <tchar.h>
#define _NO_CVCONST_H
#include <dbghelp.h>
@@ -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)
{
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -29,7 +29,7 @@
#include "VMapDefinitions.h"
#include "WorldModel.h"
#include <G3D/Ray.h>
#include <G3D/Vector3.h>
#include <G3D/Vector4.h>
#include <algorithm>
#include <cstring>
#include <memory>
+1
View File
@@ -21,6 +21,7 @@
#ifdef _WIN32 // Windows
#include <Windows.h>
#elif defined(__linux__)
#include <cstring>
#include <sched.h>
#include <sys/resource.h>
#define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0
+2
View File
@@ -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
+1
View File
@@ -18,6 +18,7 @@
#include "Field.h"
#include "Log.h"
#include "MySQLHacks.h"
#include <cstring>
Field::Field()
{
@@ -20,6 +20,7 @@
#include "Log.h"
#include "MySQLHacks.h"
#include "PreparedStatement.h"
#include <cstring>
#include <sstream>
MySQLPreparedStatement::MySQLPreparedStatement(MySQLStmt* stmt, std::string queryString) :
@@ -20,7 +20,6 @@
#include "DatabaseEnvFwd.h"
#include "Define.h"
#include "MySQLWorkaround.h"
#include <string>
#include <vector>
@@ -15,7 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <winsock2.h>
#endif
#include <mysql.h>
#endif // MySQLWorkaround_h__
@@ -21,6 +21,7 @@
#include "Log.h"
#include "MySQLHacks.h"
#include "MySQLWorkaround.h"
#include <cstring>
namespace
{
@@ -23,6 +23,7 @@
#include <mysqld_error.h>
#include <sstream>
#include <thread>
#include <cstring>
std::mutex TransactionTask::_deadlockLock;
@@ -15,18 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <winsock2.h>
#endif
#include <mysql.h>
#include <string>
#include <vector>
#include "MySQLHacks.h"
@@ -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;
}
@@ -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();
+1 -1
View File
@@ -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;
+1
View File
@@ -23,6 +23,7 @@
#include "M2Stores.h"
#include "World.h"
#include <boost/filesystem/path.hpp>
#include <G3D/Vector4.h>
#include <fstream>
#include <iostream>
#include <iomanip>
@@ -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
+1 -1
View File
@@ -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
@@ -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;
@@ -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;
+1 -3
View File
@@ -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"
@@ -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);
+1 -1
View File
@@ -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
@@ -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)
@@ -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);
@@ -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())
@@ -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:
@@ -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;
@@ -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:
@@ -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());
}
}
@@ -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();
@@ -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:
{
@@ -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:
@@ -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))
+1 -1
View File
@@ -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
@@ -21,6 +21,7 @@
#include "Database/DatabaseEnv.h"
#include "Errors.h"
#include "Log.h"
#include <cstring>
DB2FileLoader::DB2FileLoader()
{
+1
View File
@@ -22,6 +22,7 @@
#include "Log.h"
#include "Util.h"
#include <sstream>
#include <cmath>
#include <ctime>
ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(InitialBitPos), _curbitval(0), _storage(buffer.Move())
+2 -2
View File
@@ -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];
+1
View File
@@ -22,6 +22,7 @@
#include "mpqfile.h"
#include "vmapexport.h"
#include "Banner.h"
#include <algorithm>
#include <sys/stat.h>
#ifdef _WIN32
+1
View File
@@ -22,6 +22,7 @@
#include "vec3d.h"
#include "VMapDefinitions.h"
#include "wmo.h"
#include <algorithm>
#include <fstream>
#include <map>
#include <cstdio>