mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +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:
@@ -159,9 +159,14 @@ Every non-game-message packet is an `LUBitStream` subclass. The base owns the fu
|
||||
- Each service has one dispatch function with a `std::map<MessageType::X, factory>`, exactly like
|
||||
`Mail::HandleMail`: read the id, create, set context, `Deserialize` (log and drop on failure), `Handle`. Each
|
||||
server's `HandlePacket` only routes by `ServiceType`.
|
||||
- Structs live in their service's namespace and file: `AuthPackets`, `ChatPackets`, `ClientPackets`,
|
||||
`CommonPackets` (new, for `ServiceType::COMMON`), `MasterPackets`, `WorldPackets` in `dNet/`; Mail stays in
|
||||
`dGame/dUtilities/Mail.*`. Handlers that need game or server state stay in the server that owns that state
|
||||
- **One file pair per `ServiceType`; a packet goes in the file of the `ServiceType` written in its header**, in
|
||||
that namespace: `CommonPackets` (COMMON), `AuthPackets` (AUTH), `ChatPackets` (CHAT), `WorldPackets` (WORLD:
|
||||
what a client sends to a world server), `ClientPackets` (CLIENT: what any server sends to the client),
|
||||
`MasterPackets` (MASTER), all in `dNet/`. So the auth server's login response is in `ClientPackets`, and a
|
||||
world server's message to chat is in `ChatPackets`. Anything used by several services (for example `Stamps`,
|
||||
which rides in auth, master and client packets, or generic helpers) gets its own small file named for what it
|
||||
is (`dNet/Stamps.h`), not one service's file. A packet found in the wrong file is moved (a pure move, same
|
||||
bytes). Mail stays in `dGame/dUtilities/Mail.*`. Handlers that need game or server state stay in the server that owns that state
|
||||
(`dChatServer`, `dMasterServer`, `dWorldServer`, `dAuthServer`) and are attached to the struct by overriding
|
||||
`Handle` in that server's translation unit.
|
||||
- Fixed-width strings use `LUString`/`LUWString` with the width spelled out (`LUWString password(41)`).
|
||||
|
||||
Reference in New Issue
Block a user