CSquirrelVM: define "DEVELOPER" at the earliest stage possible

'Script_DestroySignalEntryListHead' is the last function to be called before 'init.nut' is loaded and parsed. Defining "DEVELOPER" with value of "developer" convar allows us to utilize this constant in 'init.nut'.
This commit is contained in:
Kawe Mazidjatari 2022-09-22 15:26:21 +02:00
parent eec4d9598e
commit 8e880b8052
2 changed files with 31 additions and 12 deletions

View File

@ -149,8 +149,6 @@ SQRESULT Script_InitializeCLGlobalStructs(HSQUIRRELVM v, SQCONTEXT context)
Script_RegisterClientFunctions(g_pClientScript.GetValue<CSquirrelVM*>());
if (context == SQCONTEXT::UI)
Script_RegisterUIFunctions(g_pUIScript.GetValue<CSquirrelVM*>());
Script_RegisterConstant(Script_GetContextObject(context), "DEVELOPER", developer->GetInt());
return results;
}
#endif // !DEDICATED
@ -164,7 +162,6 @@ void Script_InitializeSVGlobalStructs(HSQUIRRELVM v)
{
v_Script_InitializeSVGlobalStructs(v);
Script_RegisterServerFunctions(Script_GetContextObject(SQCONTEXT::SERVER));
Script_RegisterConstant(Script_GetContextObject(SQCONTEXT::SERVER), "DEVELOPER", developer->GetInt());
}
//---------------------------------------------------------------------------------
@ -237,6 +234,20 @@ CSquirrelVM* Script_GetContextObject(const SQCONTEXT context)
}
}
//---------------------------------------------------------------------------------
// Purpose: destroys the signal entry list head
// Input : *s -
// v -
// f -
// Output : true on success, false otherwise
//---------------------------------------------------------------------------------
SQBool Script_DestroySignalEntryListHead(CSquirrelVM* s, HSQUIRRELVM v, SQFloat f)
{
SQBool result = v_Script_DestroySignalEntryListHead(s, v, f);
Script_RegisterConstant(s, "DEVELOPER", developer->GetInt());
return result;
}
//---------------------------------------------------------------------------------
// Purpose: prints the global include file the compiler loads for loading scripts
// Input : *szRsonName -
@ -325,6 +336,7 @@ void SQScript_Attach()
DetourAttach((LPVOID*)&v_Script_CreateClientVM, &Script_CreateClientVM);
DetourAttach((LPVOID*)&v_Script_CreateUIVM, &Script_CreateUIVM);
#endif // !DEDICATED
DetourAttach((LPVOID*)&v_Script_DestroySignalEntryListHead, &Script_DestroySignalEntryListHead);
DetourAttach((LPVOID*)&v_Script_LoadRson, &Script_LoadRson);
DetourAttach((LPVOID*)&v_Script_LoadScript, &Script_LoadScript);
}
@ -343,6 +355,7 @@ void SQScript_Detach()
DetourDetach((LPVOID*)&v_Script_CreateClientVM, &Script_CreateClientVM);
DetourDetach((LPVOID*)&v_Script_CreateUIVM, &Script_CreateUIVM);
#endif // !DEDICATED
DetourDetach((LPVOID*)&v_Script_DestroySignalEntryListHead, &Script_DestroySignalEntryListHead);
DetourDetach((LPVOID*)&v_Script_LoadRson, &Script_LoadRson);
DetourDetach((LPVOID*)&v_Script_LoadScript, &Script_LoadScript);
}

View File

