mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Remove preprocessor directives
These preprocessor directives are invalid, as 'vscript' gets compiled as a standalone library. Compile everything (this doesn't cause an issue if its on the server or client).
This commit is contained in:
parent
3a4ce7cf02
commit
ab3abce664
@ -12,7 +12,6 @@
|
|||||||
#include "game/shared/vscript_shared.h"
|
#include "game/shared/vscript_shared.h"
|
||||||
#include "pluginsystem/modsystem.h"
|
#include "pluginsystem/modsystem.h"
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: registers script functions in SERVER context
|
// Purpose: registers script functions in SERVER context
|
||||||
// Input : *s -
|
// Input : *s -
|
||||||
@ -40,9 +39,7 @@ void Script_RegisterServerFunctions(CSquirrelVM* s)
|
|||||||
|
|
||||||
s->RegisterFunction("IsDedicated", "Script_IsDedicated", "Returns whether this is a dedicated server", "bool", "", &VScriptCode::SERVER::IsDedicated);
|
s->RegisterFunction("IsDedicated", "Script_IsDedicated", "Returns whether this is a dedicated server", "bool", "", &VScriptCode::SERVER::IsDedicated);
|
||||||
}
|
}
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
|
|
||||||
#ifndef DEDICATED
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: registers script functions in CLIENT context
|
// Purpose: registers script functions in CLIENT context
|
||||||
// Input : *s -
|
// Input : *s -
|
||||||
@ -94,7 +91,7 @@ void Script_RegisterUIFunctions(CSquirrelVM* s)
|
|||||||
s->RegisterFunction("GetHiddenServerName", "Script_GetHiddenServerName", "Gets hidden server name by token", "string", "string", &VScriptCode::UI::GetHiddenServerName);
|
s->RegisterFunction("GetHiddenServerName", "Script_GetHiddenServerName", "Gets hidden server name by token", "string", "string", &VScriptCode::UI::GetHiddenServerName);
|
||||||
s->RegisterFunction("GetAvailableMaps", "Script_GetAvailableMaps", "Gets an array of all available maps", "array< string >", "", &VScriptCode::SHARED::GetAvailableMaps);
|
s->RegisterFunction("GetAvailableMaps", "Script_GetAvailableMaps", "Gets an array of all available maps", "array< string >", "", &VScriptCode::SHARED::GetAvailableMaps);
|
||||||
s->RegisterFunction("GetAvailablePlaylists", "Script_GetAvailablePlaylists", "Gets an array of all available playlists", "array< string >", "", &VScriptCode::SHARED::GetAvailablePlaylists);
|
s->RegisterFunction("GetAvailablePlaylists", "Script_GetAvailablePlaylists", "Gets an array of all available playlists", "array< string >", "", &VScriptCode::SHARED::GetAvailablePlaylists);
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
s->RegisterFunction("KickPlayerByName", "Script_KickPlayerByName", "Kicks a player from the server by name", "void", "string", &VScriptCode::SHARED::KickPlayerByName);
|
s->RegisterFunction("KickPlayerByName", "Script_KickPlayerByName", "Kicks a player from the server by name", "void", "string", &VScriptCode::SHARED::KickPlayerByName);
|
||||||
s->RegisterFunction("KickPlayerById", "Script_KickPlayerById", "Kicks a player from the server by handle or nucleus id", "void", "string", &VScriptCode::SHARED::KickPlayerById);
|
s->RegisterFunction("KickPlayerById", "Script_KickPlayerById", "Kicks a player from the server by handle or nucleus id", "void", "string", &VScriptCode::SHARED::KickPlayerById);
|
||||||
|
|
||||||
@ -102,11 +99,10 @@ void Script_RegisterUIFunctions(CSquirrelVM* s)
|
|||||||
s->RegisterFunction("BanPlayerById", "Script_BanPlayerById", "Bans a player from the server by handle or nucleus id", "void", "string", &VScriptCode::SHARED::BanPlayerById);
|
s->RegisterFunction("BanPlayerById", "Script_BanPlayerById", "Bans a player from the server by handle or nucleus id", "void", "string", &VScriptCode::SHARED::BanPlayerById);
|
||||||
|
|
||||||
s->RegisterFunction("UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VScriptCode::SHARED::UnbanPlayer);
|
s->RegisterFunction("UnbanPlayer", "Script_UnbanPlayer", "Unbans a player from the server by nucleus id or ip address", "void", "string", &VScriptCode::SHARED::UnbanPlayer);
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
s->RegisterFunction("ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VScriptCode::SHARED::ShutdownHostGame);
|
s->RegisterFunction("ShutdownHostGame", "Script_ShutdownHostGame", "Shuts the local host game down", "void", "", &VScriptCode::SHARED::ShutdownHostGame);
|
||||||
s->RegisterFunction("IsClientDLL", "Script_IsClientDLL", "Returns whether this build is client only", "bool", "", &VScriptCode::SHARED::IsClientDLL);
|
s->RegisterFunction("IsClientDLL", "Script_IsClientDLL", "Returns whether this build is client only", "bool", "", &VScriptCode::SHARED::IsClientDLL);
|
||||||
}
|
}
|
||||||
#endif // !DEDICATED
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: Returns the script VM pointer by context
|
// Purpose: Returns the script VM pointer by context
|
||||||
@ -116,16 +112,12 @@ CSquirrelVM* Script_GetScriptHandle(const SQCONTEXT context)
|
|||||||
{
|
{
|
||||||
switch (context)
|
switch (context)
|
||||||
{
|
{
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
case SQCONTEXT::SERVER:
|
case SQCONTEXT::SERVER:
|
||||||
return g_pServerScript;
|
return g_pServerScript;
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
#ifndef DEDICATED
|
|
||||||
case SQCONTEXT::CLIENT:
|
case SQCONTEXT::CLIENT:
|
||||||
return g_pClientScript;
|
return g_pClientScript;
|
||||||
case SQCONTEXT::UI:
|
case SQCONTEXT::UI:
|
||||||
return g_pUIScript;
|
return g_pUIScript;
|
||||||
#endif // !DEDICATED
|
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -194,21 +186,17 @@ SQBool Script_PrecompileScripts(CSquirrelVM* vm)
|
|||||||
|
|
||||||
switch (context)
|
switch (context)
|
||||||
{
|
{
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
case SQCONTEXT::SERVER:
|
case SQCONTEXT::SERVER:
|
||||||
{
|
{
|
||||||
result = v_Script_PrecompileServerScripts(vm);
|
result = v_Script_PrecompileServerScripts(vm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifndef DEDICATED
|
|
||||||
case SQCONTEXT::CLIENT:
|
case SQCONTEXT::CLIENT:
|
||||||
case SQCONTEXT::UI:
|
case SQCONTEXT::UI:
|
||||||
{
|
{
|
||||||
result = v_Script_PrecompileClientScripts(vm);
|
result = v_Script_PrecompileClientScripts(vm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.End();
|
timer.End();
|
||||||
@ -217,19 +205,15 @@ SQBool Script_PrecompileScripts(CSquirrelVM* vm)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
SQBool Script_PrecompileServerScripts(CSquirrelVM* vm)
|
SQBool Script_PrecompileServerScripts(CSquirrelVM* vm)
|
||||||
{
|
{
|
||||||
return Script_PrecompileScripts(g_pServerScript);
|
return Script_PrecompileScripts(g_pServerScript);
|
||||||
}
|
}
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
|
|
||||||
#ifndef DEDICATED
|
|
||||||
SQBool Script_PrecompileClientScripts(CSquirrelVM* vm)
|
SQBool Script_PrecompileClientScripts(CSquirrelVM* vm)
|
||||||
{
|
{
|
||||||
return Script_PrecompileScripts(vm);
|
return Script_PrecompileScripts(vm);
|
||||||
}
|
}
|
||||||
#endif // !DEDICATED
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
// Purpose: Compiles and executes input code on target VM by context
|
// Purpose: Compiles and executes input code on target VM by context
|
||||||
@ -283,22 +267,14 @@ void VScript::Attach() const
|
|||||||
{
|
{
|
||||||
DetourAttach((LPVOID*)&v_Script_LoadScriptList, &Script_LoadScriptList);
|
DetourAttach((LPVOID*)&v_Script_LoadScriptList, &Script_LoadScriptList);
|
||||||
DetourAttach((LPVOID*)&v_Script_LoadScriptFile, &Script_LoadScriptFile);
|
DetourAttach((LPVOID*)&v_Script_LoadScriptFile, &Script_LoadScriptFile);
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
DetourAttach((LPVOID*)&v_Script_PrecompileServerScripts, &Script_PrecompileServerScripts);
|
DetourAttach((LPVOID*)&v_Script_PrecompileServerScripts, &Script_PrecompileServerScripts);
|
||||||
#endif
|
|
||||||
#ifndef DEDICATED
|
|
||||||
DetourAttach((LPVOID*)&v_Script_PrecompileClientScripts, &Script_PrecompileClientScripts);
|
DetourAttach((LPVOID*)&v_Script_PrecompileClientScripts, &Script_PrecompileClientScripts);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
void VScript::Detach() const
|
void VScript::Detach() const
|
||||||
{
|
{
|
||||||
DetourDetach((LPVOID*)&v_Script_LoadScriptList, &Script_LoadScriptList);
|
DetourDetach((LPVOID*)&v_Script_LoadScriptList, &Script_LoadScriptList);
|
||||||
DetourDetach((LPVOID*)&v_Script_LoadScriptFile, &Script_LoadScriptFile);
|
DetourDetach((LPVOID*)&v_Script_LoadScriptFile, &Script_LoadScriptFile);
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
DetourDetach((LPVOID*)&v_Script_PrecompileServerScripts, &Script_PrecompileServerScripts);
|
DetourDetach((LPVOID*)&v_Script_PrecompileServerScripts, &Script_PrecompileServerScripts);
|
||||||
#endif
|
|
||||||
#ifndef DEDICATED
|
|
||||||
DetourDetach((LPVOID*)&v_Script_PrecompileClientScripts, &Script_PrecompileClientScripts);
|
DetourDetach((LPVOID*)&v_Script_PrecompileClientScripts, &Script_PrecompileClientScripts);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -22,21 +22,17 @@ inline auto v_Script_LoadScriptFile = p_Script_LoadScriptFile.RCast<SQBool(*)(HS
|
|||||||
inline CMemory p_Script_ParseScriptList;
|
inline CMemory p_Script_ParseScriptList;
|
||||||
inline auto v_Script_ParseScriptList = p_Script_ParseScriptList.RCast<SQBool(__fastcall*)(SQCONTEXT ctx, const char* scriptListPath, RSON::Node_t* rson, char** scriptArray, int* pScriptCount, char** precompiledScriptArray, int precompiledScriptCount)>();
|
inline auto v_Script_ParseScriptList = p_Script_ParseScriptList.RCast<SQBool(__fastcall*)(SQCONTEXT ctx, const char* scriptListPath, RSON::Node_t* rson, char** scriptArray, int* pScriptCount, char** precompiledScriptArray, int precompiledScriptCount)>();
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
inline CMemory p_Script_PrecompileServerScripts;
|
inline CMemory p_Script_PrecompileServerScripts;
|
||||||
inline auto v_Script_PrecompileServerScripts = p_Script_PrecompileServerScripts.RCast<SQBool(__fastcall*)(CSquirrelVM* vm /*This parameter is not used internally (the client variant does use it)!*/)>();
|
inline auto v_Script_PrecompileServerScripts = p_Script_PrecompileServerScripts.RCast<SQBool(__fastcall*)(CSquirrelVM* vm /*This parameter is not used internally (the client variant does use it)!*/)>();
|
||||||
|
|
||||||
inline CMemory p_Script_SetServerCompiler;
|
inline CMemory p_Script_SetServerCompiler;
|
||||||
inline auto v_Script_SetServerPrecompiler = p_Script_SetServerCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
inline auto v_Script_SetServerPrecompiler = p_Script_SetServerCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DEDICATED
|
|
||||||
inline CMemory p_Script_PrecompileClientScripts;
|
inline CMemory p_Script_PrecompileClientScripts;
|
||||||
inline auto v_Script_PrecompileClientScripts = p_Script_PrecompileClientScripts.RCast<SQBool(__fastcall*)(CSquirrelVM* vm)>();
|
inline auto v_Script_PrecompileClientScripts = p_Script_PrecompileClientScripts.RCast<SQBool(__fastcall*)(CSquirrelVM* vm)>();
|
||||||
|
|
||||||
inline CMemory p_Script_SetClientCompiler;
|
inline CMemory p_Script_SetClientCompiler;
|
||||||
inline auto v_Script_SetClientPrecompiler = p_Script_SetClientCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
inline auto v_Script_SetClientPrecompiler = p_Script_SetClientCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
||||||
#endif
|
|
||||||
|
|
||||||
void Script_RegisterServerFunctions(CSquirrelVM* s);
|
void Script_RegisterServerFunctions(CSquirrelVM* s);
|
||||||
void Script_RegisterClientFunctions(CSquirrelVM* s);
|
void Script_RegisterClientFunctions(CSquirrelVM* s);
|
||||||
@ -57,14 +53,10 @@ class VScript : public IDetour
|
|||||||
LogFunAdr("Script_LoadScriptList", p_Script_LoadScriptList.GetPtr());
|
LogFunAdr("Script_LoadScriptList", p_Script_LoadScriptList.GetPtr());
|
||||||
LogFunAdr("Script_LoadScriptFile", p_Script_LoadScriptFile.GetPtr());
|
LogFunAdr("Script_LoadScriptFile", p_Script_LoadScriptFile.GetPtr());
|
||||||
LogFunAdr("Script_ParseScriptList", p_Script_ParseScriptList.GetPtr());
|
LogFunAdr("Script_ParseScriptList", p_Script_ParseScriptList.GetPtr());
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
LogFunAdr("Script_PrecompileServerInit", p_Script_PrecompileServerScripts.GetPtr());
|
LogFunAdr("Script_PrecompileServerInit", p_Script_PrecompileServerScripts.GetPtr());
|
||||||
LogFunAdr("Script_SetServerCompiler", p_Script_SetServerCompiler.GetPtr());
|
LogFunAdr("Script_SetServerCompiler", p_Script_SetServerCompiler.GetPtr());
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
#ifndef DEDICATED
|
|
||||||
LogFunAdr("Script_PrecompileClientInit", p_Script_PrecompileClientScripts.GetPtr());
|
LogFunAdr("Script_PrecompileClientInit", p_Script_PrecompileClientScripts.GetPtr());
|
||||||
LogFunAdr("Script_SetClientCompiler", p_Script_SetClientCompiler.GetPtr());
|
LogFunAdr("Script_SetClientCompiler", p_Script_SetClientCompiler.GetPtr());
|
||||||
#endif // !DEDICATED
|
|
||||||
}
|
}
|
||||||
virtual void GetFun(void) const
|
virtual void GetFun(void) const
|
||||||
{
|
{
|
||||||
@ -77,20 +69,17 @@ class VScript : public IDetour
|
|||||||
#endif
|
#endif
|
||||||
v_Script_LoadScriptFile = p_Script_LoadScriptFile.RCast<SQBool(*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger)>();
|
v_Script_LoadScriptFile = p_Script_LoadScriptFile.RCast<SQBool(*)(HSQUIRRELVM, const SQChar*, const SQChar*, SQInteger)>();
|
||||||
|
|
||||||
#ifndef CLIENT_DLL
|
|
||||||
p_Script_PrecompileServerScripts = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 33 DB 88 05 ?? ?? ?? ??").FollowNearCallSelf();
|
p_Script_PrecompileServerScripts = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 33 DB 88 05 ?? ?? ?? ??").FollowNearCallSelf();
|
||||||
v_Script_PrecompileServerScripts = p_Script_PrecompileServerScripts.RCast<SQBool(__fastcall*)(CSquirrelVM*)>();
|
v_Script_PrecompileServerScripts = p_Script_PrecompileServerScripts.RCast<SQBool(__fastcall*)(CSquirrelVM*)>();
|
||||||
|
|
||||||
p_Script_SetServerCompiler = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 84 24 ?? ?? ?? ?? 44 89 64 24 ?? 4C 89 64 24 ?? 4C 8D 8C 24 ?? ?? ?? ?? 4C 8B C5").FollowNearCallSelf();
|
p_Script_SetServerCompiler = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 84 24 ?? ?? ?? ?? 44 89 64 24 ?? 4C 89 64 24 ?? 4C 8D 8C 24 ?? ?? ?? ?? 4C 8B C5").FollowNearCallSelf();
|
||||||
v_Script_SetServerPrecompiler = p_Script_SetServerCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
v_Script_SetServerPrecompiler = p_Script_SetServerCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
||||||
#endif // !CLIENT_DLL
|
|
||||||
#ifndef DEDICATED
|
|
||||||
p_Script_PrecompileClientScripts = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 88 05 ?? ?? ?? ?? 33 C0").FollowNearCallSelf();
|
p_Script_PrecompileClientScripts = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 88 05 ?? ?? ?? ?? 33 C0").FollowNearCallSelf();
|
||||||
v_Script_PrecompileClientScripts = p_Script_PrecompileClientScripts.RCast<SQBool(__fastcall*)(CSquirrelVM*)>();
|
v_Script_PrecompileClientScripts = p_Script_PrecompileClientScripts.RCast<SQBool(__fastcall*)(CSquirrelVM*)>();
|
||||||
|
|
||||||
p_Script_SetClientCompiler = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 84 24 ?? ?? ?? ?? 44 89 64 24 ?? 4C 89 64 24 ?? 4C 8D 8C 24 ?? ?? ?? ?? 4C 8B C6").FollowNearCallSelf();
|
p_Script_SetClientCompiler = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8D 84 24 ?? ?? ?? ?? 44 89 64 24 ?? 4C 89 64 24 ?? 4C 8D 8C 24 ?? ?? ?? ?? 4C 8B C6").FollowNearCallSelf();
|
||||||
v_Script_SetClientPrecompiler = p_Script_SetClientCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
v_Script_SetClientPrecompiler = p_Script_SetClientCompiler.RCast<void(__fastcall*)(SQCONTEXT ctx, RSON::Node_t* rson)>();
|
||||||
#endif // !DEDICATED
|
|
||||||
|
|
||||||
p_Script_ParseScriptList = g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 55 41 56");
|
p_Script_ParseScriptList = g_GameDll.FindPatternSIMD("4C 89 4C 24 ?? 55 41 56");
|
||||||
v_Script_ParseScriptList = p_Script_ParseScriptList.RCast<SQBool(__fastcall*)(SQCONTEXT, const SQChar*, RSON::Node_t*, char**, int*, char**, int)>();
|
v_Script_ParseScriptList = p_Script_ParseScriptList.RCast<SQBool(__fastcall*)(SQCONTEXT, const SQChar*, RSON::Node_t*, char**, int*, char**, int)>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user