mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
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>
73 lines
2.2 KiB
C++
73 lines
2.2 KiB
C++
#ifndef USERMANAGER_H
|
|
#define USERMANAGER_H
|
|
|
|
#define _VARIADIC_MAX 10
|
|
#include <string>
|
|
#include <vector>
|
|
#include "RakNetTypes.h"
|
|
#include <map>
|
|
|
|
class User;
|
|
|
|
namespace WorldPackets {
|
|
struct CharacterCreateRequest;
|
|
struct CharacterDeleteRequest;
|
|
struct CharacterRenameRequest;
|
|
}
|
|
|
|
class UserManager {
|
|
public:
|
|
static UserManager* Instance() {
|
|
if (!m_Address) {
|
|
m_Address = new UserManager();
|
|
}
|
|
|
|
return m_Address;
|
|
}
|
|
|
|
void Initialize();
|
|
~UserManager();
|
|
|
|
User* CreateUser(const SystemAddress& sysAddr, const std::string& username, const std::string& sessionKey);
|
|
User* GetUser(const SystemAddress& sysAddr);
|
|
User* GetUser(const std::string& username);
|
|
std::vector<User*> GetUsersForAccount(uint32_t accountId);
|
|
bool DeleteUser(const SystemAddress& sysAddr); //Returns true on succesful deletion
|
|
void DeletePendingRemovals();
|
|
|
|
std::string GetPredefinedName(uint32_t firstNameIndex, uint32_t middleNameIndex, uint32_t lastNameIndex);
|
|
bool IsNamePreapproved(const std::string& requestedName);
|
|
|
|
void RequestCharacterList(const SystemAddress& sysAddr);
|
|
void CreateCharacter(const SystemAddress& sysAddr, const WorldPackets::CharacterCreateRequest& request);
|
|
void DeleteCharacter(const SystemAddress& sysAddr, const WorldPackets::CharacterDeleteRequest& request);
|
|
void RenameCharacter(const SystemAddress& sysAddr, const WorldPackets::CharacterRenameRequest& request);
|
|
void LoginCharacter(const SystemAddress& sysAddr, LWOOBJID playerID);
|
|
|
|
void SaveAllActiveCharacters();
|
|
|
|
size_t GetUserCount() const { return m_Users.size(); }
|
|
|
|
// Access cached config values
|
|
bool GetMuteAutoRejectNames() const { return m_MuteAutoRejectNames; }
|
|
bool GetMuteRestrictTrade() const { return m_MuteRestrictTrade; }
|
|
bool GetMuteRestrictMail() const { return m_MuteRestrictMail; }
|
|
|
|
private:
|
|
static UserManager* m_Address; //Singleton
|
|
std::map<SystemAddress, User*> m_Users;
|
|
std::vector<User*> m_UsersToDelete;
|
|
|
|
std::vector<std::string> m_FirstNames;
|
|
std::vector<std::string> m_MiddleNames;
|
|
std::vector<std::string> m_LastNames;
|
|
std::vector<std::string> m_PreapprovedNames;
|
|
|
|
// Cached config values that can change on config reload
|
|
bool m_MuteAutoRejectNames = false;
|
|
bool m_MuteRestrictTrade = false;
|
|
bool m_MuteRestrictMail = false;
|
|
};
|
|
|
|
#endif // USERMANAGER_H
|