Implemented SERVER, CLIENT and UI script commands

User can now execute script on the SERVER, CLIENT and UI vm's through the SDK
This commit is contained in:
Kawe Mazidjatari 2022-03-30 22:54:33 +02:00
parent ecb2bc54ad
commit 79f99970c6
10 changed files with 266 additions and 92 deletions

View File

@ -8,68 +8,78 @@
#include "squirrel/sqapi.h" #include "squirrel/sqapi.h"
#include "squirrel/sqtype.h" #include "squirrel/sqtype.h"
char* sq_getstring(HSQUIRRELVM* v, SQInteger i) SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i)
{ {
std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v); std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v);
return *(char**)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8) + 0x40; return *(char**)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8) + 0x40;
} }
int sq_getinteger(HSQUIRRELVM* v, SQInteger i) SQInteger sq_getinteger(HSQUIRRELVM v, SQInteger i)
{ {
std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v); std::uintptr_t thisptr = reinterpret_cast<std::uintptr_t>(v);
return *(int*)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8); return *(SQInteger*)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8);
} }
void sq_pushbool(HSQUIRRELVM* v, SQBool b) SQRESULT sq_pushroottable(HSQUIRRELVM v)
{
return v_sq_pushroottable(v);
}
void sq_pushbool(HSQUIRRELVM v, SQBool b)
{ {
v_sq_pushbool(v, b); v_sq_pushbool(v, b);
} }
void sq_pushstring(HSQUIRRELVM* v, const SQChar* s, SQInteger len) void sq_pushstring(HSQUIRRELVM v, const SQChar* s, SQInteger len)
{ {
v_sq_pushstring(v, s, len); v_sq_pushstring(v, s, len);
} }
void sq_pushinteger(HSQUIRRELVM* v, SQInteger val) void sq_pushinteger(HSQUIRRELVM v, SQInteger val)
{ {
v_sq_pushinteger(v, val); v_sq_pushinteger(v, val);
} }
void sq_pushconstant(HSQUIRRELVM* v, const SQChar* name, SQInteger val) void sq_pushconstant(HSQUIRRELVM v, const SQChar* name, SQInteger val)
{ {
v_sq_pushconstant(v, name, val); v_sq_pushconstant(v, name, val);
} }
void sq_newarray(HSQUIRRELVM* v, SQInteger size) void sq_newarray(HSQUIRRELVM v, SQInteger size)
{ {
v_sq_newarray(v, size); v_sq_newarray(v, size);
} }
void sq_arrayappend(HSQUIRRELVM* v, SQInteger idx) void sq_arrayappend(HSQUIRRELVM v, SQInteger idx)
{ {
v_sq_arrayappend(v, idx); v_sq_arrayappend(v, idx);
} }
void sq_newtable(HSQUIRRELVM* v) void sq_newtable(HSQUIRRELVM v)
{ {
v_sq_newtable(v); v_sq_newtable(v);
} }
void sq_newslot(HSQUIRRELVM* v, SQInteger idx) void sq_newslot(HSQUIRRELVM v, SQInteger idx)
{ {
v_sq_newslot(v, idx); v_sq_newslot(v, idx);
} }
void sq_pushstructure(HSQUIRRELVM* v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) void sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2)
{ {
v_sq_pushstructure(v, name, member, codeclass1, codeclass2); v_sq_pushstructure(v, name, member, codeclass1, codeclass2);
} }
SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState bufferState, const SQChar* buffer, SQCONTEXT context) SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger level)
{ {
return v_sq_compilebuffer(v, bufferState, buffer, context); return v_sq_compilebuffer(v, bufferState, buffer, level);
}
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)
{
return v_sq_call(v, params, retval, raiseerror);
} }
void SQAPI_Attach() void SQAPI_Attach()
@ -84,6 +94,7 @@ void SQAPI_Attach()
DetourAttach((LPVOID*)&v_sq_newslot, &sq_newslot); DetourAttach((LPVOID*)&v_sq_newslot, &sq_newslot);
DetourAttach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure); DetourAttach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure);
DetourAttach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer); DetourAttach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer);
DetourAttach((LPVOID*)&v_sq_call, &sq_call);
} }
void SQAPI_Detach() void SQAPI_Detach()
@ -98,4 +109,5 @@ void SQAPI_Detach()
DetourDetach((LPVOID*)&v_sq_newslot, &sq_newslot); DetourDetach((LPVOID*)&v_sq_newslot, &sq_newslot);
DetourDetach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure); DetourDetach((LPVOID*)&v_sq_pushstructure, &sq_pushstructure);
DetourDetach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer); DetourDetach((LPVOID*)&v_sq_compilebuffer, &sq_compilebuffer);
DetourDetach((LPVOID*)&v_sq_call, &sq_call);
} }

View File

