From d1be1f651fe987fe080c2e1d68146e4f37c025dc Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 23:10:20 +0000 Subject: [PATCH] Decompile fn_17982 (CItemInfoMgr::Load) Batch #3700 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_17982 CItemInfoMgr::Load: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, eAthena, superintelligence Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Items/ItemInfoMgr.cpp | 36 +++++++++++++++++++++++++++ Source/Contents/Items/ItemInfoMgr.h | 1 + 2 files changed, 37 insertions(+) diff --git a/Source/Contents/Items/ItemInfoMgr.cpp b/Source/Contents/Items/ItemInfoMgr.cpp index a73c784e..1f829b17 100644 --- a/Source/Contents/Items/ItemInfoMgr.cpp +++ b/Source/Contents/Items/ItemInfoMgr.cpp @@ -1,16 +1,19 @@ #include "Contents/Items/ItemInfoMgr.h" #include "Contents/Items/ItemDescription.h" +#include "Script/NLuaState.h" extern "C" { #include #include +#include } #include #include #include #include #include +#include // GLOBAL: gl_24729 CItemInfoMgr* g_itemInfoMgr; @@ -72,6 +75,39 @@ int CItemInfoMgr::GetPackageId(int id) { return 0; } +// OFFSET: 0x00ADFF90 +// FUNCTION: fn_17982 +bool CItemInfoMgr::Load() { + NLuaState lua; + if (lua.IsValid()) { + luaL_openlibs(lua.GetState()); + lua_register(lua.GetState(), "AddItem", CItemInfoMgr::LuaAddItem); + lua_register(lua.GetState(), "AddItemUnidentifiedDesc", CItemInfoMgr::LuaAddItemUnidentifiedDesc); + lua_register(lua.GetState(), "AddItemIdentifiedDesc", CItemInfoMgr::LuaAddItemIdentifiedDesc); + lua_register(lua.GetState(), "AddItemEffectInfo", CItemInfoMgr::LuaAddItemEffectInfo); + lua_register(lua.GetState(), "AddItemIsCostume", CItemInfoMgr::LuaAddItemIsCostume); + lua_register(lua.GetState(), "AddItemPackageID", CItemInfoMgr::LuaAddItemPackageID); + if (luaL_loadfile(lua.GetState(), "SystemEN\\iteminfo.lua") != 0 || lua_pcall(lua.GetState(), 0, 0, 0) != 0) { + MessageBoxA(nullptr, lua_tostring(lua.GetState(), -1), "CItemInfoMgr", 0); + } else { + lua_getglobal(lua.GetState(), "main"); + if (lua_pcall(lua.GetState(), 0, 2, 0) != 0) { + MessageBoxA(nullptr, lua_tostring(lua.GetState(), -1), "CItemInfoMgr", 0); + } else if (!lua_isstring(lua.GetState(), -1)) { + MessageBoxA(nullptr, "second return value is not string...", "CItemInfoMgr", 0); + } else { + if (lua_toboolean(lua.GetState(), -2)) { + return true; + } + std::string message = std::string("error found :") + lua_tostring(lua.GetState(), -1); + MessageBoxA(nullptr, message.c_str(), "CItemInfoMgr", 0); + } + } + } + + return false; +} + // OFFSET: 0x00AE0270 // FUNCTION: fn_17983 static __declspec(noinline) std::string FormatItemInfoMessage(const char* format, ...) { diff --git a/Source/Contents/Items/ItemInfoMgr.h b/Source/Contents/Items/ItemInfoMgr.h index a0e0dd64..dd12e623 100644 --- a/Source/Contents/Items/ItemInfoMgr.h +++ b/Source/Contents/Items/ItemInfoMgr.h @@ -62,6 +62,7 @@ public: this->m_items[id].identifiedResourceName = resourceName; } + bool Load(); int IsCostume(int id); int GetEffectId(int id); int GetPackageId(int id);