mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-20 19:52:48 +00:00
refactor: world packets as structs
WorldPackets now holds what a client sends a world server, one struct per packet with Serialize/Deserialize: Validation, CharacterListRequest, CharacterCreateRequest, CharacterLoginRequest, GameMessage, CharacterDeleteRequest, CharacterRenameRequest, LevelLoadComplete, PositionUpdate, MailPacket, RoutePacket, StringCheck, GeneralChatMessage, HandleFunness, UIHelpTop5. WorldServer's switch became a dispatch map of handlers (each overrides Handle in WorldServer.cpp, logic unchanged: dashboard hooks, LoadPlayer, chat logging, migration checks, message inspector capture all still run); a packet that does not deserialize is logged and dropped. UserManager's create/delete/rename take the structs. The answers are ClientPackets (the CLIENT service): LoadStaticZone, CharacterListResponse, CharacterCreateResponse, CharacterRenameResponse, DeleteCharacterResponse, TransferToWorld, ServerStates, CreateCharacter, ChatModerationString, MakeGMResponse, HTTPMonitorInfoResponse and DebugOutput, built at the call sites (world server, UserManager, slash commands, dashboard actions, components, migration). The world -> chat forward of a routed packet is ChatPackets::RoutedFromClient. All WorldPackets::Send* functions, HTTPMonitorInfo and the ClientPackets parse functions are gone. The architecture doc now states the file rule: a packet lives in the file of the ServiceType in its header. No wire change. Verified against frozen verbatim copies of the old code (tests/dGameTests/dNetTests/Legacy/WorldPacketsLegacy.h): every response is sent through the old function and the struct over grids of inputs (all enum values, strings of every length class, IDs, >64 moderation segments, big XML) and must match byte for byte; every request is read by the old code and the struct and must give the same values; plus golden bytes, round trips, truncation checks and a field width mutation that made the tests fail. Only differences: malformed requests are dropped instead of handled with partial values, and LevelLoadComplete now reads the zone ID the client sends after it (lu_packets and captures show the 1.10.64 client always sends it; DLU ignored it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include "PlayerManager.h"
|
||||
#include "User.h"
|
||||
#include "UserManager.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "ClientPackets.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
@@ -58,7 +58,12 @@ namespace {
|
||||
auto* entity = PlayerManager::GetPlayer(user->GetSystemAddress());
|
||||
if (!entity || entity->GetGMLevel() <= info->maxGmLevel) continue;
|
||||
|
||||
WorldPackets::SendGMLevelChange(entity->GetSystemAddress(), true, info->maxGmLevel, entity->GetGMLevel(), info->maxGmLevel);
|
||||
ClientPackets::MakeGMResponse response;
|
||||
response.success = true;
|
||||
response.highestLevel = info->maxGmLevel;
|
||||
response.previousLevel = entity->GetGMLevel();
|
||||
response.newLevel = info->maxGmLevel;
|
||||
response.Send(entity->GetSystemAddress());
|
||||
GameMessages::SendChatModeUpdate(entity->GetObjectID(), info->maxGmLevel);
|
||||
entity->SetGMLevel(info->maxGmLevel);
|
||||
if (info->maxGmLevel == eGameMasterLevel::CIVILIAN) {
|
||||
@@ -138,7 +143,11 @@ namespace {
|
||||
character->SaveXMLToDatabase();
|
||||
|
||||
LOG("Dashboard rescue: transferring %llu to zone %u", objectId, zoneID);
|
||||
WorldPackets::SendTransferToWorld(entity->GetSystemAddress(), serverIP, serverPort, mythranShift);
|
||||
ClientPackets::TransferToWorld transfer;
|
||||
transfer.serverIP = LUString(serverIP);
|
||||
transfer.serverPort = serverPort;
|
||||
transfer.mythranShift = mythranShift;
|
||||
transfer.Send(entity->GetSystemAddress());
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "UserManager.h"
|
||||
#include "User.h"
|
||||
#include "VanityUtilities.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "ClientPackets.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
|
||||
// Database
|
||||
@@ -80,7 +80,12 @@ namespace DEVGMCommands {
|
||||
bool success = user->GetMaxGMLevel() >= level;
|
||||
|
||||
if (success) {
|
||||
WorldPackets::SendGMLevelChange(entity->GetSystemAddress(), success, user->GetMaxGMLevel(), entity->GetGMLevel(), level);
|
||||
ClientPackets::MakeGMResponse response;
|
||||
response.success = success;
|
||||
response.highestLevel = user->GetMaxGMLevel();
|
||||
response.previousLevel = entity->GetGMLevel();
|
||||
response.newLevel = level;
|
||||
response.Send(entity->GetSystemAddress());
|
||||
GameMessages::SendChatModeUpdate(entity->GetObjectID(), level);
|
||||
entity->SetGMLevel(level);
|
||||
LOG("User %s (%i) has changed their GM level to %i for charID %llu", user->GetUsername().c_str(), user->GetAccountID(), level, entity->GetObjectID());
|
||||
@@ -88,7 +93,12 @@ namespace DEVGMCommands {
|
||||
|
||||
#ifndef DEVELOPER_SERVER
|
||||
if ((entity->GetGMLevel() > user->GetMaxGMLevel()) || (entity->GetGMLevel() > eGameMasterLevel::CIVILIAN && user->GetMaxGMLevel() == eGameMasterLevel::JUNIOR_DEVELOPER)) {
|
||||
WorldPackets::SendGMLevelChange(entity->GetSystemAddress(), true, user->GetMaxGMLevel(), entity->GetGMLevel(), eGameMasterLevel::CIVILIAN);
|
||||
ClientPackets::MakeGMResponse response;
|
||||
response.success = true;
|
||||
response.highestLevel = user->GetMaxGMLevel();
|
||||
response.previousLevel = entity->GetGMLevel();
|
||||
response.newLevel = eGameMasterLevel::CIVILIAN;
|
||||
response.Send(entity->GetSystemAddress());
|
||||
GameMessages::SendChatModeUpdate(entity->GetObjectID(), eGameMasterLevel::CIVILIAN);
|
||||
entity->SetGMLevel(eGameMasterLevel::CIVILIAN);
|
||||
|
||||
@@ -1138,7 +1148,11 @@ namespace DEVGMCommands {
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
ClientPackets::TransferToWorld transfer;
|
||||
transfer.serverIP = LUString(serverIP);
|
||||
transfer.serverPort = serverPort;
|
||||
transfer.mythranShift = mythranShift;
|
||||
transfer.Send(sysAddr);
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "PlayerManager.h"
|
||||
#include "SlashCommandHandler.h"
|
||||
#include "VanityUtilities.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "ClientPackets.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
#include "Database.h"
|
||||
|
||||
@@ -179,7 +179,11 @@ namespace GMZeroCommands {
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
ClientPackets::TransferToWorld transfer;
|
||||
transfer.serverIP = LUString(serverIP);
|
||||
transfer.serverPort = serverPort;
|
||||
transfer.mythranShift = mythranShift;
|
||||
transfer.Send(sysAddr);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -210,7 +214,11 @@ namespace GMZeroCommands {
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
ClientPackets::TransferToWorld transfer;
|
||||
transfer.serverIP = LUString(serverIP);
|
||||
transfer.serverPort = serverPort;
|
||||
transfer.mythranShift = mythranShift;
|
||||
transfer.Send(sysAddr);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "PlayerManager.h"
|
||||
#include "ServiceType.h"
|
||||
#include "TradingManager.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "ClientPackets.h"
|
||||
#include "dServer.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
|
||||
@@ -158,7 +158,11 @@ namespace {
|
||||
// player is adopted by it. Same ordered channel as the transfer, so these arrive before it.
|
||||
if (order.seamless) Game::entityManager->DestructAllEntities(sysAddr);
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, order.targetIp, order.targetPort, order.mythranShift);
|
||||
ClientPackets::TransferToWorld transfer;
|
||||
transfer.serverIP = LUString(order.targetIp);
|
||||
transfer.serverPort = order.targetPort;
|
||||
transfer.mythranShift = order.mythranShift;
|
||||
transfer.Send(sysAddr);
|
||||
LOG("Migration %u: sent %s (%llu) to instance %u", order.migrationId, character->GetName().c_str(), playerId, order.targetInstance);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user