Batch #17665 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_04258 CPlayerNameDictionary::Set: logic confirmed by peer review Peer-reviewed-by: Yommy, cremane, bibinir Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
#ifndef RAGNAROK_SOURCE_CONTENTS_ACTORS_PLAYERNAMEDICTIONARY_H
|
|
#define RAGNAROK_SOURCE_CONTENTS_ACTORS_PLAYERNAMEDICTIONARY_H
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <deque>
|
|
#include <map>
|
|
#include <string>
|
|
#include <windows.h>
|
|
|
|
class CPlayerNameDictionary {
|
|
public:
|
|
CPlayerNameDictionary();
|
|
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;
|
|
// INLINED
|
|
bool IsEnabled() const {
|
|
return this->m_enabled;
|
|
}
|
|
void Update();
|
|
|
|
private:
|
|
struct Entry {
|
|
/* 0000 */ std::string name;
|
|
/* 0018 */ std::uint32_t tick;
|
|
|
|
Entry() = default;
|
|
Entry(std::string value);
|
|
|
|
bool IsExpired() const;
|
|
};
|
|
struct Request {
|
|
/* 0000 */ std::uint32_t id;
|
|
/* 0004 */ std::uint32_t tick;
|
|
};
|
|
#if defined(_WIN32) && !defined(_WIN64)
|
|
static_assert(sizeof(Entry) == 0x1C);
|
|
static_assert(offsetof(Entry, tick) == 0x18);
|
|
static_assert(sizeof(Request) == 0x08);
|
|
static_assert(offsetof(Request, tick) == 0x04);
|
|
#endif
|
|
/* 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;
|
|
};
|
|
|
|
#if defined(_WIN32) && !defined(_WIN64)
|
|
static_assert(sizeof(CPlayerNameDictionary) == 0x38);
|
|
#endif
|
|
|
|
extern CPlayerNameDictionary* g_playerNameDictionary;
|
|
|
|
bool CreatePlayerNameDictionary();
|
|
void DestroyPlayerNameDictionary();
|
|
std::string LookupPlayerName(std::uint32_t id);
|
|
|
|
#endif
|