Skip to content

Commit e8874be

Browse files
committed
Load embedded scripts in a separate step
1 parent 9068737 commit e8874be

File tree

7 files changed

+11
-2
lines changed

7 files changed

+11
-2
lines changed

Client/mods/deathmatch/logic/CResource.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ CResource::CResource(unsigned short usNetID, const char* szResourceName, CClient
8383
if (m_pLuaVM)
8484
{
8585
m_pLuaVM->SetScriptName(szResourceName);
86+
m_pLuaVM->LoadEmbeddedScripts();
8687
}
8788
}
8889

Client/mods/deathmatch/logic/lua/CLuaMain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ void CLuaMain::InitVM()
182182

183183
lua_pushelement(m_luaVM, g_pClientGame->GetLocalPlayer());
184184
lua_setglobal(m_luaVM, "localPlayer");
185+
}
185186

186-
// Load pre-loaded lua scripts
187+
void CLuaMain::LoadEmbeddedScripts()
188+
{
187189
DECLARE_PROFILER_SECTION(OnPreLoadScript)
188190
LoadScript(EmbeddedLuaCode::exports);
189191
LoadScript(EmbeddedLuaCode::coroutine_debug);

Client/mods/deathmatch/logic/lua/CLuaMain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class CLuaMain //: public CClient
7272

7373
void InitClasses(lua_State* luaVM);
7474
void InitVM();
75+
void LoadEmbeddedScripts();
7576
const SString& GetFunctionTag(int iLuaFunction);
7677
int PCall(lua_State* L, int nargs, int nresults, int errfunc);
7778
static int LuaLoadBuffer(lua_State* L, const char* buff, size_t sz, const char* name);

Server/mods/deathmatch/logic/CResource.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,7 @@ bool CResource::CreateVM(bool bEnableOOP)
11061106
return false;
11071107

11081108
m_pVM->SetScriptName(m_strResourceName.c_str());
1109+
m_pVM->LoadEmbeddedScripts();
11091110
return true;
11101111
}
11111112

Server/mods/deathmatch/logic/CResourceHTMLItem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ bool CResourceHTMLItem::Start()
293293
fclose ( debug );*/
294294

295295
m_pVM = g_pGame->GetLuaManager()->CreateVirtualMachine(m_resource, m_bOOPEnabled);
296+
m_pVM->LoadEmbeddedScripts();
296297
m_pVM->LoadScript(strScript.c_str());
297298
m_pVM->SetResourceFile(this);
298299
m_pVM->RegisterHTMLDFunctions();

Server/mods/deathmatch/logic/lua/CLuaMain.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ void CLuaMain::InitVM()
207207

208208
lua_pushelement(m_luaVM, m_pResource->GetResourceRootElement());
209209
lua_setglobal(m_luaVM, "resourceRoot");
210+
}
210211

211-
// Load pre-loaded lua scripts
212+
void CLuaMain::LoadEmbeddedScripts()
213+
{
212214
LoadScript(EmbeddedLuaCode::exports);
213215
LoadScript(EmbeddedLuaCode::coroutine_debug);
214216
LoadScript(EmbeddedLuaCode::inspect);

Server/mods/deathmatch/logic/lua/CLuaMain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class CLuaMain //: public CClient
103103
void RegisterHTMLDFunctions();
104104

105105
void InitVM();
106+
void LoadEmbeddedScripts();
106107
const SString& GetFunctionTag(int iFunctionNumber);
107108
int PCall(lua_State* L, int nargs, int nresults, int errfunc);
108109
void CheckExecutionTime();

0 commit comments

Comments
 (0)