aboutsummaryrefslogtreecommitdiff
path: root/primedev/squirrel/squirrel.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-30 22:59:56 +0000
committerGitHub <noreply@github.com>2023-12-30 23:59:56 +0100
commita78b7d857f86318ab69031d844f34587d2d84e86 (patch)
treec8941370e4eb8e4261c6464eb80707095bd41b55 /primedev/squirrel/squirrel.cpp
parentf5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (diff)
downloadNorthstarLauncher-1.21.3.tar.gz
NorthstarLauncher-1.21.3.zip
Simplify vscript stub function (#627)v1.21.3-rc1v1.21.3
Since we can get stack info from the sqvm, we don't need to give the function name in the template and stuff. Cherry picked from primedev
Diffstat (limited to 'primedev/squirrel/squirrel.cpp')
-rw-r--r--primedev/squirrel/squirrel.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/primedev/squirrel/squirrel.cpp b/primedev/squirrel/squirrel.cpp
index ac9a2ce9..43e43398 100644
--- a/primedev/squirrel/squirrel.cpp
+++ b/primedev/squirrel/squirrel.cpp
@@ -619,20 +619,12 @@ template <ScriptContext context> void ConCommand_script(const CCommand& args)
g_pSquirrel<context>->ExecuteCode(args.ArgS());
}
-// literal class type that wraps a constant expression string
-template <size_t N> struct TemplateStringLiteral
+template <ScriptContext context> SQRESULT SQ_StubbedFunc(HSquirrelVM* sqvm)
{
- constexpr TemplateStringLiteral(const char (&str)[N])
- {
- std::copy_n(str, N, value);
- }
+ SQStackInfos si;
+ g_pSquirrel<context>->sq_stackinfos(sqvm, 0, si);
- char value[N];
-};
-
-template <ScriptContext context, TemplateStringLiteral funcName> SQRESULT SQ_StubbedFunc(HSquirrelVM* sqvm)
-{
- spdlog::info("Blocking call to stubbed function {} in {}", funcName.value, GetContextName(context));
+ spdlog::warn("Blocking call to stubbed function {} in {}", si._name, GetContextName(context));
return SQRESULT_NULL;
}
@@ -640,12 +632,12 @@ template <ScriptContext context> void StubUnsafeSQFuncs()
{
if (!CommandLine()->CheckParm("-allowunsafesqfuncs"))
{
- g_pSquirrel<context>->AddFuncOverride("DevTextBufferWrite", SQ_StubbedFunc<context, "DevTextBufferWrite">);
- g_pSquirrel<context>->AddFuncOverride("DevTextBufferClear", SQ_StubbedFunc<context, "DevTextBufferClear">);
- g_pSquirrel<context>->AddFuncOverride("DevTextBufferDumpToFile", SQ_StubbedFunc<context, "DevTextBufferDumpToFile">);
- g_pSquirrel<context>->AddFuncOverride("Dev_CommandLineAddParam", SQ_StubbedFunc<context, "Dev_CommandLineAddParam">);
- g_pSquirrel<context>->AddFuncOverride("DevP4Checkout", SQ_StubbedFunc<context, "DevP4Checkout">);
- g_pSquirrel<context>->AddFuncOverride("DevP4Add", SQ_StubbedFunc<context, "DevP4Add">);
+ g_pSquirrel<context>->AddFuncOverride("DevTextBufferWrite", SQ_StubbedFunc<context>);
+ g_pSquirrel<context>->AddFuncOverride("DevTextBufferClear", SQ_StubbedFunc<context>);
+ g_pSquirrel<context>->AddFuncOverride("DevTextBufferDumpToFile", SQ_StubbedFunc<context>);
+ g_pSquirrel<context>->AddFuncOverride("Dev_CommandLineAddParam", SQ_StubbedFunc<context>);
+ g_pSquirrel<context>->AddFuncOverride("DevP4Checkout", SQ_StubbedFunc<context>);
+ g_pSquirrel<context>->AddFuncOverride("DevP4Add", SQ_StubbedFunc<context>);
}
}