Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: supress warnings on external library headers and actually get rid of the last old-style casts #1502

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.25)
project(Darkflame)
include(CTest)

Expand Down Expand Up @@ -213,29 +213,29 @@ if (APPLE)
endif()

# Load all of our third party directories
add_subdirectory(thirdparty)
add_subdirectory(thirdparty SYSTEM)

jadebenn marked this conversation as resolved.
Show resolved Hide resolved
# Create our list of include directories
set(INCLUDED_DIRECTORIES
include_directories(
"dPhysics"

"dNavigation"

"dNet"

"thirdparty/magic_enum/include/magic_enum"
"thirdparty/raknet/Source"
"thirdparty/tinyxml2"
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
"thirdparty/cpp-httplib"
"thirdparty/MD5"

"tests"
"tests/dCommonTests"
"tests/dGameTests"
"tests/dGameTests/dComponentsTests"

SYSTEM "thirdparty/magic_enum/include/magic_enum"
SYSTEM "thirdparty/raknet/Source"
SYSTEM "thirdparty/tinyxml2"
SYSTEM "thirdparty/recastnavigation"
SYSTEM "thirdparty/SQLite"
SYSTEM "thirdparty/cpplinq"
SYSTEM "thirdparty/cpp-httplib"
SYSTEM "thirdparty/MD5"
)

# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux)
Expand All @@ -244,14 +244,9 @@ if(APPLE)
include_directories("/usr/local/include/")
endif()

# Actually include the directories from our list
foreach(dir ${INCLUDED_DIRECTORIES})
include_directories(${PROJECT_SOURCE_DIR}/${dir})
endforeach()

# Add linking directories:
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Werror") # Warning flags
endif()
file(
GLOB HEADERS_DZONEMANAGER
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ git clone --recursive https://github.com/DarkflameUniverse/DarkflameServer

### Windows packages
Ensure that you have either the [MSVC C++ compiler](https://visualstudio.microsoft.com/vs/features/cplusplus/) (recommended) or the [Clang compiler](https://github.com/llvm/llvm-project/releases/) installed.
You'll also need to download and install [CMake](https://cmake.org/download/) (version <font size="4">**CMake version 3.18**</font> or later!).
You'll also need to download and install [CMake](https://cmake.org/download/) (version <font size="4">**CMake version 3.25**</font> or later!).

### MacOS packages
Ensure you have [brew](https://brew.sh) installed.
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindMariaDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ elseif(APPLE)
endif()

# Add directories to include lists
target_include_directories(MariaDB::ConnCpp INTERFACE ${MARIADB_INCLUDE_DIR})
target_include_directories(MariaDB::ConnCpp SYSTEM INTERFACE ${MARIADB_INCLUDE_DIR})

set(MariaDB_FOUND TRUE)
2 changes: 1 addition & 1 deletion dMasterServer/MasterServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void HandlePacket(Packet* packet) {

const auto& zone = instance->GetZoneID();

MasterPackets::SendZoneTransferResponse(Game::server, packet->systemAddress, requestID, (bool)mythranShift, zone.GetMapID(), instance->GetInstanceID(), zone.GetCloneID(), instance->GetIP(), instance->GetPort());
MasterPackets::SendZoneTransferResponse(Game::server, packet->systemAddress, requestID, static_cast<bool>(mythranShift), zone.GetMapID(), instance->GetInstanceID(), zone.GetCloneID(), instance->GetIP(), instance->GetPort());

break;
}
Expand Down
16 changes: 8 additions & 8 deletions dPhysics/dpGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dpGrid::~dpGrid() {

void dpGrid::Add(dpEntity* entity) {
//Determine which grid cell it's in.
int cellX = (int)std::round(entity->m_Position.x) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellZ = (int)std::round(entity->m_Position.z) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellX = static_cast<int>(std::round(entity->m_Position.x)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellZ = static_cast<int>(std::round(entity->m_Position.z)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;

// Clamp values to the range [0, NUM_CELLS - 1]
cellX = std::clamp(cellX, 0, NUM_CELLS - 1);
Expand All @@ -42,11 +42,11 @@ void dpGrid::Add(dpEntity* entity) {
}

void dpGrid::Move(dpEntity* entity, float x, float z) {
int oldCellX = (int)std::round(entity->m_Position.x) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellZ = (int)std::round(entity->m_Position.z) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellX = static_cast<int>(std::round(entity->m_Position.x)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellZ = static_cast<int>(std::round(entity->m_Position.z)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;

int cellX = (int)std::round(x) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellZ = (int)std::round(z) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellX = static_cast<int>(std::round(x)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int cellZ = static_cast<int>(std::round(z)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;

// Clamp values to the range [0, NUM_CELLS - 1]
cellX = std::clamp(cellX, 0, NUM_CELLS - 1);
Expand All @@ -73,8 +73,8 @@ void dpGrid::Move(dpEntity* entity, float x, float z) {

void dpGrid::Delete(dpEntity* entity) {
if (!entity) return;
int oldCellX = (int)std::round(entity->m_Position.x) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellZ = (int)std::round(entity->m_Position.z) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellX = static_cast<int>(std::round(entity->m_Position.x)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;
int oldCellZ = static_cast<int>(std::round(entity->m_Position.z)) / dpGrid::CELL_SIZE + NUM_CELLS / 2;

// Clamp values to the range [0, NUM_CELLS - 1]
oldCellX = std::clamp(oldCellX, 0, NUM_CELLS - 1);
Expand Down
10 changes: 5 additions & 5 deletions dWorldServer/WorldServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int main(int argc, char** argv) {

// Update to the new framerate and scale all timings to said new framerate
if (newFrameDelta != currentFrameDelta) {
float_t ratioBeforeToAfter = (float)currentFrameDelta / (float)newFrameDelta;
float_t ratioBeforeToAfter = static_cast<float>(currentFrameDelta) / static_cast<float>(newFrameDelta);
currentFrameDelta = newFrameDelta;
currentFramerate = MS_TO_FRAMES(newFrameDelta);
LOG_DEBUG("Framerate for zone/instance/clone %i/%i/%i is now %i", zoneID, instanceID, cloneID, currentFramerate);
Expand Down Expand Up @@ -728,8 +728,8 @@ void HandleMasterPacket(Packet* packet) {
{
CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_ADDED);
bitStream.Write((LWOMAPID)Game::server->GetZoneID());
bitStream.Write((LWOINSTANCEID)instanceID);
bitStream.Write<LWOMAPID>(Game::server->GetZoneID());
bitStream.Write<LWOINSTANCEID>(instanceID);
Game::server->SendToMaster(bitStream);
}
}
Expand Down Expand Up @@ -830,8 +830,8 @@ void HandlePacket(Packet* packet) {

CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_REMOVED);
bitStream.Write((LWOMAPID)Game::server->GetZoneID());
bitStream.Write((LWOINSTANCEID)instanceID);
bitStream.Write<LWOMAPID>(Game::server->GetZoneID());
bitStream.Write<LWOINSTANCEID>(instanceID);
Game::server->SendToMaster(bitStream);
}

Expand Down
38 changes: 19 additions & 19 deletions tests/dCommonTests/TestLDFFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST_F(LDFTests, LDFUTF16Test) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::u16string>*)data.get())->GetValue(), u"IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; ");
ASSERT_EQ((static_cast<LDFData<std::u16string>*>(data.get()))->GetValue(), u"IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; ");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -37,7 +37,7 @@ TEST_F(LDFTests, LDFUTF16EmptyTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::u16string>*)data.get())->GetValue(), u"");
ASSERT_EQ(static_cast<LDFData<std::u16string>*>(data.get())->GetValue(), u"");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -47,7 +47,7 @@ TEST_F(LDFTests, LDFUTF16ColonTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::u16string>*)data.get())->GetValue(), u"::");
ASSERT_EQ(static_cast<LDFData<std::u16string>*>(data.get())->GetValue(), u"::");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -57,7 +57,7 @@ TEST_F(LDFTests, LDFUTF16EqualsTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::u16string>*)data.get())->GetValue(), u"==");
ASSERT_EQ(static_cast<LDFData<std::u16string>*>(data.get())->GetValue(), u"==");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -66,15 +66,15 @@ TEST_F(LDFTests, LDFS32Test) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_S32);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<int32_t>*)data.get())->GetValue(), -15);
ASSERT_EQ(static_cast<LDFData<int32_t>*>(data.get())->GetValue(), -15);
ASSERT_EQ(data->GetString(), "KEY=1:-15");
}
TEST_F(LDFTests, LDFU32Test) {
LdfUniquePtr data(LDFBaseData::DataFromString("KEY=5:15"));
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<uint32_t>*)data.get())->GetValue(), 15);
ASSERT_EQ(static_cast<LDFData<uint32_t>*>(data.get())->GetValue(), 15);
ASSERT_EQ(data->GetString(), "KEY=5:15");
}

