diff options
author | uniboi <64006268+uniboi@users.noreply.github.com> | 2023-04-27 12:55:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-27 14:55:06 +0200 |
commit | 6fa48abd3387a7fe0c00f462f08bf4b680f656f9 (patch) | |
tree | 64231d48674f7fbc4ccd23bc9653078c9112f519 /NorthstarDLL/squirrel | |
parent | c50441f67a53ffa38f8f82e85aafbd4206bafc14 (diff) | |
download | NorthstarLauncher-6fa48abd3387a7fe0c00f462f08bf4b680f656f9.tar.gz NorthstarLauncher-6fa48abd3387a7fe0c00f462f08bf4b680f656f9.zip |
Use structs for the Script Server Browser (#453)v1.14.2-rc1v1.14.2v1.14.1-rc1v1.14.1v1.14.0-rc1v1.14.0
* fix vector garbage data
* use structs for script server browser
* use sq struct api wrappers
* use sqfloat return type for getvector
* use const references for access
* move fn to make the diff more readable (hopefully)
Diffstat (limited to 'NorthstarDLL/squirrel')
-rw-r--r-- | NorthstarDLL/squirrel/squirrel.cpp | 10 | ||||
-rw-r--r-- | NorthstarDLL/squirrel/squirrel.h | 13 | ||||
-rw-r--r-- | NorthstarDLL/squirrel/squirrelclasstypes.h | 4 |
3 files changed, 27 insertions, 0 deletions
diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp index 43c5296b..3bb5c154 100644 --- a/NorthstarDLL/squirrel/squirrel.cpp +++ b/NorthstarDLL/squirrel/squirrel.cpp @@ -780,6 +780,12 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::CLIENT>->__sq_stackinfos = module.Offset(0x35970).As<sq_stackinfosType>(); g_pSquirrel<ScriptContext::UI>->__sq_stackinfos = g_pSquirrel<ScriptContext::CLIENT>->__sq_stackinfos; + // Structs + g_pSquirrel<ScriptContext::CLIENT>->__sq_pushnewstructinstance = module.Offset(0x5400).As<sq_pushnewstructinstanceType>(); + g_pSquirrel<ScriptContext::CLIENT>->__sq_sealstructslot = module.Offset(0x5530).As<sq_sealstructslotType>(); + g_pSquirrel<ScriptContext::UI>->__sq_pushnewstructinstance = g_pSquirrel<ScriptContext::CLIENT>->__sq_pushnewstructinstance; + g_pSquirrel<ScriptContext::UI>->__sq_sealstructslot = g_pSquirrel<ScriptContext::CLIENT>->__sq_sealstructslot; + MAKEHOOK( module.Offset(0x108E0), &RegisterSquirrelFunctionHook<ScriptContext::CLIENT>, @@ -869,6 +875,10 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) g_pSquirrel<ScriptContext::SERVER>->__sq_getfunction = module.Offset(0x6C85).As<sq_getfunctionType>(); g_pSquirrel<ScriptContext::SERVER>->__sq_stackinfos = module.Offset(0x35920).As<sq_stackinfosType>(); + // Structs + g_pSquirrel<ScriptContext::SERVER>->__sq_pushnewstructinstance = module.Offset(0x53e0).As<sq_pushnewstructinstanceType>(); + g_pSquirrel<ScriptContext::SERVER>->__sq_sealstructslot = module.Offset(0x5510).As<sq_sealstructslotType>(); + MAKEHOOK( module.Offset(0x1DD10), &RegisterSquirrelFunctionHook<ScriptContext::SERVER>, diff --git a/NorthstarDLL/squirrel/squirrel.h b/NorthstarDLL/squirrel/squirrel.h index 9bf3a794..3d18d6c1 100644 --- a/NorthstarDLL/squirrel/squirrel.h +++ b/NorthstarDLL/squirrel/squirrel.h @@ -107,6 +107,9 @@ class SquirrelManagerBase sq_getentityfrominstanceType __sq_getentityfrominstance; sq_GetEntityConstantType __sq_GetEntityConstant_CBaseEntity; + sq_pushnewstructinstanceType __sq_pushnewstructinstance; + sq_sealstructslotType __sq_sealstructslot; + #pragma endregion #pragma region SQVM func wrappers @@ -288,6 +291,16 @@ class SquirrelManagerBase // there are entity constants for other types, but seemingly CBaseEntity's is the only one needed return (T*)__sq_getentityfrominstance(m_pSQVM, &obj, __sq_GetEntityConstant_CBaseEntity()); } + + inline SQRESULT pushnewstructinstance(HSquirrelVM* sqvm, const int fieldCount) + { + return __sq_pushnewstructinstance(sqvm, fieldCount); + } + + inline SQRESULT sealstructslot(HSquirrelVM* sqvm, const int fieldIndex) + { + return __sq_sealstructslot(sqvm, fieldIndex); + } #pragma endregion }; diff --git a/NorthstarDLL/squirrel/squirrelclasstypes.h b/NorthstarDLL/squirrel/squirrelclasstypes.h index 67f69827..ac813334 100644 --- a/NorthstarDLL/squirrel/squirrelclasstypes.h +++ b/NorthstarDLL/squirrel/squirrelclasstypes.h @@ -236,6 +236,10 @@ typedef char** (*sq_GetEntityConstantType)(); typedef int (*sq_getfunctionType)(HSquirrelVM* sqvm, const char* name, SQObject* returnObj, const char* signature); +// structs +typedef SQRESULT (*sq_pushnewstructinstanceType)(HSquirrelVM* sqvm, int fieldCount); +typedef SQRESULT (*sq_sealstructslotType)(HSquirrelVM* sqvm, int slotIndex); + #pragma endregion // These "external" versions of the types are for plugins |