@ -4,55 +4,65 @@
namespace namespace
{ {
/* ==== SQUIRREL ======================================================================================================================================================== */ /* ==== SQUIRREL ======================================================================================================================================================== */
ADDRESS p_sq_pushroottable = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x28\x8B\x51\x00\x44\x8B\xC2", "xxxxxx?xxx");
SQRESULT(*v_sq_pushroottable)(HSQUIRRELVM v) = (SQRESULT(*)(HSQUIRRELVM))p_sq_pushroottable.GetPtr(); /*48 83 EC 28 8B 51 ?? 44 8B C2*/
ADDRESS p_sq_pushbool = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x08\x00\x00\x01\x48", "xxxxxxxxxxxxxxxx"); ADDRESS p_sq_pushbool = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x08\x00\x00\x01\x48", "xxxxxxxxxxxxxxxx");
void (*v_sq_pushbool)(HSQUIRRELVM* v, SQBool b) = (void (*)(HSQUIRRELVM*, SQBool))p_sq_pushbool.GetPtr(); /*48 83 EC 38 33 C0 48 C7 44 24 20 08 00 00 01 48*/ void (*v_sq_pushbool)(HSQUIRRELVM v, SQBool b) = (void (*)(HSQUIRRELVM, SQBool))p_sq_pushbool.GetPtr(); /*48 83 EC 38 33 C0 48 C7 44 24 20 08 00 00 01 48*/
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8C\x00", "xxxxxxxxxxxxxxxx"); ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8C\x00", "xxxxxxxxxxxxxxxx");
void (*v_sq_pushstring)(HSQUIRRELVM* v, const SQChar* string, int len) = (void (*)(HSQUIRRELVM*, const SQChar*, int))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8C 00*/ void (*v_sq_pushstring)(HSQUIRRELVM v, const SQChar* string, int len) = (void (*)(HSQUIRRELVM, const SQChar*, int))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8C 00*/
#elif defined (GAMEDLL_S3) #elif defined (GAMEDLL_S3)
ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8F\x00", "xxxxxxxxxxxxxxxx"); ADDRESS p_sq_pushstring = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x56\x48\x83\xEC\x30\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x8F\x00", "xxxxxxxxxxxxxxxx");
void (*v_sq_pushstring)(HSQUIRRELVM* v, const SQChar* string, SQInteger len) = (void (*)(HSQUIRRELVM*, const SQChar*, SQInteger))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8F 00*/ void (*v_sq_pushstring)(HSQUIRRELVM v, const SQChar* string, SQInteger len) = (void (*)(HSQUIRRELVM, const SQChar*, SQInteger))p_sq_pushstring.GetPtr(); /*40 56 48 83 EC 30 48 8B F1 48 85 D2 0F 84 8F 00*/
#endif #endif
ADDRESS p_sq_pushinteger = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x02\x00\x00\x05\x48", "xxxxxxxxxxxxxxxx"); ADDRESS p_sq_pushinteger = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x83\xEC\x38\x33\xC0\x48\xC7\x44\x24\x20\x02\x00\x00\x05\x48", "xxxxxxxxxxxxxxxx");
void (*v_sq_pushinteger)(HSQUIRRELVM* v, SQInteger val) = (void (*)(HSQUIRRELVM*, SQInteger))p_sq_pushinteger.GetPtr(); /*48 83 EC 38 33 C0 48 C7 44 24 20 02 00 00 05 48*/ void (*v_sq_pushinteger)(HSQUIRRELVM v, SQInteger val) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_pushinteger.GetPtr(); /*48 83 EC 38 33 C0 48 C7 44 24 20 02 00 00 05 48*/
ADDRESS p_sq_pushconstant = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x4C\x8B", "xxxx?xxxx?xxxx?xxxxxxx"); ADDRESS p_sq_pushconstant = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x4C\x8B", "xxxx?xxxx?xxxx?xxxxxxx");
void (*v_sq_pushconstant)(HSQUIRRELVM* v, const SQChar* name, SQInteger val) = (void (*)(HSQUIRRELVM*, const SQChar*, SQInteger))p_sq_pushconstant.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 30 4C 8B*/ void (*v_sq_pushconstant)(HSQUIRRELVM v, const SQChar* name, SQInteger val) = (void (*)(HSQUIRRELVM, const SQChar*, SQInteger))p_sq_pushconstant.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 30 4C 8B*/
ADDRESS p_sq_newarray = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x40", "xxxxxxxxxxxxxxxxxxx"); ADDRESS p_sq_newarray = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x40", "xxxxxxxxxxxxxxxxxxx");
void (*v_sq_newarray)(HSQUIRRELVM* v, SQInteger size) = (void (*)(HSQUIRRELVM*, SQInteger))p_sq_newarray.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 40*/ void (*v_sq_newarray)(HSQUIRRELVM v, SQInteger size) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_newarray.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 40*/
ADDRESS p_sq_arrayappend = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x8B\x41\x00\x48\x8B\xD9\x2B\x41\x00\x83\xF8\x02\x7D", "xxxxxxxx?xxxxx?xxxx"); ADDRESS p_sq_arrayappend = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x8B\x41\x00\x48\x8B\xD9\x2B\x41\x00\x83\xF8\x02\x7D", "xxxxxxxx?xxxxx?xxxx");
void (*v_sq_arrayappend)(HSQUIRRELVM* v, SQInteger idx) = (void (*)(HSQUIRRELVM*, SQInteger))p_sq_arrayappend.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/ void (*v_sq_arrayappend)(HSQUIRRELVM v, SQInteger idx) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_arrayappend.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
ADDRESS p_sq_newtable = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x20", "xxxxxxxxxxxxxxxxxxx"); ADDRESS p_sq_newtable = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x30\x48\x8B\xD9\x48\xC7\x44\x24\x20\x20", "xxxxxxxxxxxxxxxxxxx");
void (*v_sq_newtable)(HSQUIRRELVM* v) = (void (*)(HSQUIRRELVM*))p_sq_newtable.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 20*/ void (*v_sq_newtable)(HSQUIRRELVM v) = (void (*)(HSQUIRRELVM))p_sq_newtable.GetPtr(); /*48 89 5C 24 08 57 48 83 EC 30 48 8B D9 48 C7 44 24 20 20*/
ADDRESS p_sq_newslot = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x30\x44\x8B\x49\x00\x48\x8B\xD9\x41\x8B\xC1", "xxxxxxxxx?xxxxxx"); ADDRESS p_sq_newslot = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x30\x44\x8B\x49\x00\x48\x8B\xD9\x41\x8B\xC1", "xxxxxxxxx?xxxxxx");
void (*v_sq_newslot)(HSQUIRRELVM* v, SQInteger idx) = (void (*)(HSQUIRRELVM*, SQInteger))p_sq_newslot.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/ void (*v_sq_newslot)(HSQUIRRELVM v, SQInteger idx) = (void (*)(HSQUIRRELVM, SQInteger))p_sq_newslot.GetPtr(); /*40 53 48 83 EC 20 8B 41 ?? 48 8B D9 2B 41 ?? 83 F8 02 7D*/
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x4C\x89\x4C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC", "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx"); ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x4C\x89\x4C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC", "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx");
void (*v_sq_pushstructure)(HSQUIRRELVM* v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM*, const SQChar*, const SQChar*, const SQChar*, const SQChar*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 4C 89 4C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC*/ void (*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 4C 89 4C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC*/
#elif defined (GAMEDLL_S3) #elif defined (GAMEDLL_S3)
ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60\x48\x8B\x59\x60", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxxxxx"); ADDRESS p_sq_pushstructure = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60\x48\x8B\x59\x60", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxxxxx");
void (*v_sq_pushstructure)(HSQUIRRELVM* v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM*, const SQChar*, const SQChar*, const SQChar*, const SQChar*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60 48 8B 59 60*/ void (*v_sq_pushstructure)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2) = (void (*)(HSQUIRRELVM, const SQChar*, const SQChar*, const SQChar*, const SQChar*))p_sq_pushstructure.GetPtr(); /*48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60 48 8B 59 60*/
#endif #endif
ADDRESS p_sq_compilebuffer = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x56\x41\x57\x48\x83\xEC\x50\x41\x8B\xE9\x49\x8B\xF8", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx"); ADDRESS p_sq_compilebuffer = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x41\x56\x41\x57\x48\x83\xEC\x50\x41\x8B\xE9\x49\x8B\xF8", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxx");
SQRESULT (*v_sq_compilebuffer)(HSQUIRRELVM v, SQBufState bufferState, const SQChar* buffer, SQCONTEXT context) = (SQRESULT (*)(HSQUIRRELVM, SQBufState, const SQChar*, SQCONTEXT))p_sq_compilebuffer.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC 50 41 8B E9 49 8B F8 */ SQRESULT (*v_sq_compilebuffer)(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger level) = (SQRESULT (*)(HSQUIRRELVM, SQBufState*, const SQChar*, SQInteger))p_sq_compilebuffer.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC 50 41 8B E9 49 8B F8*/
ADDRESS p_sq_call = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x4C\x8B\xDC\x49\x89\x5B\x08\x49\x89\x6B\x10\x49\x89\x73\x18\x57\x48\x83\xEC\x50\x8B\xF2", "xxxxxxxxxxxxxxxxxxxxxx");
SQRESULT (*v_sq_call)(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror) = (SQRESULT (*)(HSQUIRRELVM, SQInteger, SQBool, SQBool))p_sq_call.GetPtr(); /*4C 8B DC 49 89 5B 08 49 89 6B 10 49 89 73 18 57 48 83 EC 50 8B F2*/
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
char* sq_getstring(HSQUIRRELVM* v, SQInteger i); SQRESULT sq_pushroottable(HSQUIRRELVM v);
int sq_getinteger(HSQUIRRELVM* v, SQInteger i); SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i);
void sq_pushbool(HSQUIRRELVM* v, SQBool b); SQInteger sq_getinteger(HSQUIRRELVM v, SQInteger i);
void sq_pushstring(HSQUIRRELVM* v, const SQChar* string, SQInteger len); SQRESULT sq_pushroottable(HSQUIRRELVM v);
void sq_pushinteger(HSQUIRRELVM* v, SQInteger val); void sq_pushbool(HSQUIRRELVM v, SQBool b);
void sq_pushconstant(HSQUIRRELVM* v, const SQChar* name, SQInteger val); void sq_pushstring(HSQUIRRELVM v, const SQChar* string, SQInteger len);
void sq_newarray(HSQUIRRELVM* v, SQInteger size); void sq_pushinteger(HSQUIRRELVM v, SQInteger val);
void sq_arrayappend(HSQUIRRELVM* v, SQInteger idx); void sq_pushconstant(HSQUIRRELVM v, const SQChar* name, SQInteger val);
void sq_newtable(HSQUIRRELVM* v); void sq_newarray(HSQUIRRELVM v, SQInteger size);
void sq_newslot(HSQUIRRELVM* v, SQInteger idx); void sq_arrayappend(HSQUIRRELVM v, SQInteger idx);
void sq_pushstructure(HSQUIRRELVM* v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2); void sq_newtable(HSQUIRRELVM v);
void sq_newslot(HSQUIRRELVM v, SQInteger idx);
void sq_pushstructure(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2);
SQRESULT sq_compilebuffer(HSQUIRRELVM v, SQBufState* bufferState, const SQChar* buffer, SQInteger context);
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror);
void SQAPI_Attach(); void SQAPI_Attach();
void SQAPI_Detach(); void SQAPI_Detach();
@ -62,6 +72,7 @@ class HSqapi : public IDetour
{ {
virtual void debugp() virtual void debugp()
{ {
std::cout << "| FUN: sq_pushroottable : 0x" << std::hex << std::uppercase << p_sq_pushroottable.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_pushbool : 0x" << std::hex << std::uppercase << p_sq_pushbool.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_pushbool : 0x" << std::hex << std::uppercase << p_sq_pushbool.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_pushstring : 0x" << std::hex << std::uppercase << p_sq_pushstring.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_pushstring : 0x" << std::hex << std::uppercase << p_sq_pushstring.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_pushinteger : 0x" << std::hex << std::uppercase << p_sq_pushinteger.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_pushinteger : 0x" << std::hex << std::uppercase << p_sq_pushinteger.GetPtr() << std::setw(npad) << " |" << std::endl;
@ -72,6 +83,7 @@ class HSqapi : public IDetour
std::cout << "| FUN: sq_newslot : 0x" << std::hex << std::uppercase << p_sq_newslot.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_newslot : 0x" << std::hex << std::uppercase << p_sq_newslot.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_pushstructure : 0x" << std::hex << std::uppercase << p_sq_pushstructure.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_pushstructure : 0x" << std::hex << std::uppercase << p_sq_pushstructure.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_compilebuffer : 0x" << std::hex << std::uppercase << p_sq_compilebuffer.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: sq_compilebuffer : 0x" << std::hex << std::uppercase << p_sq_compilebuffer.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: sq_call : 0x" << std::hex << std::uppercase << p_sq_call.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "+----------------------------------------------------------------+" << std::endl; std::cout << "+----------------------------------------------------------------+" << std::endl;
} }
}; };