Expand All @@ -83,7 +83,7 @@ TEST_F(LDFTests, LDFU32TrueTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<uint32_t>*)data.get())->GetValue(), 1);
ASSERT_EQ(static_cast<LDFData<uint32_t>*>(data.get())->GetValue(), 1);
ASSERT_EQ(data->GetString(), "KEY=5:1");
}

Expand All @@ -92,7 +92,7 @@ TEST_F(LDFTests, LDFU32FalseTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<uint32_t>*)data.get())->GetValue(), 0);
ASSERT_EQ(static_cast<LDFData<uint32_t>*>(data.get())->GetValue(), 0);
ASSERT_EQ(data->GetString(), "KEY=5:0");
}

Expand All @@ -103,7 +103,7 @@ TEST_F(LDFTests, LDFFloatTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_FLOAT);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<float>*)data.get())->GetValue(), 15.5f);
ASSERT_EQ(static_cast<LDFData<float>*>(data.get())->GetValue(), 15.5f);
ASSERT_EQ(data->GetString().find("KEY=3:15.5"), 0);
}

Expand All @@ -112,7 +112,7 @@ TEST_F(LDFTests, LDFDoubleTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_DOUBLE);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<double>*)data.get())->GetValue(), 15.5);
ASSERT_EQ(static_cast<LDFData<double>*>(data.get())->GetValue(), 15.5);
ASSERT_EQ(data->GetString().find("KEY=4:15.5"), 0);
}

