diff options
author | cat_or_not <41955154+catornot@users.noreply.github.com> | 2023-11-05 20:21:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-06 02:21:50 +0100 |
commit | bb822b7638d5ae9bc4499ff76edc74f3741e6518 (patch) | |
tree | 558886bd28dc53d1004e235be1c1543c5ec2fd9f /NorthstarDLL/squirrel | |
parent | 583bae6e1a7e35eec2c5cb4383bc0089f6ee6781 (diff) | |
download | NorthstarLauncher-bb822b7638d5ae9bc4499ff76edc74f3741e6518.tar.gz NorthstarLauncher-bb822b7638d5ae9bc4499ff76edc74f3741e6518.zip |
Plugins v3 (#472)v1.20.1-rc2v1.20.1-rc1v1.20.0-rc3v1.20.0
- nuked presence logic ( moved to the discord rpc plugin )
- more exposed sq functions
- exposed dll addresses
- `g_pCVar` is exposed
- added "userdata" to plugin's async call
- added runframe to plugins
Diffstat (limited to 'NorthstarDLL/squirrel')
-rw-r--r-- | NorthstarDLL/squirrel/squirrel.cpp | 29 | ||||
-rw-r--r-- | NorthstarDLL/squirrel/squirrel.h | 2 | ||||
-rw-r--r-- | NorthstarDLL/squirrel/squirrelclasstypes.h | 6 |
3 files changed, 23 insertions, 14 deletions
diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp index 429ef8b0..e43686d7 100644 --- a/NorthstarDLL/squirrel/squirrel.cpp +++ b/NorthstarDLL/squirrel/squirrel.cpp @@ -164,6 +164,7 @@ template <ScriptContext context> void SquirrelManager<context>::GenerateSquirrel s->__sq_compilebuffer = __sq_compilebuffer; s->__sq_call = __sq_call; s->__sq_raiseerror = __sq_raiseerror; + s->__sq_compilefile = __sq_compilefile; s->__sq_newarray = __sq_newarray; s->__sq_arrayappend = __sq_arrayappend; @@ -179,12 +180,8 @@ template <ScriptContext context> void SquirrelManager<context>::GenerateSquirrel s->__sq_pushasset = __sq_pushasset; s->__sq_pushvector = __sq_pushvector; s->__sq_pushobject = __sq_pushobject; - s->__sq_getstring = __sq_getstring; - s->__sq_getthisentity = __sq_getthisentity; - s->__sq_getobject = __sq_getobject; - - s->__sq_stackinfos = __sq_stackinfos; + s->__sq_getstring = __sq_getstring; s->__sq_getinteger = __sq_getinteger; s->__sq_getfloat = __sq_getfloat; s->__sq_getbool = __sq_getbool; @@ -192,24 +189,32 @@ template <ScriptContext context> void SquirrelManager<context>::GenerateSquirrel s->__sq_getasset = __sq_getasset; s->__sq_getuserdata = __sq_getuserdata; s->__sq_getvector = __sq_getvector; + s->__sq_getthisentity = __sq_getthisentity; + s->__sq_getobject = __sq_getobject; + + s->__sq_stackinfos = __sq_stackinfos; + s->__sq_createuserdata = __sq_createuserdata; s->__sq_setuserdatatypeid = __sq_setuserdatatypeid; s->__sq_getfunction = __sq_getfunction; + s->__sq_schedule_call_external = AsyncCall_External; + s->__sq_getentityfrominstance = __sq_getentityfrominstance; s->__sq_GetEntityConstant_CBaseEntity = __sq_GetEntityConstant_CBaseEntity; - s->__sq_schedule_call_external = AsyncCall_External; + s->__sq_pushnewstructinstance = __sq_pushnewstructinstance; + s->__sq_sealstructslot = __sq_sealstructslot; } // Allows for generating squirrelmessages from plugins. -// Not used in this version, but will be used later -void AsyncCall_External(ScriptContext context, const char* func_name, SquirrelMessage_External_Pop function) +void AsyncCall_External(ScriptContext context, const char* func_name, SquirrelMessage_External_Pop function, void* userdata) { SquirrelMessage message {}; message.functionName = func_name; message.isExternal = true; message.externalFunc = function; + message.userdata = userdata; switch (context) { case ScriptContext::CLIENT: @@ -651,9 +656,11 @@ template <ScriptContext context> void SquirrelManager<context>::ProcessMessageBu pushobject(m_pSQVM->sqvm, &functionobj); // Push the function object pushroottable(m_pSQVM->sqvm); - if (message.isExternal) + int argsAmount = message.args.size(); + + if (message.isExternal && message.externalFunc != NULL) { - message.externalFunc(m_pSQVM->sqvm); + argsAmount = message.externalFunc(m_pSQVM->sqvm, message.userdata); } else { @@ -664,7 +671,7 @@ template <ScriptContext context> void SquirrelManager<context>::ProcessMessageBu } } - _call(m_pSQVM->sqvm, message.args.size()); + _call(m_pSQVM->sqvm, argsAmount); } } diff --git a/NorthstarDLL/squirrel/squirrel.h b/NorthstarDLL/squirrel/squirrel.h index 427eb03c..50dd31d0 100644 --- a/NorthstarDLL/squirrel/squirrel.h +++ b/NorthstarDLL/squirrel/squirrel.h @@ -51,7 +51,7 @@ const char* GetContextName_Short(ScriptContext context); eSQReturnType SQReturnTypeFromString(const char* pReturnType); const char* SQTypeNameFromID(const int iTypeId); -void AsyncCall_External(ScriptContext context, const char* func_name, SquirrelMessage_External_Pop function); +void AsyncCall_External(ScriptContext context, const char* func_name, SquirrelMessage_External_Pop function, void* userdata); ScriptContext ScriptContextFromString(std::string string); diff --git a/NorthstarDLL/squirrel/squirrelclasstypes.h b/NorthstarDLL/squirrel/squirrelclasstypes.h index ac813334..c193f2fc 100644 --- a/NorthstarDLL/squirrel/squirrelclasstypes.h +++ b/NorthstarDLL/squirrel/squirrelclasstypes.h @@ -116,8 +116,9 @@ concept is_iterable = requires(std::ranges::range_value_t<T> x) // clang-format on -typedef void (*SquirrelMessage_External_Pop)(HSquirrelVM* sqvm); -typedef void (*sq_schedule_call_externalType)(ScriptContext context, const char* funcname, SquirrelMessage_External_Pop function); +typedef int (*SquirrelMessage_External_Pop)(HSquirrelVM* sqvm, void* userdata); +typedef void (*sq_schedule_call_externalType)( + ScriptContext context, const char* funcname, SquirrelMessage_External_Pop function, void* userdata); class SquirrelMessage { @@ -125,6 +126,7 @@ class SquirrelMessage std::string functionName; FunctionVector args; bool isExternal = false; + void* userdata = NULL; SquirrelMessage_External_Pop externalFunc = NULL; }; |