rodecomp/Source/Contents/PlayerNameDictionary.h
2026-10-24 00:35:19 +00:00

51 lines
1.2 KiB
C++

#ifndef RAGNAROK_SOURCE_CONTENTS_PLAYERNAMEDICTIONARY_H
#define RAGNAROK_SOURCE_CONTENTS_PLAYERNAMEDICTIONARY_H
#include <cstdint>
#include <deque>
#include <map>
#include <string>
#include <windows.h>
class CConnection;
struct PlayerNameContext {
CConnection& connection;
const bool& languagePrefix;
const int& service;
const WORD& language;
};
// RTTI CPlayerNameDictionary. Original56-byte owned map and two deques;
// reconstructed source adds one explicit context pointer.
class CPlayerNameDictionary {
public:
explicit CPlayerNameDictionary(PlayerNameContext& context);
virtual ~CPlayerNameDictionary();
std::string Lookup(std::uint32_t id);
void Set(std::uint32_t id, std::string name);
void Clear();
bool Contains(std::uint32_t id) const;
void Update();
private:
struct Entry {
std::string name;
std::uint32_t tick;
};
struct Request {
std::uint32_t id;
std::uint32_t tick;
};
/* 0004 */ bool m_enabled;
/* 0008 */ std::map<std::uint32_t, Entry> m_names;
/* 0010 */ std::deque<std::uint32_t> m_pending;
/* 0024 */ std::deque<Request> m_requests;
PlayerNameContext* m_context;
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(CPlayerNameDictionary) == 60);
#endif
#endif