aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters6
-rw-r--r--NorthstarDedicatedTest/context.cpp14
-rw-r--r--NorthstarDedicatedTest/context.h11
-rw-r--r--NorthstarDedicatedTest/logging.h1
-rw-r--r--NorthstarDedicatedTest/modmanager.h4
-rw-r--r--NorthstarDedicatedTest/sourceinterface.cpp4
-rw-r--r--NorthstarDedicatedTest/squirrel.cpp26
-rw-r--r--NorthstarDedicatedTest/squirrel.h11
9 files changed, 38 insertions, 41 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index 58afcd9f..1125b87e 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -132,7 +132,6 @@
<ClInclude Include="color.h" />
<ClInclude Include="concommand.h" />
<ClInclude Include="configurables.h" />
- <ClInclude Include="context.h" />
<ClInclude Include="convar.h" />
<ClInclude Include="cvar.h" />
<ClInclude Include="dedicated.h" />
@@ -585,7 +584,6 @@
<ClCompile Include="clientvideooverrides.cpp" />
<ClCompile Include="concommand.cpp" />
<ClCompile Include="configurables.cpp" />
- <ClCompile Include="context.cpp" />
<ClCompile Include="convar.cpp" />
<ClCompile Include="cvar.cpp" />
<ClCompile Include="debugoverlay.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 23e406a3..eb4f2a5c 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -165,9 +165,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>
@@ -1541,9 +1538,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/NorthstarDedicatedTest/context.cpp b/NorthstarDedicatedTest/context.cpp
deleted file mode 100644
index 7478faa3..00000000
--- a/NorthstarDedicatedTest/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 "";
-} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/context.h b/NorthstarDedicatedTest/context.h
deleted file mode 100644
index b6097780..00000000
--- a/NorthstarDedicatedTest/context.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-enum class ScriptContext : int
-{
- SERVER,
- CLIENT,
- UI,
- NONE
-};
-
-const char* GetContextName(ScriptContext context); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/logging.h b/NorthstarDedicatedTest/logging.h
index f9a287b5..a3aa60cc 100644
--- a/NorthstarDedicatedTest/logging.h
+++ b/NorthstarDedicatedTest/logging.h
@@ -1,5 +1,4 @@
#pragma once
-#include "context.h"
void CreateLogFiles();
void InitialiseLogging(); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/modmanager.h b/NorthstarDedicatedTest/modmanager.h
index 5c325d7c..ac7f7425 100644
--- a/NorthstarDedicatedTest/modmanager.h
+++ b/NorthstarDedicatedTest/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/NorthstarDedicatedTest/sourceinterface.cpp b/NorthstarDedicatedTest/sourceinterface.cpp
index 24657739..73e93849 100644
--- a/NorthstarDedicatedTest/sourceinterface.cpp
+++ b/NorthstarDedicatedTest/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/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp
index 1e405e29..1772bdb8 100644
--- a/NorthstarDedicatedTest/squirrel.cpp
+++ b/NorthstarDedicatedTest/squirrel.cpp
@@ -44,6 +44,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";
+ }
+}
+
ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (HMODULE baseAddress)
{
HookEnabler hook;
diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h
index 453db83b..4dc3240c 100644
--- a/NorthstarDedicatedTest/squirrel.h
+++ b/NorthstarDedicatedTest/squirrel.h
@@ -58,6 +58,16 @@ struct SQFuncRegistration
}
};
+enum class ScriptContext : int
+{
+ SERVER,
+ CLIENT,
+ UI,
+ NONE
+};
+
+const char* GetContextName(ScriptContext context);
+
// core sqvm funcs
typedef int64_t (*RegisterSquirrelFuncType)(void* sqvm, SQFuncRegistration* funcReg, char unknown);
extern RegisterSquirrelFuncType ClientRegisterSquirrelFunc;
@@ -222,3 +232,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(); \ No newline at end of file