diff options
author | Emma Miler <emma.pi@protonmail.com> | 2022-12-11 22:57:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-11 22:57:18 +0100 |
commit | 08c30b23cdda07fe5564030f8c55b9becc460566 (patch) | |
tree | 00c34a14fa6bb36caa4c7def8dae673eab16516b | |
parent | 013548a64babbf97b07e9c4436117f0da5c07e43 (diff) | |
download | NorthstarLauncher-08c30b23cdda07fe5564030f8c55b9becc460566.tar.gz NorthstarLauncher-08c30b23cdda07fe5564030f8c55b9becc460566.zip |
Log function lookup failure on Call (#355)
* Log function lookup failure on Call
* Formatting
* Update squirrel.cpp
* format
-rw-r--r-- | NorthstarDLL/dllmain.cpp | 1 | ||||
-rw-r--r-- | NorthstarDLL/logging.h | 1 | ||||
-rw-r--r-- | NorthstarDLL/loghooks.cpp | 1 | ||||
-rw-r--r-- | NorthstarDLL/squirrel.cpp | 6 | ||||
-rw-r--r-- | NorthstarDLL/squirrel.h | 10 |
5 files changed, 14 insertions, 5 deletions
diff --git a/NorthstarDLL/dllmain.cpp b/NorthstarDLL/dllmain.cpp index 44d973f2..4a9da4af 100644 --- a/NorthstarDLL/dllmain.cpp +++ b/NorthstarDLL/dllmain.cpp @@ -8,6 +8,7 @@ #include "plugins.h" #include "version.h" #include "pch.h" +#include "squirrel.h" #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" diff --git a/NorthstarDLL/logging.h b/NorthstarDLL/logging.h index a75dce91..78f65e18 100644 --- a/NorthstarDLL/logging.h +++ b/NorthstarDLL/logging.h @@ -2,7 +2,6 @@ #include "pch.h" #include "spdlog/sinks/base_sink.h" #include "spdlog/logger.h" -#include "squirrel.h" #include "color.h" void CreateLogFiles(); diff --git a/NorthstarDLL/loghooks.cpp b/NorthstarDLL/loghooks.cpp index 316d34ae..a352f4c1 100644 --- a/NorthstarDLL/loghooks.cpp +++ b/NorthstarDLL/loghooks.cpp @@ -6,6 +6,7 @@ #include "bitbuf.h" #include "nsprefix.h" #include "tier0.h" +#include "squirrel.h" #include <iomanip> #include <sstream> diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp index a5733784..fb4e77c5 100644 --- a/NorthstarDLL/squirrel.cpp +++ b/NorthstarDLL/squirrel.cpp @@ -528,10 +528,8 @@ template <ScriptContext context> void SquirrelManager<context>::ProcessMessageBu int result = sq_getfunction(m_pSQVM->sqvm, message.functionName.c_str(), &functionobj, 0); if (result != 0) // This func returns 0 on success for some reason { - spdlog::error( - "ProcessMessageBuffer was unable to find function with name '{}' on {}. Is it global?", - message.functionName, - GetContextName(context)); + NS::log::squirrel_logger<context>()->error( + "ProcessMessageBuffer was unable to find function with name '{}'. Is it global?", message.functionName); return; } pushobject(m_pSQVM->sqvm, &functionobj); // Push the function object diff --git a/NorthstarDLL/squirrel.h b/NorthstarDLL/squirrel.h index 65dd66c5..a1f1dd5f 100644 --- a/NorthstarDLL/squirrel.h +++ b/NorthstarDLL/squirrel.h @@ -3,6 +3,7 @@ #include "squirrelclasstypes.h" #include "squirrelautobind.h" #include "vector.h" +#include "logging.h" // stolen from ttf2sdk: sqvm types typedef float SQFloat; @@ -36,6 +37,13 @@ const char* GetContextName_Short(ScriptContext context); eSQReturnType SQReturnTypeFromString(const char* pReturnType); const char* SQTypeNameFromID(const int iTypeId); +std::shared_ptr<ColoredLogger> getSquirrelLoggerByContext(ScriptContext context); + +namespace NS::log +{ + template <ScriptContext context> std::shared_ptr<spdlog::logger> squirrel_logger(); +}; // namespace NS::log + void schedule_call_external(ScriptContext context, const char* func_name, SquirrelMessage_External_Pop function); // This base class means that only the templated functions have to be rebuilt for each template instance @@ -297,6 +305,7 @@ template <ScriptContext context> class SquirrelManager : public virtual Squirrel int result = sq_getfunction(m_pSQVM->sqvm, funcname, &functionobj, 0); if (result != 0) // This func returns 0 on success for some reason { + NS::log::squirrel_logger<context>()->error("Call was unable to find function with name '{}'. Is it global?", funcname); return SQRESULT_ERROR; } pushobject(m_pSQVM->sqvm, &functionobj); // Push the function object @@ -319,6 +328,7 @@ template <ScriptContext context> class SquirrelManager : public virtual Squirrel int result = sq_getfunction(m_pSQVM->sqvm, funcname, &functionobj, 0); if (result != 0) // This func returns 0 on success for some reason { + NS::log::squirrel_logger<context>()->error("Call was unable to find function with name '{}'. Is it global?", funcname); return SQRESULT_ERROR; } pushobject(m_pSQVM->sqvm, &functionobj); // Push the function object |