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

This PR exists for CI reasons. Do not delete until the workflow has completed. #1343

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
[submodule "thirdparty/AccountManager"]
path = thirdparty/AccountManager
url = https://github.com/DarkflameUniverse/AccountManager
[submodule "thirdparty/magic_enum"]
path = thirdparty/magic_enum
url = https://github.com/Neargye/magic_enum.git
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ set(INCLUDED_DIRECTORIES
"thirdparty/recastnavigation"
"thirdparty/SQLite"
"thirdparty/cpplinq"
"thirdparty/magic_enum/include"

"tests"
"tests/dCommonTests"
Expand Down
8 changes: 8 additions & 0 deletions dCommon/dEnums/eGameMessageType.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <cstdint>

#include "magic_enum/magic_enum.hpp"

enum class eGameMessageType : uint16_t {
GET_POSITION = 0,
GET_ROTATION = 1,
Expand Down Expand Up @@ -1602,4 +1604,10 @@ enum class eGameMessageType : uint16_t {
GET_IS_ON_RAIL = 1772
};

template <>
struct magic_enum::customize::enum_range<eGameMessageType> {
static constexpr int min = 0;
static constexpr int max = 1772;
};

#endif //!__EGAMEMESSAGETYPE__H__
12 changes: 5 additions & 7 deletions dGame/dGameMessages/GameMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
#include "ePlayerFlag.h"
#include "dConfig.h"

using namespace std;

void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) {

CBITSTREAM;
Expand All @@ -49,11 +47,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
User* usr = UserManager::Instance()->GetUser(sysAddr);

if (!entity) {
LOG("Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID);
LOG("Failed to find associated entity (%llu), aborting GM (%4i) %s!", objectID, messageID, magic_enum::enum_name(messageID).data());
return;
}

if (messageID != eGameMessageType::READY_FOR_UPDATES) LOG_DEBUG("received game message ID: %i", messageID);
if (messageID != eGameMessageType::READY_FOR_UPDATES) LOG_DEBUG("Received GM with ID and name: %4i, %s", messageID, magic_enum::enum_name(messageID).data());

switch (messageID) {

Expand Down Expand Up @@ -344,12 +342,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System

SyncSkill sync = SyncSkill(inStream); // inStream replaced &bitStream

ostringstream buffer;
std::ostringstream buffer;

for (unsigned int k = 0; k < sync.sBitStream.size(); k++) {
char s;
s = sync.sBitStream.at(k);
buffer << setw(2) << hex << setfill('0') << (int)s << " ";
buffer << std::setw(2) << std::hex << std::setfill('0') << (int)s << " ";
}

if (usr != nullptr) {
Expand Down Expand Up @@ -691,7 +689,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
GameMessages::HandleCancelDonationOnPlayer(inStream, entity);
break;
default:
LOG_DEBUG("Unknown game message ID: %i", messageID);
LOG_DEBUG("Received Unknown GM with ID: %4i, %s", messageID, magic_enum::enum_name(messageID).data());
break;
}
}
6 changes: 5 additions & 1 deletion dWorldServer/WorldServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,11 @@ void HandlePacket(Packet* packet) {
}

default:
LOG("Unknown world packet received: %i", int(packet->data[3]));
if (packet->bitSize < (16 + sizeof(uint32_t) * 8)) break;

uint32_t messageId = *reinterpret_cast<uint32_t*>(&packet->data[3]);
const char* messageIdString = magic_enum::enum_name(static_cast<eWorldMessageType>(messageId)).data();
LOG("Unknown world packet received: (%4i) %s", messageId, messageIdString);
}
}

Expand Down
1 change: 1 addition & 0 deletions thirdparty/magic_enum
Submodule magic_enum added at e26b05
Loading