diff --git a/Source/Contents/ConfigMgr.cpp b/Source/Contents/ConfigMgr.cpp index e51219dc..90cffe13 100644 --- a/Source/Contents/ConfigMgr.cpp +++ b/Source/Contents/ConfigMgr.cpp @@ -6,8 +6,30 @@ CConfigMgr* g_configMgr = nullptr; // OFFSET: 0x007A6FE0 +// FUNCTION: fn_09042 +CConfigMgr::~CConfigMgr() { +} // OFFSET: 0x007A7070 +// FUNCTION: fn_09044 +bool CConfigMgr::Create() { + if (g_configMgr) { + return false; + } + + g_configMgr = new (std::nothrow) CConfigMgr(); + if (!g_configMgr) { + return false; + } + + if (!g_configMgr->m_initialized) { + delete g_configMgr; + g_configMgr = nullptr; + return false; + } + + return true; +} // OFFSET: 0x007A7160 // FUNCTION: fn_09045 @@ -15,3 +37,10 @@ void CConfigMgr::Update() { } // OFFSET: 0x007A7170 +// FUNCTION: fn_09046 +void CConfigMgr::Destroy() { + if (g_configMgr) { + delete g_configMgr; + g_configMgr = nullptr; + } +} diff --git a/Source/Contents/SimpleStringMgr.cpp b/Source/Contents/SimpleStringMgr.cpp index 01b29541..ec56305c 100644 --- a/Source/Contents/SimpleStringMgr.cpp +++ b/Source/Contents/SimpleStringMgr.cpp @@ -6,5 +6,31 @@ CSimpleStringMgr* g_simpleStringMgr = nullptr; // OFFSET: 0x007A96A0 +// FUNCTION: fn_09077 +void CSimpleStringMgr::Destroy() { + if (g_simpleStringMgr) { + delete g_simpleStringMgr; + g_simpleStringMgr = nullptr; + } +} // OFFSET: 0x007A9DA0 +// FUNCTION: fn_09079 +const char* CSimpleStringMgr::GetString(const char* key) { + STR_TYPE type = STR_TYPE_EMOTION; + if (key == nullptr || std::strlen(key) == 0) { + return nullptr; + } + + auto table = this->m_tables.find(type); + if (table == this->m_tables.end()) { + return nullptr; + } + + auto entry = table->second.find(std::string(key)); + if (entry == table->second.end()) { + return nullptr; + } + + return entry->second.c_str(); +} diff --git a/Source/Contents/SpecialPopupMgr.cpp b/Source/Contents/SpecialPopupMgr.cpp index b32ecda9..72566af7 100644 --- a/Source/Contents/SpecialPopupMgr.cpp +++ b/Source/Contents/SpecialPopupMgr.cpp @@ -13,13 +13,108 @@ extern "C" { CSpecialPopupMgr* g_specialPopupMgr = nullptr; // OFFSET: 0x007A7930 +// FUNCTION: fn_09052 +bool CSpecialPopupMgr::Create() { + if (g_specialPopupMgr) { + return false; + } + + g_specialPopupMgr = new (std::nothrow) CSpecialPopupMgr(); + if (!g_specialPopupMgr) { + return false; + } + + if (!g_specialPopupMgr->m_initialized) { + delete g_specialPopupMgr; + g_specialPopupMgr = nullptr; + return false; + } + + return true; +} // OFFSET: 0x007A7A20 +// FUNCTION: fn_09053 +void CSpecialPopupMgr::Destroy() { + if (g_specialPopupMgr) { + delete g_specialPopupMgr; + g_specialPopupMgr = nullptr; + } +} // OFFSET: 0x007A7A40 +// FUNCTION: fn_09054 +PopupData* CSpecialPopupMgr::GetPopup(int id) { + std::map::iterator it = this->m_popups.find(id); + if (it == this->m_popups.end()) { + return nullptr; + } + + return &it->second; +} // OFFSET: 0x007A7DB0 +// FUNCTION: fn_09056 +std::string FormatPopupString(const char* format, ...) { + char buffer[2049]; + std::memset(buffer, 0, sizeof(buffer)); + + va_list arguments; + va_start(arguments, format); + _vsnprintf(buffer, 2048, format, arguments); + return std::string(buffer); +} // OFFSET: 0x007A80B0 +// FUNCTION: fn_09058 +int CSpecialPopupMgr::LuaAddDesc(lua_State* state) { + if (!lua_isstring(state, -1)) { + lua_pushboolean(state, 0); + lua_pushstring(state, FormatPopupString("2nd argment is must string").c_str()); + return 2; + } + + if (!lua_isnumber(state, -2)) { + lua_pushboolean(state, 0); + lua_pushstring(state, FormatPopupString("1st argment is must number").c_str()); + return 2; + } + + const int id = static_cast(lua_tonumber(state, -2)); + std::string description = lua_tostring(state, -1); + g_specialPopupMgr->AddDescription(id, description); + lua_pushboolean(state, 1); + lua_pushstring(state, FormatPopupString("good").c_str()); + return 2; +} // OFFSET: 0x007A82D0 +// FUNCTION: fn_09059 +int CSpecialPopupMgr::LuaAddMsg(lua_State* state) { + const int id = static_cast(lua_tonumber(state, -3)); + if (!lua_isnumber(state, -3)) { + lua_pushboolean(state, 0); + lua_pushstring(state, FormatPopupString("3th argment is must number [itemID:%d]", id).c_str()); + return 2; + } + + if (!lua_isnumber(state, -2)) { + lua_pushboolean(state, 0); + lua_pushstring(state, FormatPopupString("2nd argment is must number [itemID:%d]", id).c_str()); + return 2; + } + + if (!lua_isnumber(state, -1)) { + lua_pushboolean(state, 0); + lua_pushstring(state, FormatPopupString("1st argment is must number [itemID:%d]", id).c_str()); + return 2; + } + + const int messageId = static_cast(lua_tonumber(state, -2)); + const unsigned int color = static_cast(lua_tonumber(state, -1)); + g_specialPopupMgr->m_popups[id].m_messageId = messageId; + g_specialPopupMgr->m_popups[id].m_color = ((((color >> 8) & 0xFF) | ((color & 0xFF) << 8)) << 8) | ((color >> 16) & 0xFF); + lua_pushboolean(state, 1); + lua_pushstring(state, FormatPopupString("good").c_str()); + return 2; +}