aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-09-04 22:47:02 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-09 00:43:59 +0200
commitb80d330ac865aa97177825d09c7b1edc09114d11 (patch)
tree7402fd0f1603b6b74d6341a0abd2150d622435e8
parent4d6452865eb3e2b2abec3f5afe9de66ca7f1855b (diff)
downloadNorthstarLauncher-b80d330ac865aa97177825d09c7b1edc09114d11.tar.gz
NorthstarLauncher-b80d330ac865aa97177825d09c7b1edc09114d11.zip
Get rid of context filerefactor-remove-context-file
This is basically 77a1195d77034c00959dfd030e2eb7a57d58a88d from refactor PR redone on top of main
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj2
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj.filters6
-rw-r--r--NorthstarDLL/context.cpp14
-rw-r--r--NorthstarDLL/context.h11
-rw-r--r--NorthstarDLL/logging.h1
-rw-r--r--NorthstarDLL/modmanager.h4
-rw-r--r--NorthstarDLL/sourceinterface.cpp4
-rw-r--r--NorthstarDLL/squirrel.cpp26
-rw-r--r--NorthstarDLL/squirrel.h11
9 files changed, 38 insertions, 41 deletions
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj
index 19444e8d..70200fa6 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj
+++ b/NorthstarDLL/NorthstarDLL.vcxproj
@@ -128,7 +128,6 @@
<ClInclude Include="color.h" />
<ClInclude Include="concommand.h" />
<ClInclude Include="nsprefix.h" />
- <ClInclude Include="context.h" />
<ClInclude Include="convar.h" />
<ClInclude Include="cvar.h" />
<ClInclude Include="dedicated.h" />
@@ -581,7 +580,6 @@
<ClCompile Include="clientvideooverrides.cpp" />
<ClCompile Include="concommand.cpp" />
<ClCompile Include="nsprefix.cpp" />
- <ClCompile Include="context.cpp" />
<ClCompile Include="convar.cpp" />
<ClCompile Include="cvar.cpp" />
<ClCompile Include="debugoverlay.cpp" />
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters
index ebbe4fa4..0a224c80 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj.filters
+++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters
@@ -168,9 +168,6 @@
<ClInclude Include="logging.h">
<Filter>Header Files\Shared</Filter>
</ClInclude>
- <ClInclude Include="context.h">
- <Filter>Header Files\Shared</Filter>
- </ClInclude>
<ClInclude Include="sourceinterface.h">
<Filter>Header Files\Shared</Filter>
</ClInclude>
@@ -1550,9 +1547,6 @@
<ClCompile Include="logging.cpp">
<Filter>Source Files\Shared</Filter>
</ClCompile>
- <ClCompile Include="context.cpp">
- <Filter>Source Files\Shared</Filter>
- </ClCompile>
<ClCompile Include="sourceinterface.cpp">
<Filter>Source Files\Shared</Filter>
</ClCompile>
diff --git a/NorthstarDLL/context.cpp b/NorthstarDLL/context.cpp
deleted file mode 100644
index 19ee85a3..00000000
--- a/NorthstarDLL/context.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pch.h"
-#include "context.h"
-
-const char* GetContextName(ScriptContext context)
-{
- if (context == ScriptContext::CLIENT)
- return "CLIENT";
- else if (context == ScriptContext::SERVER)
- return "SERVER";
- else if (context == ScriptContext::UI)
- return "UI";
-
- return "";
-}
diff --git a/NorthstarDLL/context.h b/NorthstarDLL/context.h
deleted file mode 100644
index d872f738..00000000
--- a/NorthstarDLL/context.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-enum class ScriptContext : int
-{
- SERVER,
- CLIENT,
- UI,
- NONE
-};
-
-const char* GetContextName(ScriptContext context);
diff --git a/NorthstarDLL/logging.h b/NorthstarDLL/logging.h
index 59537e01..dc21e6d9 100644
--- a/NorthstarDLL/logging.h
+++ b/NorthstarDLL/logging.h
@@ -1,5 +1,4 @@
#pragma once
-#include "context.h"
void CreateLogFiles();
void InitialiseLogging();
diff --git a/NorthstarDLL/modmanager.h b/NorthstarDLL/modmanager.h
index 83cc0e40..815946ad 100644
--- a/NorthstarDLL/modmanager.h
+++ b/NorthstarDLL/modmanager.h
@@ -5,6 +5,7 @@
#include <filesystem>
#include "rapidjson/document.h"
#include "memalloc.h"
+#include "squirrel.h"
namespace fs = std::filesystem;
@@ -24,9 +25,6 @@ struct ModConVar
struct ModScriptCallback
{
public:
- // would've liked to make it possible to hook arbitrary codecallbacks, but couldn't find a function that calls some ui ones
- // std::string HookedCodeCallback;
-
ScriptContext Context;
// called before the codecallback is executed
diff --git a/NorthstarDLL/sourceinterface.cpp b/NorthstarDLL/sourceinterface.cpp
index 56020e5e..4ef241ea 100644
--- a/NorthstarDLL/sourceinterface.cpp
+++ b/NorthstarDLL/sourceinterface.cpp
@@ -2,11 +2,7 @@
#include "sourceinterface.h"
#include "hooks.h"
#include "hookutils.h"
-
#include "sourceconsole.h"
-#include "context.h"
-#include "convar.h"
-#include <iostream>
// really wanted to do a modular callback system here but honestly couldn't be bothered so hardcoding stuff for now: todo later
diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp
index 2fa957fb..b52d266f 100644
--- a/NorthstarDLL/squirrel.cpp
+++ b/NorthstarDLL/squirrel.cpp
@@ -107,6 +107,32 @@ SquirrelManager<ScriptContext::CLIENT>* g_ClientSquirrelManager;
SquirrelManager<ScriptContext::SERVER>* g_ServerSquirrelManager;
SquirrelManager<ScriptContext::UI>* g_UISquirrelManager;
+template <ScriptContext context> SquirrelManager<context>* GetSquirrelManager()
+{
+ switch (context)
+ {
+ case ScriptContext::CLIENT:
+ return g_ClientSquirrelManager;
+ case ScriptContext::SERVER:
+ return g_ServerSquirrelManager;
+ case ScriptContext::UI:
+ return g_UISquirrelManager;
+ }
+}
+
+const char* GetContextName(ScriptContext context)
+{
+ switch (context)
+ {
+ case ScriptContext::CLIENT:
+ return "CLIENT";
+ case ScriptContext::SERVER:
+ return "SERVER";
+ case ScriptContext::UI:
+ return "UI";
+ }
+}
+
SQInteger NSTestFunc(void* sqvm)
{
return 1;
diff --git a/NorthstarDLL/squirrel.h b/NorthstarDLL/squirrel.h
index e465ddc6..ab982736 100644
--- a/NorthstarDLL/squirrel.h
+++ b/NorthstarDLL/squirrel.h
@@ -544,6 +544,16 @@ struct SQArray
} \
}
+enum class ScriptContext : int
+{
+ SERVER,
+ CLIENT,
+ UI,
+ NONE
+};
+
+const char* GetContextName(ScriptContext context);
+
// core sqvm funcs
typedef SQRESULT (*sq_compilebufferType)(void* sqvm, CompileBufferState* compileBuffer, const char* file, int a1, ScriptContext a2);
extern sq_compilebufferType ClientSq_compilebuffer;
@@ -811,3 +821,4 @@ template <ScriptContext context> class SquirrelManager
extern SquirrelManager<ScriptContext::CLIENT>* g_ClientSquirrelManager;
extern SquirrelManager<ScriptContext::SERVER>* g_ServerSquirrelManager;
extern SquirrelManager<ScriptContext::UI>* g_UISquirrelManager;
+template <ScriptContext context> SquirrelManager<context>* GetSquirrelManager();