Expand All @@ -122,7 +122,7 @@ TEST_F(LDFTests, LDFBoolTrueTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<bool>*)data.get())->GetValue(), true);
ASSERT_EQ(static_cast<LDFData<bool>*>(data.get())->GetValue(), true);
ASSERT_EQ(data->GetString(), "KEY=7:1");
}

Expand All @@ -131,7 +131,7 @@ TEST_F(LDFTests, LDFBoolFalseTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<bool>*)data.get())->GetValue(), false);
ASSERT_EQ(static_cast<LDFData<bool>*>(data.get())->GetValue(), false);
ASSERT_EQ(data->GetString(), "KEY=7:0");
}

Expand All @@ -140,7 +140,7 @@ TEST_F(LDFTests, LDFBoolIntTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<bool>*)data.get())->GetValue(), true);
ASSERT_EQ(static_cast<LDFData<bool>*>(data.get())->GetValue(), true);
ASSERT_EQ(data->GetString(), "KEY=7:1");
}

Expand All @@ -149,7 +149,7 @@ TEST_F(LDFTests, LDFU64Test) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U64);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<uint64_t>*)data.get())->GetValue(), 15);
ASSERT_EQ(static_cast<LDFData<uint64_t>*>(data.get())->GetValue(), 15);
ASSERT_EQ(data->GetString(), "KEY=8:15");
}

Expand All @@ -158,7 +158,7 @@ TEST_F(LDFTests, LDFLWOOBJIDTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_OBJID);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<uint64_t>*)data.get())->GetValue(), 15);
ASSERT_EQ(static_cast<LDFData<uint64_t>*>(data.get())->GetValue(), 15);
ASSERT_EQ(data->GetString(), "KEY=9:15");
}

Expand All @@ -168,7 +168,7 @@ TEST_F(LDFTests, LDFUTF8Test) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::string>*)data.get())->GetValue(), "IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; ");
ASSERT_EQ(static_cast<LDFData<std::string>*>(data.get())->GetValue(), "IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; ");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -178,7 +178,7 @@ TEST_F(LDFTests, LDFUTF8EmptyTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::string>*)data.get())->GetValue(), "");
ASSERT_EQ(static_cast<LDFData<std::string>*>(data.get())->GetValue(), "");
ASSERT_EQ(data->GetString(), testWord);
}

Expand All @@ -188,7 +188,7 @@ TEST_F(LDFTests, LDFUTF8ColonsTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::string>*)data.get())->GetValue(), "::");
ASSERT_EQ(static_cast<LDFData<std::string>*>(data.get())->GetValue(), "::");
ASSERT_EQ(data->GetString(), testWord);
}
TEST_F(LDFTests, LDFUTF8EqualsTest) {
Expand All @@ -197,7 +197,7 @@ TEST_F(LDFTests, LDFUTF8EqualsTest) {
ASSERT_NE(data, nullptr);
ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8);
ASSERT_EQ(data->GetKey(), u"KEY");
ASSERT_EQ(((LDFData<std::string>*)data.get())->GetValue(), "==");
ASSERT_EQ(static_cast<LDFData<std::string>*>(data.get())->GetValue(), "==");
ASSERT_EQ(data->GetString(), testWord);
}

Expand Down
Loading
Loading