From 6a9fae96aeab36a9a9a32af7cd8d6b0c700d2f2b Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Sun, 6 Mar 2022 18:58:55 +0000
Subject: add support for server=>client script stringcommands
---
.../NorthstarDedicatedTest.vcxproj | 2 ++
.../NorthstarDedicatedTest.vcxproj.filters | 6 ++++++
NorthstarDedicatedTest/dllmain.cpp | 2 ++
.../scriptservertoclientstringcommand.cpp | 25 ++++++++++++++++++++++
.../scriptservertoclientstringcommand.h | 3 +++
5 files changed, 38 insertions(+)
create mode 100644 NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
create mode 100644 NorthstarDedicatedTest/scriptservertoclientstringcommand.h
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index f12a9eee..c5a5ce60 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -553,6 +553,7 @@
+
@@ -609,6 +610,7 @@
+
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 37277e2e..f384e81b 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -1471,6 +1471,9 @@
Header Files\Client
+ Header Files\Client
+
+
Header Files\Client
@@ -1629,6 +1632,9 @@
Source Files\Client
+ Source Files\Client
+
+
Source Files\Client
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index f906e724..6a079da0 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -37,6 +37,7 @@
#include "serverchathooks.h"
#include "clientchathooks.h"
#include "localchatwriter.h"
+#include "scriptservertoclientstringcommand.h"
#include
#include "pch.h"
#include "plugin_abi.h"
@@ -239,6 +240,7 @@ bool InitialiseNorthstar()
AddDllLoadCallback("client.dll", InitialisePluginCommands);
AddDllLoadCallback("client.dll", InitialiseClientChatHooks);
AddDllLoadCallback("client.dll", InitialiseLocalChatWriter);
+ AddDllLoadCallback("client.dll", InitialiseScriptServerToClientStringCommands);
}
AddDllLoadCallback("engine.dll", InitialiseEngineSpewFuncHooks);
diff --git a/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp b/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
new file mode 100644
index 00000000..58d92ec6
--- /dev/null
+++ b/NorthstarDedicatedTest/scriptservertoclientstringcommand.cpp
@@ -0,0 +1,25 @@
+#include "pch.h"
+#include "scriptservertoclientstringcommand.h"
+#include "squirrel.h"
+#include "convar.h"
+#include "concommand.h"
+#include "dedicated.h"
+
+void ConCommand_ns_script_servertoclientstringcommand(const CCommand& arg)
+{
+ if (g_ClientSquirrelManager->sqvm && g_ClientSquirrelManager->setupfunc("NSClientCodeCallback_RecievedServerToClientStringCommand") != SQRESULT_ERROR)
+ {
+ g_ClientSquirrelManager->pusharg(arg.ArgS());
+ g_ClientSquirrelManager->call(1); // todo: doesn't throw or log errors from within this, probably not great behaviour
+ }
+}
+
+void InitialiseScriptServerToClientStringCommands(HMODULE baseAddress)
+{
+ if (IsDedicated())
+ return;
+
+ RegisterConCommand(
+ "ns_script_servertoclientstringcommand", ConCommand_ns_script_servertoclientstringcommand, "",
+ FCVAR_CLIENTDLL | FCVAR_SERVER_CAN_EXECUTE);
+}
\ No newline at end of file
diff --git a/NorthstarDedicatedTest/scriptservertoclientstringcommand.h b/NorthstarDedicatedTest/scriptservertoclientstringcommand.h
new file mode 100644
index 00000000..609c6105
--- /dev/null
+++ b/NorthstarDedicatedTest/scriptservertoclientstringcommand.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void InitialiseScriptServerToClientStringCommands(HMODULE baseAddress);
\ No newline at end of file
--
cgit v1.2.3