From 98d93b74b59da90ca04d65a1965f1bdc271e934e Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 15:50:46 +0000 Subject: [PATCH] Decompile fn_18348 (?AddNeededSkill@?A0xf8bc354c@@YAHPAUlua_State@@@Z) Batch #12490 by cremane: 0 byte-identical, 1 confirmed by peer review. - fn_18348 ?AddNeededSkill@?A0xf8bc354c@@YAHPAUlua_State@@@Z: logic confirmed by peer review Peer-reviewed-by: Yommy, gordaoprogramas, dori Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Skills/SkillTreeScript.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Contents/Skills/SkillTreeScript.cpp b/Source/Contents/Skills/SkillTreeScript.cpp index 94d2e111..00a4c0a3 100644 --- a/Source/Contents/Skills/SkillTreeScript.cpp +++ b/Source/Contents/Skills/SkillTreeScript.cpp @@ -1,3 +1,4 @@ +#include "Client/Session.h" #include "Contents/Skills/PlayerSkillBundle.h" #include "Contents/Skills/SkillTreeScript.h" @@ -6,16 +7,15 @@ extern "C" { } #include +#include + +CSkillInfo* FindGroupedSkill(CSession& session, std::uint32_t id); namespace { - // INLINED - CPlayerSkillBundle& Bundle(lua_State* state) { - return *static_cast(lua_touserdata(state, lua_upvalueindex(1))); - } - // OFFSET: 0x00AFEE00 // FUNCTION: fn_18349 int AddSkill(lua_State* state) { + CSkillInfo skill(0); const double group = luaL_checknumber(state, 1); const double id = luaL_checknumber(state, 2); const char* name = luaL_checkstring(state, 3); @@ -23,8 +23,7 @@ namespace { const int value = static_cast(luaL_checknumber(state, 5)); const double last = luaL_checknumber(state, 6); - if (*name && position != -1 && value != -1) { - CSkillInfo skill(0); + if (std::strcmp(name, "") != 0 && position != -1 && value != -1) { skill.available = 1; skill.name = name; skill.unknown_0024 = position; @@ -36,7 +35,7 @@ namespace { skill.unknown_001C = 0; skill.unknown_0034 = 0; skill.unknown_002C = static_cast(last); - Bundle(state).AddGrouped(static_cast(group), skill); + g_session.m_skillBundle.AddGrouped(static_cast(group), skill); } return 1; @@ -50,7 +49,7 @@ namespace { const int level = static_cast(luaL_checknumber(state, 3)); if (id != -1 && needed != -1 && level != -1) { - CSkillInfo* skill = Bundle(state).FindGrouped(static_cast(id)); + CSkillInfo* skill = FindGroupedSkill(g_session, static_cast(id)); if (skill && skill->available) { skill->entries.push_back({static_cast(needed), static_cast(level)}); }