rodecomp/Source/Script/NLuaState.cpp
ragnarok-clanker fec919b88e Maintenance: Link-completeness fixes so the whole client links into one executable (all units in data/compile.json plus exe-only thir
Batch #13186 by ragnarok-clanker: forced by an admin (40 lower score(s), 206 changed function(s)); checked with 620 compiled unit(s), including every includer of Source/Archive/GPak.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Session.h, Source/Client/Stove/StoveMgr.h, Source/Client/Stove/StovePCSDK.h, Source/Client/Timer.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/RenderObject.h, Source/Contents/CashEmotionMgr.h, Source/Contents/Configuration/ServiceOptions.h, Source/Contents/Skills/SkillTreeScript.h, Source/Render/DX9/D3DX9Runtime.h, Source/Resource/GifResource.h, Source/UI/AdventureGuide/UIAdventureGuide.h, Source/UI/Cooldowns/CooldownOwner.h, Source/UI/Edit/UIEditBoxEx.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Text/UITextViewerControl.h, Source/UI/UIBroadcastBalloon.h, Source/UI/UICaptchaRegisterWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIReputeWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISelCharForUServerWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/Utility/EncryptedName.h.
2026-11-06 10:56:48 +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* sub_CA4B60() {
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;
}