@ -89,6 +89,9 @@ inline auto v_Script_CreateClientVM = p_Script_CreateClientVM.RCast<SQBool(*)(CH
inline CMemory p_Script_CreateUIVM;
inline auto v_Script_CreateUIVM = p_Script_CreateUIVM.RCast<SQBool(*)(void)>();
#endif // !DEDICATED
inline CMemory p_Script_DestroySignalEntryListHead;
inline auto v_Script_DestroySignalEntryListHead = p_Script_DestroySignalEntryListHead.RCast<SQBool(*)(CSquirrelVM* s, HSQUIRRELVM v, SQFloat f)>();
inline CMemory p_Script_LoadRson;
inline auto v_Script_LoadRson = p_Script_LoadRson.RCast<SQInteger(*)(const SQChar* szRsonName)>();
@ -147,6 +150,7 @@ class VSquirrelVM : public IDetour
spdlog::debug("| FUN: Script_CreateClientVM : {:#18x} |\n", p_Script_CreateClientVM.GetPtr());
spdlog::debug("| FUN: Script_CreateUIVM : {:#18x} |\n", p_Script_CreateUIVM.GetPtr());
#endif // !DEDICATED
spdlog::debug("| FUN: Script_DestroySignalEntryListHead : {:#18x} |\n", p_Script_DestroySignalEntryListHead.GetPtr());
spdlog::debug("| FUN: Script_LoadRson : {:#18x} |\n", p_Script_LoadRson.GetPtr());
spdlog::debug("| FUN: Script_LoadScript : {:#18x} |\n", p_Script_LoadScript.GetPtr());
#ifndef CLIENT_DLL
@ -181,29 +185,31 @@ class VSquirrelVM : public IDetour
#if !defined (DEDICATED)
p_Script_CreateUIVM = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x48\x83\xEC\x20\x48\x8B\x1D\x00\x00\x00\x00\xC6\x05\x00\x00\x00\x00\x00"), "xxxxxxxxx????xx?????");
#endif // !DEDICATED
p_Script_DestroySignalEntryListHead = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x50\x44\x8B\x42\x78"), "xxxx?xxxx?xxxxxxxxxxxx");
p_Script_LoadRson = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x4C\x8B\xDC\x49\x89\x5B\x08\x57\x48\x81\xEC\xA0\x00\x00\x00\x33"), "xxxxxxxxxxxxxxxx");
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
p_Script_LoadScript = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x48\x89\x4C\x24\x08\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\x6C"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
p_Script_LoadScript = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\xC4\x48\x89\x48\x08\x55\x41\x56\x48\x8D\x68"), "xxxxxxxxxxxxx");
#endif
v_Script_RegisterConstant = p_Script_RegisterConstant.RCast<SQRESULT(*)(CSquirrelVM*, const SQChar*, SQInteger)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 4C 8B*/
v_Script_RegisterFunction = p_Script_RegisterFunction.RCast<SQRESULT(*)(CSquirrelVM*, ScriptFunctionBinding_t*, SQInteger)>(); /*48 83 EC 38 45 0F B6 C8*/
v_Script_RegisterConstant = p_Script_RegisterConstant.RCast<SQRESULT(*)(CSquirrelVM*, const SQChar*, SQInteger)>(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 4C 8B*/
v_Script_RegisterFunction = p_Script_RegisterFunction.RCast<SQRESULT(*)(CSquirrelVM*, ScriptFunctionBinding_t*, SQInteger)>(); /*48 83 EC 38 45 0F B6 C8*/
#if !defined (CLIENT_DLL)
v_Script_InitializeSVGlobalStructs = p_Script_InitializeSVGlobalStructs.RCast<SQRESULT(*)(HSQUIRRELVM)>(); /*48 89 74 24 ?? 57 48 83 EC 30 48 8B 3D ?? ?? ?? ?? 48 8B F1*/
v_Script_InitializeSVGlobalStructs = p_Script_InitializeSVGlobalStructs.RCast<SQRESULT(*)(HSQUIRRELVM)>(); /*48 89 74 24 ?? 57 48 83 EC 30 48 8B 3D ?? ?? ?? ?? 48 8B F1*/
#endif // !CLIENT_DLL
#if !defined (DEDICATED)
v_Script_InitializeCLGlobalStructs = p_Script_InitializeCLGlobalStructs.RCast<SQRESULT(*)(HSQUIRRELVM, SQCONTEXT)>(); /*48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 48 63 C2 48 8D 3D ?? ?? ?? ??*/
v_Script_InitializeCLGlobalStructs = p_Script_InitializeCLGlobalStructs.RCast<SQRESULT(*)(HSQUIRRELVM, SQCONTEXT)>(); /*48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 30 48 63 C2 48 8D 3D ?? ?? ?? ??*/
#endif // !DEDICATED
#if !defined (CLIENT_DLL)
v_Script_CreateServerVM = p_Script_CreateServerVM.RCast<SQBool(*)(void)>(); /*40 53 56 48 83 EC 48 48 8D 0D ?? ?? ?? ??*/
v_Script_CreateServerVM = p_Script_CreateServerVM.RCast<SQBool(*)(void)>(); /*40 53 56 48 83 EC 48 48 8D 0D ?? ?? ?? ??*/
#endif // !CLIENT_DLL
#if !defined (DEDICATED)
v_Script_CreateClientVM = p_Script_CreateClientVM.RCast<SQBool(*)(CHLClient*)>(); /*40 53 41 57 48 83 EC 68 48 83 3D ?? ?? ?? ?? ??*/
v_Script_CreateUIVM = p_Script_CreateUIVM.RCast<SQBool(*)(void)>(); /*40 53 48 83 EC 20 48 8B 1D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??*/
v_Script_CreateClientVM = p_Script_CreateClientVM.RCast<SQBool(*)(CHLClient*)>(); /*40 53 41 57 48 83 EC 68 48 83 3D ?? ?? ?? ?? ??*/
v_Script_CreateUIVM = p_Script_CreateUIVM.RCast<SQBool(*)(void)>(); /*40 53 48 83 EC 20 48 8B 1D ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ??*/
#endif // !DEDICATED
v_Script_LoadRson = p_Script_LoadRson.RCast<SQInteger(*)(const SQChar*)>(); /*4C 8B DC 49 89 5B 08 57 48 81 EC A0 00 00 00 33*/
v_Script_LoadScript = p_Script_LoadScript.RCast<SQBool(*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger)>(); /*48 8B C4 48 89 48 08 55 41 56 48 8D 68*/
v_Script_DestroySignalEntryListHead = p_Script_DestroySignalEntryListHead.RCast<SQBool(*)(CSquirrelVM*, HSQUIRRELVM, SQFloat)>();/*48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 50 44 8B 42*/
v_Script_LoadRson = p_Script_LoadRson.RCast<SQInteger(*)(const SQChar*)>(); /*4C 8B DC 49 89 5B 08 57 48 81 EC A0 00 00 00 33*/
v_Script_LoadScript = p_Script_LoadScript.RCast<SQBool(*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger)>(); /*48 8B C4 48 89 48 08 55 41 56 48 8D 68*/
}
virtual void GetVar(void) const
{