Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge TheCataclysmPreservationProject to ElunaCataPreservation [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Niam5 committed Dec 14, 2023
2 parents a82a2d2 + 45f0c79 commit 8694278
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 38 deletions.
6 changes: 5 additions & 1 deletion cmake/platform/win/settings.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
add_definitions(-D_WIN32_WINNT=0x0601)
add_definitions(-D_WIN32_WINNT=0x0A00) # Windows 10
add_definitions(-DNTDDI_VERSION=0x0A000007) # 19H1 (1903)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)
add_definitions(-DTRINITY_REQUIRED_WINDOWS_BUILD=18362)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if(WIN32)
set(sources_windows
${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.cpp
${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.h
${CMAKE_SOURCE_DIR}/src/common/WindowsSettings.manifest
)
endif(WIN32)

Expand Down
14 changes: 14 additions & 0 deletions src/common/Debugging/Errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ void Abort(char const* file, int line, char const* function)
Crash(formattedMessage.c_str());
}

void Abort(char const* file, int line, char const* function, char const* message, ...)
{
va_list args;
va_start(args, message);

std::string formattedMessage = StringFormat("\n%s:%i in %s ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n';
va_end(args);

fprintf(stderr, "%s", formattedMessage.c_str());
fflush(stderr);

Crash(formattedMessage.c_str());
}

void AbortHandler(int sigval)
{
// nothing useful to log here, no way to pass args
Expand Down
3 changes: 3 additions & 0 deletions src/common/Debugging/Errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace Trinity
DECLSPEC_NORETURN TC_COMMON_API void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;

DECLSPEC_NORETURN TC_COMMON_API void Abort(char const* file, int line, char const* function) ATTR_NORETURN;
DECLSPEC_NORETURN TC_COMMON_API void Abort(char const* file, int line, char const* function, char const* message, ...) ATTR_NORETURN;

TC_COMMON_API void Warning(char const* file, int line, char const* function, char const* message);

Expand All @@ -54,6 +55,7 @@ namespace Trinity
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END

#ifdef PERFORMANCE_PROFILING
#define ASSERT(cond, ...) ((void)0)
Expand All @@ -62,6 +64,7 @@ namespace Trinity
#endif

#define ABORT WPAbort
#define ABORT_MSG WPAbort_MSG

template <typename T> inline T* ASSERT_NOTNULL(T* pointer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/Debugging/WheatyExceptionReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
RTL_OSVERSIONINFOEXW osvi = { };
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi);
if (bVersionEx < 0)
if (FAILED(bVersionEx))
{
osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi))
Expand Down
24 changes: 20 additions & 4 deletions src/common/Utilities/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,27 @@
#include <cstdarg>
#include <ctime>

#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void Trinity::VerifyOsVersion()
{
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
auto isWindowsBuildGreaterOrEqual = [](DWORD build)
{
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, build, 0, {0}, 0, 0, 0, 0 };
ULONGLONG conditionMask = 0;
VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);

return VerifyVersionInfo(&osvi, VER_BUILDNUMBER, conditionMask);
};

if (!isWindowsBuildGreaterOrEqual(TRINITY_REQUIRED_WINDOWS_BUILD))
{
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, 0 };
GetVersionEx((LPOSVERSIONINFO)&osvi);
ABORT_MSG("TrinityCore requires Windows 10 19H1 (1903) or Windows Server 2019 (1903) - require build number 10.0.%d but found %d.%d.%d",
TRINITY_REQUIRED_WINDOWS_BUILD, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
}
#endif
}

Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve /*= 0*/, bool keepEmptyStrings /*= true*/)
{
Expand Down
5 changes: 5 additions & 0 deletions src/common/Utilities/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <sstream>
#include <vector>

namespace Trinity
{
TC_COMMON_API void VerifyOsVersion();
}

class TC_COMMON_API Tokenizer
{
public:
Expand Down
13 changes: 13 additions & 0 deletions src/common/WindowsSettings.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <!-- Windows 10 -->
</application>
</compatibility>
</assembly>
2 changes: 2 additions & 0 deletions src/server/bnetserver/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ int main(int argc, char** argv)
{
signal(SIGABRT, &Trinity::AbortHandler);

Trinity::VerifyOsVersion();

auto configFile = fs::absolute(_TRINITY_BNET_CONFIG);
std::string configService;
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
Expand Down
26 changes: 8 additions & 18 deletions src/server/game/Grids/Cells/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#ifndef TRINITY_CELL_H
#define TRINITY_CELL_H

#include <cmath>

#include "TypeContainer.h"
#include "TypeContainerVisitor.h"

Expand Down Expand Up @@ -47,10 +45,9 @@ struct CellArea

struct Cell
{
Cell() { data.All = 0; }
Cell(Cell const& cell) { data.All = cell.data.All; }
Cell() : data() { }
explicit Cell(CellCoord const& p);
explicit Cell(float x, float y);
explicit Cell(float x, float y) : Cell(Trinity::ComputeCellCoord(x, y)) { }

void Compute(uint32 &x, uint32 &y) const
{
Expand Down Expand Up @@ -84,26 +81,19 @@ struct Cell
data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y);
}

Cell& operator=(Cell const& cell)
{
this->data.All = cell.data.All;
return *this;
}

bool operator == (Cell const& cell) const { return (data.All == cell.data.All); }
bool operator != (Cell const& cell) const { return !operator == (cell); }
union
{
struct
{
unsigned grid_x : 6;
unsigned grid_y : 6;
unsigned cell_x : 6;
unsigned cell_y : 6;
unsigned nocreate : 1;
unsigned reserved : 7;
uint8 grid_x;
uint8 grid_y;
uint8 cell_x;
uint8 cell_y;
uint8 nocreate;
} Part;
uint32 All;
uint64 All;
} data;

template<class T, class CONTAINER> void Visit(CellCoord const&, TypeContainerVisitor<T, CONTAINER>& visitor, Map&, WorldObject const& obj, float radius) const;
Expand Down
15 changes: 1 addition & 14 deletions src/server/game/Grids/Cells/CellImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,12 @@
#include "Map.h"
#include "Object.h"

inline Cell::Cell(CellCoord const& p)
inline Cell::Cell(CellCoord const& p) : data()
{
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
data.Part.nocreate = 0;
data.Part.reserved = 0;
}

inline Cell::Cell(float x, float y)
{
CellCoord p = Trinity::ComputeCellCoord(x, y);
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
data.Part.nocreate = 0;
data.Part.reserved = 0;
}

inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
Expand Down
2 changes: 2 additions & 0 deletions src/server/worldserver/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ extern int main(int argc, char** argv)
{
signal(SIGABRT, &Trinity::AbortHandler);

Trinity::VerifyOsVersion();

auto configFile = fs::absolute(_TRINITY_CORE_CONFIG);
std::string configService;

Expand Down
3 changes: 3 additions & 0 deletions src/tools/map_extractor/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "StringFormat.h"
#include "Util.h"
#include "MapDefines.h"
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
Expand Down Expand Up @@ -1373,6 +1374,8 @@ void LoadCommonMPQFiles(uint32 build)

int main(int argc, char * arg[])
{
Trinity::VerifyOsVersion();

Trinity::Banner::Show("Map & DBC Extractor", [](char const* text) { printf("%s\n", text); }, nullptr);

PrintProgress = isatty(fileno(stdout));
Expand Down
2 changes: 2 additions & 0 deletions src/tools/mmaps_generator/PathGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ std::unordered_map<uint32, std::vector<uint32>> LoadMap(std::string const& local

int main(int argc, char** argv)
{
Trinity::VerifyOsVersion();

Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr);

unsigned int threads = std::thread::hardware_concurrency();
Expand Down
3 changes: 3 additions & 0 deletions src/tools/vmap4_assembler/VMapAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@

#include "TileAssembler.h"
#include "Banner.h"
#include "Util.h"

int main(int argc, char* argv[])
{
Trinity::VerifyOsVersion();

Trinity::Banner::Show("VMAP assembler", [](char const* text) { std::cout << text << std::endl; }, nullptr);

std::string src = "Buildings";
Expand Down
3 changes: 3 additions & 0 deletions src/tools/vmap4_extractor/vmapexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mpqfile.h"
#include "wmo.h"
#include "StringFormat.h"
#include "Util.h"
#include "vmapexport.h"
#include "VMapDefinitions.h"
#include "Banner.h"
Expand Down Expand Up @@ -476,6 +477,8 @@ bool processArgv(int argc, char ** argv, const char *versionString)

int main(int argc, char ** argv)
{
Trinity::VerifyOsVersion();

Trinity::Banner::Show("VMAP data extractor", [](char const* text) { printf("%s\n", text); }, nullptr);

input_path = boost::filesystem::current_path();
Expand Down

0 comments on commit 8694278

Please sign in to comment.