From 9562207a4dba0ef4e0ac56bfa0caab0f23fdf034 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 29 Oct 2026 21:50:08 +0000 Subject: [PATCH] Decompile 2 functions in Source/Script/NLuaState.cpp, Source/Script/NLuaState.h Batch #3188 by eAthena: 0 byte-identical, 2 confirmed by peer review. - fn_20941 NLuaState::NLuaState: logic confirmed by peer review - fn_20944 NLuaThread::`scalar deleting destructor': logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Script/NLuaState.cpp --- Source/Script/NLuaState.cpp | 35 +++++++++++++++++++++++++++++++++++ Source/Script/NLuaState.h | 35 +++++++++++++++++++++++++++++++++++ data/compile.json | 1 + 3 files changed, 71 insertions(+) create mode 100644 Source/Script/NLuaState.cpp create mode 100644 Source/Script/NLuaState.h diff --git a/Source/Script/NLuaState.cpp b/Source/Script/NLuaState.cpp new file mode 100644 index 00000000..4fd78211 --- /dev/null +++ b/Source/Script/NLuaState.cpp @@ -0,0 +1,35 @@ +#include "Script/NLuaState.h" + +extern "C" { +#include +#include +} + +// OFFSET: 0x00CA4CF0 +// FUNCTION: fn_20941 +NLuaState::NLuaState() : m_state(nullptr), m_isValid(false) { + this->m_state = luaL_newstate(); + if (this->m_state != nullptr) { + this->m_isValid = true; + } +} + +NLuaState::~NLuaState() { + if (this->m_state != nullptr) { + lua_close(this->m_state); + this->m_state = nullptr; + } +} + +NLuaThread::NLuaThread(NLuaState& parent) : m_state(nullptr), m_isValid(false) { + this->m_state = lua_newthread(parent.m_state); + if (this->m_state != nullptr) { + this->m_isValid = true; + } +} + +// OFFSET: 0x00CA4E80 +// FUNCTION: fn_20944 +NLuaThread::~NLuaThread() { + this->m_state = nullptr; +} diff --git a/Source/Script/NLuaState.h b/Source/Script/NLuaState.h new file mode 100644 index 00000000..3a14cd52 --- /dev/null +++ b/Source/Script/NLuaState.h @@ -0,0 +1,35 @@ +#ifndef RAGNAROK_SOURCE_SCRIPT_NLUASTATE_H +#define RAGNAROK_SOURCE_SCRIPT_NLUASTATE_H + +struct lua_State; + +// VTABLE: vt_01824 +class NLuaState { +public: + NLuaState(); + virtual ~NLuaState(); + + // INLINED + lua_State* GetState() const { + return this->m_state; + } + // INLINED + bool IsValid() const { + return this->m_isValid; + } + + /* 0004 */ lua_State* m_state; + /* 0008 */ bool m_isValid; +}; + +// VTABLE: vt_01825 +class NLuaThread { +public: + explicit NLuaThread(NLuaState& parent); + virtual ~NLuaThread(); + + /* 0004 */ lua_State* m_state; + /* 0008 */ bool m_isValid; +}; + +#endif diff --git a/data/compile.json b/data/compile.json index 9f64471b..b03808c8 100644 --- a/data/compile.json +++ b/data/compile.json @@ -658,6 +658,7 @@ "Source/Script/LuaFileOperations.cpp": 5, "Source/Script/LuaInstance.cpp": 5, "Source/Script/LuaScript.cpp": 5, + "Source/Script/NLuaState.cpp": 5, "Source/UI/Acceptance/UIChooseSellBuyWnd.cpp": 2, "Source/UI/Acceptance/UIExchangeAcceptWnd.cpp": 2, "Source/UI/Acceptance/UIJoinPartyAcceptWnd.cpp": 2,