aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/clientchathooks.cpp
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-08-16 01:12:59 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-08-16 01:12:59 +0100
commit082f3893215797268d7ac8c1000ebe371f276af7 (patch)
treeb5cc677a49635a9244559e235d4915c064c9f6c4 /NorthstarDLL/clientchathooks.cpp
parentb30a385fc25dad05e568ae8538f5aa3656c5c8d4 (diff)
downloadNorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.tar.gz
NorthstarLauncher-082f3893215797268d7ac8c1000ebe371f276af7.zip
lots of stuff idk
Diffstat (limited to 'NorthstarDLL/clientchathooks.cpp')
-rw-r--r--NorthstarDLL/clientchathooks.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/NorthstarDLL/clientchathooks.cpp b/NorthstarDLL/clientchathooks.cpp
index e4364db5..5b1f2e3f 100644
--- a/NorthstarDLL/clientchathooks.cpp
+++ b/NorthstarDLL/clientchathooks.cpp
@@ -1,81 +1,81 @@
-#include "pch.h"
-#include "squirrel.h"
-#include "serverchathooks.h"
-#include "localchatwriter.h"
-
-#include <rapidjson/document.h>
-
-AUTOHOOK_INIT()
-
-AUTOHOOK(CHudChat__AddGameLine, client.dll + 0x22E580,
-void,, (void* self, const char* message, int inboxId, bool isTeam, bool isDead))
-{
- // This hook is called for each HUD, but we only want our logic to run once.
- if (self != *CHudChat::allHuds)
- return;
-
- if (g_pClientSquirrel->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
- {
- int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
- bool isAnonymous = senderId == 0;
- bool isCustom = isAnonymous || (inboxId & CUSTOM_MESSAGE_INDEX_BIT);
-
- // Type is set to 0 for non-custom messages, custom messages have a type encoded as the first byte
- int type = 0;
- const char* payload = message;
- if (isCustom)
- {
- type = message[0];
- payload = message + 1;
- }
-
- g_pClientSquirrel->pushinteger(g_pClientSquirrel->sqvm2, (int)senderId - 1);
- g_pClientSquirrel->pushstring(g_pClientSquirrel->sqvm2, payload);
- g_pClientSquirrel->pushbool(g_pClientSquirrel->sqvm2, isTeam);
- g_pClientSquirrel->pushbool(g_pClientSquirrel->sqvm2, isDead);
- g_pClientSquirrel->pushinteger(g_pClientSquirrel->sqvm2, type);
- g_pClientSquirrel->call(g_pClientSquirrel->sqvm2, 5);
- }
- else
- for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next)
- CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
-}
-
-// void NSChatWrite( int context, string str )
-SQRESULT SQ_ChatWrite(void* sqvm)
-{
- int context = g_pClientSquirrel->getinteger(sqvm, 1);
- const char* str = g_pClientSquirrel->getstring(sqvm, 2);
-
- LocalChatWriter((LocalChatWriter::Context)context).Write(str);
- return SQRESULT_NULL;
-}
-
-// void NSChatWriteRaw( int context, string str )
-SQRESULT SQ_ChatWriteRaw(void* sqvm)
-{
- int context = g_pClientSquirrel->getinteger(sqvm, 1);
- const char* str = g_pClientSquirrel->getstring(sqvm, 2);
-
- LocalChatWriter((LocalChatWriter::Context)context).InsertText(str);
- return SQRESULT_NULL;
-}
-
-// void NSChatWriteLine( int context, string str )
-SQRESULT SQ_ChatWriteLine(void* sqvm)
-{
- int context = g_pClientSquirrel->getinteger(sqvm, 1);
- const char* str = g_pClientSquirrel->getstring(sqvm, 2);
-
- LocalChatWriter((LocalChatWriter::Context)context).WriteLine(str);
- return SQRESULT_NULL;
-}
-
-ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientChatHooks, ClientSquirrel, (CModule module))
-{
- AUTOHOOK_DISPATCH()
-
- g_pClientSquirrel->AddFuncRegistration("void", "NSChatWrite", "int context, string text", "", SQ_ChatWrite);
- g_pClientSquirrel->AddFuncRegistration("void", "NSChatWriteRaw", "int context, string text", "", SQ_ChatWriteRaw);
- g_pClientSquirrel->AddFuncRegistration("void", "NSChatWriteLine", "int context, string text", "", SQ_ChatWriteLine);
-} \ No newline at end of file
+#include "pch.h"
+#include "squirrel.h"
+#include "serverchathooks.h"
+#include "localchatwriter.h"
+
+#include <rapidjson/document.h>
+
+AUTOHOOK_INIT()
+
+AUTOHOOK(CHudChat__AddGameLine, client.dll + 0x22E580,
+void,, (void* self, const char* message, int inboxId, bool isTeam, bool isDead))
+{
+ // This hook is called for each HUD, but we only want our logic to run once.
+ if (self != *CHudChat::allHuds)
+ return;
+
+ if (g_pSquirrel<ScriptContext::CLIENT>->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
+ {
+ int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
+ bool isAnonymous = senderId == 0;
+ bool isCustom = isAnonymous || (inboxId & CUSTOM_MESSAGE_INDEX_BIT);
+
+ // Type is set to 0 for non-custom messages, custom messages have a type encoded as the first byte
+ int type = 0;
+ const char* payload = message;
+ if (isCustom)
+ {
+ type = message[0];
+ payload = message + 1;
+ }
+
+ g_pSquirrel<ScriptContext::CLIENT>->pushinteger(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, (int)senderId - 1);
+ g_pSquirrel<ScriptContext::CLIENT>->pushstring(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, payload);
+ g_pSquirrel<ScriptContext::CLIENT>->pushbool(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, isTeam);
+ g_pSquirrel<ScriptContext::CLIENT>->pushbool(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, isDead);
+ g_pSquirrel<ScriptContext::CLIENT>->pushinteger(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, type);
+ g_pSquirrel<ScriptContext::CLIENT>->call(g_pSquirrel<ScriptContext::CLIENT>->sqvm2, 5);
+ }
+ else
+ for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next)
+ CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
+}
+
+// void NSChatWrite( int context, string str )
+SQRESULT SQ_ChatWrite(void* sqvm)
+{
+ int context = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 1);
+ const char* str = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 2);
+
+ LocalChatWriter((LocalChatWriter::Context)context).Write(str);
+ return SQRESULT_NULL;
+}
+
+// void NSChatWriteRaw( int context, string str )
+SQRESULT SQ_ChatWriteRaw(void* sqvm)
+{
+ int context = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 1);
+ const char* str = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 2);
+
+ LocalChatWriter((LocalChatWriter::Context)context).InsertText(str);
+ return SQRESULT_NULL;
+}
+
+// void NSChatWriteLine( int context, string str )
+SQRESULT SQ_ChatWriteLine(void* sqvm)
+{
+ int context = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 1);
+ const char* str = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 2);
+
+ LocalChatWriter((LocalChatWriter::Context)context).WriteLine(str);
+ return SQRESULT_NULL;
+}
+
+ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientChatHooks, ClientSquirrel, (CModule module))
+{
+ AUTOHOOK_DISPATCH()
+
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration("void", "NSChatWrite", "int context, string text", "", SQ_ChatWrite);
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration("void", "NSChatWriteRaw", "int context, string text", "", SQ_ChatWriteRaw);
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration("void", "NSChatWriteLine", "int context, string text", "", SQ_ChatWriteLine);
+}