Decompile 6 functions in Source/Contents/CashEmotionMgr.cpp, Source/Contents/CashEmotionMgr.h

Batch #1250 by eAthena: 0 byte-identical, 6 confirmed by peer review.

- fn_02975 CCashEmotionMgr::IsOwnedPack: logic confirmed by peer review
- fn_02849 CashEmotionCommand::CashEmotionCommand: logic confirmed by peer review
- fn_02850 CashEmotionCommand::Add: logic confirmed by peer review
- fn_02851 CashEmotionCommand::Get: logic confirmed by peer review
- fn_02936 CCashEmotionMgr::ClearCommands: logic confirmed by peer review
- fn_02963 CCashEmotionMgr::GetSprFileName: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
This commit is contained in:
ragnarok-clanker 2026-10-27 23:23:11 +00:00
commit c01d0dae32
2 changed files with 84 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#include "Contents/CashEmotionMgr.h"
#include "UI/Chat/ChatSuggestions.h"
#include <algorithm>
#include <cstring>
#include <new>
@ -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<int, int> CashEmotionCommand::Get(int index) const {
if (index < 0 || static_cast<std::size_t>(index) >= this->entries.size()) {
return std::pair<int, int>(-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<CashEmotionCommand*>(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();
}

View file

@ -5,6 +5,26 @@
#include <cstdint>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
struct CashEmotionKeyHash {
// INLINED
std::size_t operator()(int key) const {
return static_cast<std::size_t>(key);
}
};
class CashEmotionCommand {
public:
CashEmotionCommand(const std::string& name, int packId, int emotionId);
void Add(int packId, int emotionId);
std::pair<int, int> Get(int index) const;
/* 0000 */ std::string name;
/* 0018 */ std::vector<std::pair<int, int>> 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<int, std::unordered_map<int, CashEmotionData>> m_emotionsByPack;
/* 0050 */ std::uint8_t unknown_0050[64];
/* 0090 */ std::unordered_map<int, std::string> m_packNames;
/* 00B0 */ std::uint8_t unknown_00B0[200];
/* 00B0 */ std::uint8_t unknown_00B0[36];
/* 00D4 */ std::unordered_map<int, std::string, CashEmotionKeyHash> m_sprNames;
/* 00F4 */ std::uint8_t unknown_00F4[132]{};
/* 0178 */ std::unordered_map<std::string, int> m_commands;
/* 0198 */ std::uint8_t unknown_0198[64];
/* 0198 */ std::uint8_t unknown_0198[12];
/* 01A4 */ std::vector<int> 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