mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve CSquirrelVM methods
* Made part of class, hooks are static. * Added proper return and parameter types to script compiler methods.
This commit is contained in:
parent
199c4caede
commit
f1da8d315d
@ -318,7 +318,7 @@ void Script_SetCompilingVM(CSquirrelVM* vm, RSON::Node_t* rson)
|
||||
}
|
||||
}
|
||||
|
||||
void CSquirrelVM_CompileModScripts(CSquirrelVM* vm)
|
||||
void CSquirrelVM::CompileModScripts()
|
||||
{
|
||||
for (auto& mod : g_pModSystem->GetModList())
|
||||
{
|
||||
@ -331,15 +331,15 @@ void CSquirrelVM_CompileModScripts(CSquirrelVM* vm)
|
||||
RSON::Node_t* rson = mod.LoadScriptCompileList(); // allocs parsed rson buffer
|
||||
|
||||
if (!rson)
|
||||
Error(vm->GetVM()->GetNativePrintContext(), EXIT_FAILURE, "%s: Failed to load RSON file %s\n", __FUNCTION__, mod.GetScriptCompileListPath().string().c_str());
|
||||
Error(GetVM()->GetNativePrintContext(), EXIT_FAILURE, "%s: Failed to load RSON file %s\n", __FUNCTION__, mod.GetScriptCompileListPath().string().c_str());
|
||||
|
||||
const char* scriptPathArray[1024];
|
||||
int scriptCount = 0;
|
||||
|
||||
Script_SetCompilingVM(vm, rson);
|
||||
Script_SetCompilingVM(this, rson);
|
||||
|
||||
if (Script_ParseCompileListRSON(
|
||||
vm->GetContext(),
|
||||
GetContext(),
|
||||
mod.GetScriptCompileListPath().string().c_str(),
|
||||
rson,
|
||||
(char**)scriptPathArray, &scriptCount,
|
||||
@ -361,12 +361,12 @@ void CSquirrelVM_CompileModScripts(CSquirrelVM* vm)
|
||||
scriptPathArray[i] = pszScriptPath;
|
||||
}
|
||||
|
||||
switch (vm->GetVM()->GetContext())
|
||||
switch (GetVM()->GetContext())
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
case SQCONTEXT::SERVER:
|
||||
{
|
||||
v_CSquirrelVM_CompileScriptsFromArray_SV(vm, vm->GetContext(), (char**)scriptPathArray, scriptCount);
|
||||
v_CSquirrelVM_CompileScriptsFromArray_SV(this, GetContext(), (char**)scriptPathArray, scriptCount);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -374,7 +374,7 @@ void CSquirrelVM_CompileModScripts(CSquirrelVM* vm)
|
||||
case SQCONTEXT::CLIENT:
|
||||
case SQCONTEXT::UI:
|
||||
{
|
||||
v_CSquirrelVM_CompileScriptsFromArray_UICL(vm, vm->GetContext(), (char**)scriptPathArray, scriptCount);
|
||||
v_CSquirrelVM_CompileScriptsFromArray_UICL(this, GetContext(), (char**)scriptPathArray, scriptCount);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -393,27 +393,27 @@ void CSquirrelVM_CompileModScripts(CSquirrelVM* vm)
|
||||
|
||||
|
||||
#ifndef DEDICATED
|
||||
__int64 CSquirrelVM_CompileUICLScripts(CSquirrelVM* vm)
|
||||
bool CSquirrelVM::CompileClientScripts(CSquirrelVM* vm)
|
||||
{
|
||||
HSQUIRRELVM v = vm->GetVM();
|
||||
DevMsg(v->GetNativePrintContext(), (char*)"Loading and compiling script lists\n");
|
||||
|
||||
CSquirrelVM_CompileModScripts(vm);
|
||||
vm->CompileModScripts();
|
||||
|
||||
return v_CSquirrelVM_CompileUICLScripts(vm);
|
||||
return v_CSquirrelVM_CompileClientScripts(vm);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
__int64 CSquirrelVM_CompileSVScripts(__int64 a1)
|
||||
bool CSquirrelVM::CompileServerScripts(int numPrecompiled)
|
||||
{
|
||||
HSQUIRRELVM v = g_pServerScript->GetVM();
|
||||
|
||||
DevMsg(v->GetNativePrintContext(), (char*)"Loading and compiling script lists\n");
|
||||
|
||||
CSquirrelVM_CompileModScripts(g_pServerScript);
|
||||
g_pServerScript->CompileModScripts();
|
||||
|
||||
return v_CSquirrelVM_CompileSVScripts(a1);
|
||||
return v_CSquirrelVM_CompileServerScripts(numPrecompiled);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -427,10 +427,10 @@ void VSquirrelVM::Attach() const
|
||||
DetourAttach((LPVOID*)&v_Script_LoadScript, &Script_LoadScript);
|
||||
|
||||
#ifndef DEDICATED
|
||||
DetourAttach((LPVOID*)&v_CSquirrelVM_CompileUICLScripts, &CSquirrelVM_CompileUICLScripts);
|
||||
DetourAttach((LPVOID*)&v_CSquirrelVM_CompileClientScripts, &CSquirrelVM::CompileClientScripts);
|
||||
#endif
|
||||
#ifndef CLIENT_DLL
|
||||
DetourAttach((LPVOID*)&v_CSquirrelVM_CompileSVScripts, &CSquirrelVM_CompileSVScripts);
|
||||
DetourAttach((LPVOID*)&v_CSquirrelVM_CompileServerScripts, &CSquirrelVM::CompileServerScripts);
|
||||
#endif
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
@ -444,9 +444,9 @@ void VSquirrelVM::Detach() const
|
||||
DetourDetach((LPVOID*)&v_Script_LoadScript, &Script_LoadScript);
|
||||
|
||||
#ifndef DEDICATED
|
||||
DetourDetach((LPVOID*)&v_CSquirrelVM_CompileUICLScripts, &CSquirrelVM_CompileUICLScripts);
|
||||
DetourDetach((LPVOID*)&v_CSquirrelVM_CompileClientScripts, &CSquirrelVM::CompileClientScripts);
|
||||
#endif
|
||||
#ifndef CLIENT_DLL
|
||||
DetourDetach((LPVOID*)&v_CSquirrelVM_CompileSVScripts, &CSquirrelVM_CompileSVScripts);
|
||||
DetourDetach((LPVOID*)&v_CSquirrelVM_CompileServerScripts, &CSquirrelVM::CompileServerScripts);
|
||||
#endif
|
||||
}
|
||||
|
@ -49,15 +49,17 @@ static_assert(sizeof(ScriptFunctionBinding_t) == 0x68);
|
||||
class CSquirrelVM
|
||||
{
|
||||
public:
|
||||
HSQUIRRELVM GetVM() const
|
||||
{
|
||||
return m_sqVM;
|
||||
}
|
||||
FORCEINLINE HSQUIRRELVM GetVM() const { return m_sqVM; }
|
||||
FORCEINLINE SQCONTEXT GetContext() const { return m_iContext; }
|
||||
|
||||
SQCONTEXT GetContext() const
|
||||
{
|
||||
return m_iContext;
|
||||
}
|
||||
void CompileModScripts();
|
||||
|
||||
#ifndef DEDICATED
|
||||
static bool CompileClientScripts(CSquirrelVM* vm);
|
||||
#endif
|
||||
#ifndef CLIENT_DLL
|
||||
static bool CompileServerScripts(int numPrecompiled);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SQChar pad0[0x8];
|
||||
@ -97,8 +99,8 @@ inline CMemory p_Script_LoadScript;
|
||||
inline auto v_Script_LoadScript = p_Script_LoadScript.RCast<SQBool(*)(HSQUIRRELVM v, const SQChar* path, const SQChar* name, SQInteger flags)>();
|
||||
|
||||
#ifndef DEDICATED
|
||||
inline CMemory p_CSquirrelVM_CompileUICLScripts;
|
||||
inline auto v_CSquirrelVM_CompileUICLScripts = p_CSquirrelVM_CompileUICLScripts.RCast<__int64(__fastcall*)(CSquirrelVM* vm)>();
|
||||
inline CMemory p_CSquirrelVM_CompileClientScripts;
|
||||
inline auto v_CSquirrelVM_CompileClientScripts = p_CSquirrelVM_CompileClientScripts.RCast<bool(__fastcall*)(CSquirrelVM* vm)>();
|
||||
|
||||
inline CMemory p_CSquirrelVM_CompileScriptsFromArray_UICL;
|
||||
inline auto v_CSquirrelVM_CompileScriptsFromArray_UICL = p_CSquirrelVM_CompileScriptsFromArray_UICL.RCast<bool(__fastcall*)(CSquirrelVM* vm, SQCONTEXT context, char** scriptArray, int scriptCount)>();
|
||||
@ -108,8 +110,8 @@ inline auto v_Script_SetCompilingVM_UICL = p_Script_SetCompilingVM_UICL.RCast<vo
|
||||
#endif
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
inline CMemory p_CSquirrelVM_CompileSVScripts;
|
||||
inline auto v_CSquirrelVM_CompileSVScripts = p_CSquirrelVM_CompileSVScripts.RCast<__int64(__fastcall*)(__int64 a1)>();
|
||||
inline CMemory p_CSquirrelVM_CompileServerScripts;
|
||||
inline auto v_CSquirrelVM_CompileServerScripts = p_CSquirrelVM_CompileServerScripts.RCast<bool(__fastcall*)(int numPrecompiled)>();
|
||||
|
||||
inline CMemory p_CSquirrelVM_CompileScriptsFromArray_SV;
|
||||
inline auto v_CSquirrelVM_CompileScriptsFromArray_SV = p_CSquirrelVM_CompileScriptsFromArray_SV.RCast<bool(__fastcall*)(CSquirrelVM* vm, SQCONTEXT context, char** scriptArray, int scriptCount)>();
|
||||
@ -182,8 +184,8 @@ class VSquirrelVM : public IDetour
|
||||
|
||||
#ifndef DEDICATED
|
||||
// cl/ui scripts.rson compiling
|
||||
p_CSquirrelVM_CompileUICLScripts = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 88 05 ? ? ? ? 33 C0").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileUICLScripts = p_CSquirrelVM_CompileUICLScripts.RCast<__int64(__fastcall*)(CSquirrelVM * vm)>();
|
||||
p_CSquirrelVM_CompileClientScripts = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 88 05 ? ? ? ? 33 C0").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileClientScripts = p_CSquirrelVM_CompileClientScripts.RCast<bool(__fastcall*)(CSquirrelVM*)>();
|
||||
|
||||
p_CSquirrelVM_CompileScriptsFromArray_UICL = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 44 0F B6 F0 48 85 DB").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileScriptsFromArray_UICL = p_CSquirrelVM_CompileScriptsFromArray_UICL.RCast<bool(__fastcall*)(CSquirrelVM* vm, SQCONTEXT context, char** scriptArray, int scriptCount)>();
|
||||
@ -194,8 +196,8 @@ class VSquirrelVM : public IDetour
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
// sv scripts.rson compiling
|
||||
p_CSquirrelVM_CompileSVScripts = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 33 DB 88 05 ? ? ? ? ").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileSVScripts = p_CSquirrelVM_CompileSVScripts.RCast<__int64(__fastcall*)(__int64 a1)>();
|
||||
p_CSquirrelVM_CompileServerScripts = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 33 DB 88 05 ? ? ? ? ").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileServerScripts = p_CSquirrelVM_CompileServerScripts.RCast<bool(__fastcall*)(int)>();
|
||||
|
||||
p_CSquirrelVM_CompileScriptsFromArray_SV = g_GameDll.FindPatternSIMD("E8 ? ? ? ? 0F B6 F0 48 85 DB").FollowNearCallSelf();
|
||||
v_CSquirrelVM_CompileScriptsFromArray_SV = p_CSquirrelVM_CompileScriptsFromArray_SV.RCast<bool(__fastcall*)(CSquirrelVM* vm, SQCONTEXT context, char** scriptArray, int scriptCount)>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user