rodecomp/Source/Script/NLuaState.cpp
ragnarok-clanker 3f8411389e Maintenance: Rename placeholder sub_XXXXXX functions to evidence-based names (Lua registration strings, log/error strings, packet ids
Batch #13406 by ragnarok-clanker: no function's compiled code changes; checked with 124 compiled unit(s), including every includer of Source/Contents/Effects/RagEffect.h, Source/Contents/Effects/PowderingEffect.h, Source/Contents/Effects/SpriteParticle.h, Source/UI/Enchant/EnchantUI.h, Source/UI/Guild/UIAgitWnd.h, Source/UI/Window/UINewSelectCharWnd.h, Source/Contents/Actors/Skill.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/Contents/Effects/HealEffect.h, Source/Contents/AchievementMgr.h, Source/UI/Window/UISecondCostumeWnd.h, Source/Contents/Effects/LightSphereEffect.h, Source/Contents/Effects/BlastForge.h, Source/Security/NProtectGameGuardMgr.h, Source/Contents/Effects/MapChainEffect.h, Source/Utility/Math/Int64Math.h.
2026-11-06 16:08:47 +00:00

85 lines
1.8 KiB
C++

#include "Script/NLuaState.h"
extern "C" {
#include <lauxlib.h>
#include <lua.h>
}
#include <utility>
// GLOBAL: gl_24849
void* g_entryQueueMgr = nullptr;
struct TreeSubNode {
TreeSubNode* left;
TreeSubNode* parent;
TreeSubNode* right;
char color;
char isnil;
};
struct TreeSubMap {
TreeSubNode* head;
unsigned int size;
void Clear() noexcept;
__declspec(noinline) void EraseSubtree(TreeSubMap& al, TreeSubNode* node);
};
// OFFSET: 0x00BA1A20
// FUNCTION: fn_19656
void TreeSubMap::EraseSubtree(TreeSubMap& al, TreeSubNode* node) {
while (node->isnil == 0) {
this->EraseSubtree(al, node->right);
::operator delete(std::exchange(node, node->left), 0x18);
}
}
// OFFSET: 0x00CA4AE0
// FUNCTION: fn_20939
void TreeSubMap::Clear() noexcept {
TreeSubNode* head = this->head;
TreeSubNode* cur = head->parent;
while (cur->isnil == 0) {
this->EraseSubtree(*this, cur->right);
::operator delete(std::exchange(cur, cur->left), 0x18);
}
head->parent = head;
head->left = head;
head->right = head;
this->size = 0;
}
// OFFSET: 0x00CA4B60
// FUNCTION: fn_20940
void* GetEntryQueueMgr() {
return g_entryQueueMgr;
}
// 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;
}