View File

@ -29,7 +29,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: SDK test and example body // Purpose: SDK test and example body
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT SDKNativeTest(HSQUIRRELVM* v) SQRESULT SDKNativeTest(HSQUIRRELVM v)
{ {
// Function code goes here. // Function code goes here.
return SQ_OK; return SQ_OK;
@ -38,7 +38,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: expose SDK version to the VScript API // Purpose: expose SDK version to the VScript API
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetSDKVersion(HSQUIRRELVM* v) SQRESULT GetSDKVersion(HSQUIRRELVM v)
{ {
sq_pushstring(v, g_pR5net->GetSDKVersion().c_str(), -1); sq_pushstring(v, g_pR5net->GetSDKVersion().c_str(), -1);
return SQ_OK; return SQ_OK;
@ -58,7 +58,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get server's current name from serverlist index // Purpose: get server's current name from serverlist index
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetServerName(HSQUIRRELVM* v) SQRESULT GetServerName(HSQUIRRELVM v)
{ {
int iServerIndex = sq_getinteger(v, 1); int iServerIndex = sq_getinteger(v, 1);
std::string svServerName = g_pIBrowser->m_vServerList[iServerIndex].svServerName; std::string svServerName = g_pIBrowser->m_vServerList[iServerIndex].svServerName;
@ -71,7 +71,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get server's current playlist via serverlist index // Purpose: get server's current playlist via serverlist index
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetServerPlaylist(HSQUIRRELVM* v) SQRESULT GetServerPlaylist(HSQUIRRELVM v)
{ {
int iServerIndex = sq_getinteger(v, 1); int iServerIndex = sq_getinteger(v, 1);
std::string svServerPlaylist = g_pIBrowser->m_vServerList[iServerIndex].svPlaylist; std::string svServerPlaylist = g_pIBrowser->m_vServerList[iServerIndex].svPlaylist;
@ -84,7 +84,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get server's current map via serverlist index // Purpose: get server's current map via serverlist index
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetServerMap(HSQUIRRELVM* v) SQRESULT GetServerMap(HSQUIRRELVM v)
{ {
int iServerIndex = sq_getinteger(v, 1); int iServerIndex = sq_getinteger(v, 1);
std::string svServerMapName = g_pIBrowser->m_vServerList[iServerIndex].svMapName; std::string svServerMapName = g_pIBrowser->m_vServerList[iServerIndex].svMapName;
@ -97,7 +97,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get current server count from pylon // Purpose: get current server count from pylon
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetServerCount(HSQUIRRELVM* v) SQRESULT GetServerCount(HSQUIRRELVM v)
{ {
g_pIBrowser->GetServerList(); // Refresh svListing list. g_pIBrowser->GetServerList(); // Refresh svListing list.
@ -109,7 +109,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get promo data for serverbrowser panels // Purpose: get promo data for serverbrowser panels
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetPromoData(HSQUIRRELVM* v) SQRESULT GetPromoData(HSQUIRRELVM v)
{ {
enum class R5RPromoData : int enum class R5RPromoData : int
{ {
@ -172,7 +172,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: set netchannel encryption key and connect to server // Purpose: set netchannel encryption key and connect to server
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT SetEncKeyAndConnect(HSQUIRRELVM* v) SQRESULT SetEncKeyAndConnect(HSQUIRRELVM v)
{ {
int iServerIndex = sq_getinteger(v, 1); int iServerIndex = sq_getinteger(v, 1);
@ -185,7 +185,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: create server via native serverbrowser entries // Purpose: create server via native serverbrowser entries
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT CreateServerFromMenu(HSQUIRRELVM* v) SQRESULT CreateServerFromMenu(HSQUIRRELVM v)
{ {
std::string svServerName = sq_getstring(v, 1); std::string svServerName = sq_getstring(v, 1);
std::string svServerMapName = sq_getstring(v, 2); std::string svServerMapName = sq_getstring(v, 2);
@ -210,7 +210,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: request token from pylon and join server with result. // Purpose: request token from pylon and join server with result.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT JoinPrivateServerFromMenu(HSQUIRRELVM* v) SQRESULT JoinPrivateServerFromMenu(HSQUIRRELVM v)
{ {
std::string svHiddenServerRequestMessage = std::string(); std::string svHiddenServerRequestMessage = std::string();
@ -229,7 +229,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: get response from private server request // Purpose: get response from private server request
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetPrivateServerMessage(HSQUIRRELVM* v) SQRESULT GetPrivateServerMessage(HSQUIRRELVM v)
{ {
std::string svHiddenServerRequestMessage = std::string(); std::string svHiddenServerRequestMessage = std::string();
@ -258,7 +258,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: connect to server from native server browser entries // Purpose: connect to server from native server browser entries
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT ConnectToIPFromMenu(HSQUIRRELVM* v) SQRESULT ConnectToIPFromMenu(HSQUIRRELVM v)
{ {
std::string svIpAddr = sq_getstring(v, 1); std::string svIpAddr = sq_getstring(v, 1);
std::string svEncKey = sq_getstring(v, 2); std::string svEncKey = sq_getstring(v, 2);
@ -276,7 +276,7 @@ namespace VSquirrel
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: return all available maps // Purpose: return all available maps
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SQRESULT GetAvailableMaps(HSQUIRRELVM* v) SQRESULT GetAvailableMaps(HSQUIRRELVM v)
{ {
std::vector<std::string> vsvMapList = g_pIBrowser->m_vszMapFileNameList; std::vector<std::string> vsvMapList = g_pIBrowser->m_vszMapFileNameList;

View File

@ -18,8 +18,8 @@ namespace VSquirrel
{ {
namespace SHARED namespace SHARED
{ {
SQRESULT SDKNativeTest(HSQUIRRELVM* v); SQRESULT SDKNativeTest(HSQUIRRELVM v);
SQRESULT GetSDKVersion(HSQUIRRELVM* v); SQRESULT GetSDKVersion(HSQUIRRELVM v);
} }
namespace SERVER namespace SERVER
{ {
@ -30,17 +30,17 @@ namespace VSquirrel
} }
namespace UI namespace UI
{ {
SQRESULT GetServerName(HSQUIRRELVM* v); SQRESULT GetServerName(HSQUIRRELVM v);
SQRESULT GetServerPlaylist(HSQUIRRELVM* v); SQRESULT GetServerPlaylist(HSQUIRRELVM v);
SQRESULT GetServerMap(HSQUIRRELVM* v); SQRESULT GetServerMap(HSQUIRRELVM v);
SQRESULT GetServerCount(HSQUIRRELVM* v); SQRESULT GetServerCount(HSQUIRRELVM v);
SQRESULT GetPromoData(HSQUIRRELVM* v); SQRESULT GetPromoData(HSQUIRRELVM v);
SQRESULT SetEncKeyAndConnect(HSQUIRRELVM* v); SQRESULT SetEncKeyAndConnect(HSQUIRRELVM v);
SQRESULT CreateServerFromMenu(HSQUIRRELVM* v); SQRESULT CreateServerFromMenu(HSQUIRRELVM v);
SQRESULT JoinPrivateServerFromMenu(HSQUIRRELVM* v); SQRESULT JoinPrivateServerFromMenu(HSQUIRRELVM v);
SQRESULT GetPrivateServerMessage(HSQUIRRELVM* v); SQRESULT GetPrivateServerMessage(HSQUIRRELVM v);
SQRESULT ConnectToIPFromMenu(HSQUIRRELVM* v); SQRESULT ConnectToIPFromMenu(HSQUIRRELVM v);
SQRESULT GetAvailableMaps(HSQUIRRELVM* v); SQRESULT GetAvailableMaps(HSQUIRRELVM v);
} }
#endif // !DEDICATED #endif // !DEDICATED
} }

View File

@ -14,7 +14,18 @@ typedef unsigned long SQUnsignedInteger;
typedef SQUnsignedInteger SQBool; typedef SQUnsignedInteger SQBool;
typedef SQInteger SQRESULT; typedef SQInteger SQRESULT;
typedef struct SQVM* HSQUIRRELVM; struct SQVM
{
char pad_0000[0x8];
SQVM* m_pSqVTable;
// !TODO: The rest.
SQVM* GetVTable()
{
return m_pSqVTable;
}
};
typedef SQVM* HSQUIRRELVM;
struct SQBufState struct SQBufState
{ {
@ -30,6 +41,33 @@ struct SQBufState
} }
}; };
struct SQFuncRegistration
{
const char* m_szScriptName; // 00
const char* m_szNativeName; // 08
const char* m_szHelpString; // 10
const char* m_szRetValType; // 18
const char* m_szArgTypes; // 20
std::int16_t unk28; // 28
std::int16_t padding1; // 2A
std::int32_t unk2c; // 2C
std::int64_t unk30; // 30
std::int32_t unk38; // 38
std::int32_t padding2; // 3C
std::int64_t unk40; // 40
std::int64_t unk48; // 48
std::int64_t unk50; // 50
std::int32_t unk58; // 58
std::int32_t padding3; // 5C
void* m_pFunction; // 60
SQFuncRegistration()
{
memset(this, 0, sizeof(SQFuncRegistration));
this->padding2 = 6;
}
};
enum class SQCONTEXT : int enum class SQCONTEXT : int
{ {
SERVER = 0, SERVER = 0,

View File

@ -15,6 +15,7 @@
#endif // DEDICATED #endif // DEDICATED
#include "vgui/vgui_debugpanel.h" #include "vgui/vgui_debugpanel.h"
#include "gameui/IConsole.h" #include "gameui/IConsole.h"
#include "squirrel/sqtype.h"
#include "squirrel/sqvm.h" #include "squirrel/sqvm.h"
#include "squirrel/sqinit.h" #include "squirrel/sqinit.h"
@ -392,6 +393,78 @@ bool HSQVM_CreateUIVM()
} }
#endif // !DEDICATED #endif // !DEDICATED
//---------------------------------------------------------------------------------
// Purpose: Returns the VM name by context
// Input : context -
// Output : const SQChar*
//---------------------------------------------------------------------------------
const SQChar* SQVM_GetContextName(SQCONTEXT context)
{
switch (context)
{
case SQCONTEXT::SERVER:
return "SERVER";
case SQCONTEXT::CLIENT:
return "CLIENT";
case SQCONTEXT::UI:
return "UI";
default:
return nullptr;
}
}
//---------------------------------------------------------------------------------
// Purpose: Returns the VM pointer by context
// Input : context -
// Output : SQVM*
//---------------------------------------------------------------------------------
HSQUIRRELVM SQVM_GetVM(SQCONTEXT context)
{
switch (context)
{
case SQCONTEXT::SERVER:
return g_pServerVM.GetValue<HSQUIRRELVM>();
case SQCONTEXT::CLIENT:
return g_pClientVM.GetValue<HSQUIRRELVM>();
case SQCONTEXT::UI:
return g_pUIVM.GetValue<HSQUIRRELVM>();
default:
return nullptr;
}
}
//---------------------------------------------------------------------------------
// Purpose: Compiles and executes input code on target VM by context
// Input : *code -
// context -
//---------------------------------------------------------------------------------
void SQVM_Execute(const SQChar* code, SQCONTEXT context)
{
HSQUIRRELVM v = SQVM_GetVM(context);
if (!v)
{
Error(eDLL_T::ENGINE, "Attempted to execute %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
SQVM* vTable = v->GetVTable();
if (!vTable)
{
Error(eDLL_T::ENGINE, "Attempted to execute %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
SQRESULT compileResult{};
SQBufState bufState = SQBufState(code);
compileResult = sq_compilebuffer(vTable, &bufState, "console", -1);
if (compileResult >= 0)
{
sq_pushroottable(vTable);
SQRESULT callResult = sq_call(vTable, 1, false, false);
}
}
void SQVM_Attach() void SQVM_Attach()
{ {
DetourAttach((LPVOID*)&SQVM_PrintFunc, &HSQVM_PrintFunc); DetourAttach((LPVOID*)&SQVM_PrintFunc, &HSQVM_PrintFunc);

View File

@ -1,33 +1,6 @@
#pragma once #pragma once
#include "squirrel/sqtype.h" #include "squirrel/sqtype.h"
struct SQFuncRegistration
{
const char* m_szScriptName; // 00
const char* m_szNativeName; // 08
const char* m_szHelpString; // 10
const char* m_szRetValType; // 18
const char* m_szArgTypes; // 20
std::int16_t unk28; // 28
std::int16_t padding1; // 2A
std::int32_t unk2c; // 2C
std::int64_t unk30; // 30
std::int32_t unk38; // 38
std::int32_t padding2; // 3C
std::int64_t unk40; // 40
std::int64_t unk48; // 48
std::int64_t unk50; // 50
std::int32_t unk58; // 58
std::int32_t padding3; // 5C
void* m_pFunction; // 60
SQFuncRegistration()
{
memset(this, 0, sizeof(SQFuncRegistration));
this->padding2 = 6;
}
};
namespace namespace
{ {
/* ==== SQUIRREL ======================================================================================================================================================== */ /* ==== SQUIRREL ======================================================================================================================================================== */
@ -104,6 +77,9 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...);
void* HSQVM_LoadRson(const char* szRsonName); void* HSQVM_LoadRson(const char* szRsonName);
bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlags); bool HSQVM_LoadScript(void* sqvm, const char* szScriptPath, const char* szScriptName, int nFlags);
void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpString, const char* szRetValType, const char* szArgTypes, void* pFunction); void HSQVM_RegisterFunction(void* sqvm, const char* szName, const char* szHelpString, const char* szRetValType, const char* szArgTypes, void* pFunction);
const SQChar* SQVM_GetContextName(SQCONTEXT context);
HSQUIRRELVM SQVM_GetVM(SQCONTEXT context);
void SQVM_Execute(const SQChar* code, SQCONTEXT context);
void SQVM_Attach(); void SQVM_Attach();
void SQVM_Detach(); void SQVM_Detach();

View File

@ -120,6 +120,7 @@ void ConCommand::Init(void)
{ {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// SERVER DLL | // SERVER DLL |
ConCommand* script = new ConCommand("script", "Run input code as SERVER script on the VM.", FCVAR_GAMEDLL | FCVAR_CHEAT, _SQVM_ServerScript_f_CompletionFunc, nullptr);
ConCommand* sv_kick = new ConCommand("sv_kick", "Kick a client from the server by name. | Usage: kick \"<name>\".", FCVAR_RELEASE, _Kick_f_CompletionFunc, nullptr); ConCommand* sv_kick = new ConCommand("sv_kick", "Kick a client from the server by name. | Usage: kick \"<name>\".", FCVAR_RELEASE, _Kick_f_CompletionFunc, nullptr);
ConCommand* sv_kickid = new ConCommand("sv_kickid", "Kick a client from the server by UserID or OriginID | Usage: kickid \"<OriginID>\"/\"<UserID>\".", FCVAR_RELEASE, _KickID_f_CompletionFunc, nullptr); ConCommand* sv_kickid = new ConCommand("sv_kickid", "Kick a client from the server by UserID or OriginID | Usage: kickid \"<OriginID>\"/\"<UserID>\".", FCVAR_RELEASE, _KickID_f_CompletionFunc, nullptr);
ConCommand* sv_ban = new ConCommand("sv_ban", "Bans a client from the server by name. | Usage: ban <name>.", FCVAR_RELEASE, _Ban_f_CompletionFunc, nullptr); ConCommand* sv_ban = new ConCommand("sv_ban", "Bans a client from the server by name. | Usage: ban <name>.", FCVAR_RELEASE, _Ban_f_CompletionFunc, nullptr);
@ -129,10 +130,14 @@ void ConCommand::Init(void)
#ifndef DEDICATED #ifndef DEDICATED
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// CLIENT DLL | // CLIENT DLL |
ConCommand* script_client = new ConCommand("script_client", "Run input code as CLIENT script on the VM.", FCVAR_CLIENTDLL | FCVAR_CHEAT, _SQVM_ClientScript_f_CompletionFunc, nullptr);
ConCommand* cl_showconsole = new ConCommand("cl_showconsole", "Opens the game console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CGameConsole_f_CompletionFunc, nullptr); ConCommand* cl_showconsole = new ConCommand("cl_showconsole", "Opens the game console.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CGameConsole_f_CompletionFunc, nullptr);
ConCommand* cl_showbrowser = new ConCommand("cl_showbrowser", "Opens the server browser.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CCompanion_f_CompletionFunc, nullptr); ConCommand* cl_showbrowser = new ConCommand("cl_showbrowser", "Opens the server browser.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _CCompanion_f_CompletionFunc, nullptr);
ConCommand* rcon = new ConCommand("rcon", "Forward RCON query to remote server. | Usage: rcon \"<query>\".", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_CmdQuery_f_CompletionFunc, nullptr); ConCommand* rcon = new ConCommand("rcon", "Forward RCON query to remote server. | Usage: rcon \"<query>\".", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_CmdQuery_f_CompletionFunc, nullptr);
ConCommand* rcon_disconnect = new ConCommand("rcon_disconnect", "Disconnect from RCON server.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_Disconnect_f_CompletionFunc, nullptr); ConCommand* rcon_disconnect = new ConCommand("rcon_disconnect", "Disconnect from RCON server.", FCVAR_CLIENTDLL | FCVAR_RELEASE, _RCON_Disconnect_f_CompletionFunc, nullptr);
//-------------------------------------------------------------------------
// UI DLL |
ConCommand* script_ui = new ConCommand("script_ui", "Run input code as UI script on the VM.", FCVAR_CLIENTDLL | FCVAR_CHEAT, _SQVM_UIScript_f_CompletionFunc, nullptr);
#endif // !DEDICATED #endif // !DEDICATED
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// FILESYSTEM API | // FILESYSTEM API |

View File

@ -18,6 +18,7 @@
#include "rtech/rtech_game.h" #include "rtech/rtech_game.h"
#include "rtech/rtech_utils.h" #include "rtech/rtech_utils.h"
#include "vpklib/packedstore.h" #include "vpklib/packedstore.h"
#include "squirrel/sqvm.h"
#ifndef DEDICATED #ifndef DEDICATED
#include "gameui/IBrowser.h" #include "gameui/IBrowser.h"
#include "gameui/IConsole.h" #include "gameui/IConsole.h"
@ -800,7 +801,61 @@ void _RCON_Disconnect_f_CompletionFunc(const CCommand& args)
} }
#endif // !DEDICATED #endif // !DEDICATED
/*
=====================
_SQVM_ServerScript_f_CompletionFunc
Exectutes input on the
VM in SERVER context.
=====================
*/
void _SQVM_ServerScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() < 2)
{
return;
}
SQVM_Execute(args.Arg(1), SQCONTEXT::SERVER);
}
#ifndef DEDICATED #ifndef DEDICATED
/*
=====================
_SQVM_ClientScript_f_CompletionFunc
Exectutes input on the
VM in CLIENT context.
=====================
*/
void _SQVM_ClientScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() < 2)
{
return;
}
SQVM_Execute(args.Arg(1), SQCONTEXT::CLIENT);
}
/*
=====================
_SQVM_UIScript_f_CompletionFunc
Exectutes input on the
VM in UI context.
=====================
*/
void _SQVM_UIScript_f_CompletionFunc(const CCommand& args)
{
if (args.ArgC() < 2)
{
return;
}
SQVM_Execute(args.Arg(1), SQCONTEXT::UI);
}
/* /*
===================== =====================
_IMaterial_GetMaterialAtCrossHair_f_CompletionFunc _IMaterial_GetMaterialAtCrossHair_f_CompletionFunc

View File

@ -39,7 +39,10 @@ void _NET_GenerateKey_f_CompletionFunc(const CCommand& args);
void _RCON_CmdQuery_f_CompletionFunc(const CCommand& args); void _RCON_CmdQuery_f_CompletionFunc(const CCommand& args);
void _RCON_Disconnect_f_CompletionFunc(const CCommand& args); void _RCON_Disconnect_f_CompletionFunc(const CCommand& args);
#endif // !DEDICATED #endif // !DEDICATED
void _SQVM_ServerScript_f_CompletionFunc(const CCommand& args);
#ifndef DEDICATED #ifndef DEDICATED
void _SQVM_ClientScript_f_CompletionFunc(const CCommand& args);
void _SQVM_UIScript_f_CompletionFunc(const CCommand& args);
void _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc(const CCommand& args); void _CMaterial_GetMaterialAtCrossHair_f_ComplectionFunc(const CCommand& args);
#endif // !DEDICATED #endif // !DEDICATED