aboutsummaryrefslogtreecommitdiff
path: root/primedev/squirrel/squirrel.cpp
diff options
context:
space:
mode:
authorF1F7Y <64418963+F1F7Y@users.noreply.github.com>2024-09-02 17:50:37 +0200
committerGitHub <noreply@github.com>2024-09-02 17:50:37 +0200
commitce21abe9c4c58d7c7d986fb01824ab107081ad2f (patch)
treed723f3ddab3994adfd0391eed5d53faf8db26e65 /primedev/squirrel/squirrel.cpp
parent79fbb9b9a751d6c3a863b1fed95cd8480a1586ab (diff)
downloadNorthstarLauncher-1.27.6.tar.gz
NorthstarLauncher-1.27.6.zip
vscript: Move squirrel types to their respective files (#788)v1.27.6-rc4v1.27.6
Refactor logic to move Squirrel types to their own respective files and extend existing layouts in the process where applicable. Contains additional smaller fixes.
Diffstat (limited to 'primedev/squirrel/squirrel.cpp')
-rw-r--r--primedev/squirrel/squirrel.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/primedev/squirrel/squirrel.cpp b/primedev/squirrel/squirrel.cpp
index 29540cce..4141d04d 100644
--- a/primedev/squirrel/squirrel.cpp
+++ b/primedev/squirrel/squirrel.cpp
@@ -11,6 +11,8 @@
#include "ns_version.h"
#include "core/vanilla.h"
+#include "vscript/vscript.h"
+
#include <any>
AUTOHOOK_INIT()
@@ -253,8 +255,8 @@ template <ScriptContext context> void SquirrelManager<context>::ExecuteCode(cons
spdlog::info("Executing {} script code {} ", GetContextName(context), pCode);
- std::string strCode(pCode);
- CompileBufferState bufferState = CompileBufferState(strCode);
+ // NOTE: SQBufferState doesn't strdup pCode!
+ SQBufferState bufferState = SQBufferState(pCode);
SQRESULT compileResult = compilebuffer(&bufferState, "console");
spdlog::info("sq_compilebuffer returned {}", PrintSQRESULT.at(compileResult));
@@ -309,14 +311,14 @@ template <ScriptContext context> void SquirrelManager<context>::AddFuncOverride(
}
// hooks
-bool IsUIVM(ScriptContext context, HSquirrelVM* pSqvm)
+bool IsUIVM(ScriptContext context, HSQUIRRELVM pSqvm)
{
NOTE_UNUSED(context);
return ScriptContext(pSqvm->sharedState->cSquirrelVM->vmContext) == ScriptContext::UI;
}
-template <ScriptContext context> void* (*sq_compiler_create)(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError);
-template <ScriptContext context> void* __fastcall sq_compiler_createHook(HSquirrelVM* sqvm, void* a2, void* a3, SQBool bShouldThrowError)
+template <ScriptContext context> void* (*sq_compiler_create)(HSQUIRRELVM sqvm, void* a2, void* a3, SQBool bShouldThrowError);
+template <ScriptContext context> void* __fastcall sq_compiler_createHook(HSQUIRRELVM sqvm, void* a2, void* a3, SQBool bShouldThrowError)
{
// store whether errors generated from this compile should be fatal
if (IsUIVM(context, sqvm))
@@ -327,8 +329,8 @@ template <ScriptContext context> void* __fastcall sq_compiler_createHook(HSquirr
return sq_compiler_create<context>(sqvm, a2, a3, bShouldThrowError);
}
-template <ScriptContext context> SQInteger (*SQPrint)(HSquirrelVM* sqvm, const char* fmt);
-template <ScriptContext context> SQInteger SQPrintHook(HSquirrelVM* sqvm, const char* fmt, ...)
+template <ScriptContext context> SQInteger (*SQPrint)(HSQUIRRELVM sqvm, const char* fmt);
+template <ScriptContext context> SQInteger SQPrintHook(HSQUIRRELVM sqvm, const char* fmt, ...)
{
NOTE_UNUSED(sqvm);
@@ -398,9 +400,9 @@ template <ScriptContext context> void __fastcall DestroyVMHook(void* a1, CSquirr
spdlog::info("DestroyVM {} {}", GetContextName(realContext), (void*)sqvm);
}
-template <ScriptContext context> void (*SQCompileError)(HSquirrelVM* sqvm, const char* error, const char* file, int line, int column);
+template <ScriptContext context> void (*SQCompileError)(HSQUIRRELVM sqvm, const char* error, const char* file, int line, int column);
template <ScriptContext context>
-void __fastcall ScriptCompileErrorHook(HSquirrelVM* sqvm, const char* error, const char* file, int line, int column)
+void __fastcall ScriptCompileErrorHook(HSQUIRRELVM sqvm, const char* error, const char* file, int line, int column)
{
bool bIsFatalError = g_pSquirrel<context>->m_bFatalCompilationErrors;
ScriptContext realContext = context; // ui and client use the same function so we use this for prints
@@ -544,7 +546,7 @@ template <ScriptContext context> void ConCommand_script(const CCommand& args)
g_pSquirrel<context>->ExecuteCode(args.ArgS());
}
-template <ScriptContext context> SQRESULT SQ_StubbedFunc(HSquirrelVM* sqvm)
+template <ScriptContext context> SQRESULT SQ_StubbedFunc(HSQUIRRELVM sqvm)
{
SQStackInfos si;
g_pSquirrel<context>->sq_stackinfos(sqvm, 0, si);