diff --git a/Source/Contents/CashEmotionMgr.cpp b/Source/Contents/CashEmotionMgr.cpp index 41a6f5c..c285570 100644 --- a/Source/Contents/CashEmotionMgr.cpp +++ b/Source/Contents/CashEmotionMgr.cpp @@ -1,6 +1,7 @@ #include "Contents/CashEmotionMgr.h" #include "UI/Chat/ChatSuggestions.h" +#include #include #include @@ -18,6 +19,32 @@ public: unsigned int Select(int actionId); }; +// OFFSET: 0x00592290 +// FUNCTION: fn_02849 +CashEmotionCommand::CashEmotionCommand(const std::string& name, int packId, int emotionId) : name(name) { + this->Add(packId, emotionId); +} + +// OFFSET: 0x005923D0 +// FUNCTION: fn_02850 +void CashEmotionCommand::Add(int packId, int emotionId) { + if (packId < 0 || emotionId < 0) { + return; + } + + this->entries.emplace_back(packId, emotionId); +} + +// OFFSET: 0x00592420 +// FUNCTION: fn_02851 +std::pair CashEmotionCommand::Get(int index) const { + if (index < 0 || static_cast(index) >= this->entries.size()) { + return std::pair(-1, -1); + } + + return this->entries[index]; +} + // OFFSET: 0x00596430 // FUNCTION: fn_02915 CCashEmotionMgr::CCashEmotionMgr() @@ -41,6 +68,16 @@ void CCashEmotionMgr::Reset() { this->m_commands.clear(); } +// OFFSET: 0x00598F40 +// FUNCTION: fn_02936 +void CCashEmotionMgr::ClearCommands() { + for (auto& entry : this->m_commands) { + delete reinterpret_cast(entry.second); + } + + this->m_commands.erase(this->m_commands.begin(), this->m_commands.end()); +} + // OFFSET: 0x00599650 // FUNCTION: fn_02940 bool CCashEmotionMgr::Initialize() { @@ -156,3 +193,20 @@ const char* CCashEmotionMgr::GetEmotionName(int packId, int emotionId) { return emoIt->second.name.c_str(); } + +// OFFSET: 0x0059AC40 +// FUNCTION: fn_02963 +const char* CCashEmotionMgr::GetSprFileName(int sprId) { + auto it = this->m_sprNames.find(sprId); + if (it == this->m_sprNames.end()) { + return nullptr; + } + + return it->second.c_str(); +} + +// OFFSET: 0x0059C490 +// FUNCTION: fn_02975 +bool CCashEmotionMgr::IsOwnedPack(int packId) { + return std::find(this->m_ownedPacks.begin(), this->m_ownedPacks.end(), packId) != this->m_ownedPacks.end(); +} diff --git a/Source/Contents/CashEmotionMgr.h b/Source/Contents/CashEmotionMgr.h index 2a8b6a1..b1b6bbd 100644 --- a/Source/Contents/CashEmotionMgr.h +++ b/Source/Contents/CashEmotionMgr.h @@ -5,6 +5,26 @@ #include #include #include +#include +#include + +struct CashEmotionKeyHash { + // INLINED + std::size_t operator()(int key) const { + return static_cast(key); + } +}; + +class CashEmotionCommand { +public: + CashEmotionCommand(const std::string& name, int packId, int emotionId); + + void Add(int packId, int emotionId); + std::pair Get(int index) const; + + /* 0000 */ std::string name; + /* 0018 */ std::vector> entries; +}; struct CashEmotionData { int id; @@ -21,11 +41,14 @@ public: static void Shutdown(); void Reset(); + void ClearCommands(); void HideSuggestions(); int ProcessChatCommand(const char* command); const char* GetPackName(int packId); CashEmotionData* GetEmotionData(int packId, int emotionId); const char* GetEmotionName(int packId, int emotionId); + const char* GetSprFileName(int sprId); + bool IsOwnedPack(int packId); protected: /* 0004 */ bool m_enabled; @@ -36,15 +59,20 @@ protected: /* 0030 */ std::unordered_map> m_emotionsByPack; /* 0050 */ std::uint8_t unknown_0050[64]; /* 0090 */ std::unordered_map m_packNames; - /* 00B0 */ std::uint8_t unknown_00B0[200]; + /* 00B0 */ std::uint8_t unknown_00B0[36]; + /* 00D4 */ std::unordered_map m_sprNames; + /* 00F4 */ std::uint8_t unknown_00F4[132]{}; /* 0178 */ std::unordered_map m_commands; - /* 0198 */ std::uint8_t unknown_0198[64]; + /* 0198 */ std::uint8_t unknown_0198[12]; + /* 01A4 */ std::vector m_ownedPacks; + /* 01B0 */ std::uint8_t unknown_01B0[40]{}; }; extern CCashEmotionMgr* g_cashEmotionMgr; #if defined(_WIN32) && !defined(_WIN64) static_assert(offsetof(CashEmotionData, name) == 0x08); +static_assert(sizeof(CashEmotionCommand) == 0x24); static_assert(sizeof(CCashEmotionMgr) == 472); #endif