aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/clientchathooks.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-02-25 00:15:28 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-02-25 00:15:28 +0000
commitf2b56ee58261af3052ed63979b7c3f93ea715edb (patch)
tree3b730341b044ca96c253c16c64ee3e635325c008 /NorthstarDedicatedTest/clientchathooks.cpp
parent1fda5cab9d18346e049cf84a9e791bbf89b7a861 (diff)
downloadNorthstarLauncher-f2b56ee58261af3052ed63979b7c3f93ea715edb.tar.gz
NorthstarLauncher-f2b56ee58261af3052ed63979b7c3f93ea715edb.zip
use vanilla chat logic if codecallbacks are missing
Diffstat (limited to 'NorthstarDedicatedTest/clientchathooks.cpp')
-rw-r--r--NorthstarDedicatedTest/clientchathooks.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/NorthstarDedicatedTest/clientchathooks.cpp b/NorthstarDedicatedTest/clientchathooks.cpp
index 81413002..62166cb2 100644
--- a/NorthstarDedicatedTest/clientchathooks.cpp
+++ b/NorthstarDedicatedTest/clientchathooks.cpp
@@ -17,32 +17,36 @@ struct ChatTags
static void CHudChat__AddGameLineHook(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 (!IsFirstHud(self))
+ if (g_ClientSquirrelManager->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
{
- return;
- }
+ // This hook is called for each HUD, but we only want our logic to run once.
+ if (!IsFirstHud(self))
+ {
+ return;
+ }
- int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
- bool isAnonymous = senderId == 0;
- bool isCustom = isAnonymous || (inboxId & CUSTOM_MESSAGE_INDEX_BIT);
+ 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;
- }
+ // 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_ClientSquirrelManager->setupfunc("CHudChat_ProcessMessageStartThread");
- g_ClientSquirrelManager->pusharg((int)senderId - 1);
- g_ClientSquirrelManager->pusharg(payload);
- g_ClientSquirrelManager->pusharg(isTeam);
- g_ClientSquirrelManager->pusharg(isDead);
- g_ClientSquirrelManager->pusharg(type);
- g_ClientSquirrelManager->call(5);
+ g_ClientSquirrelManager->pusharg((int)senderId - 1);
+ g_ClientSquirrelManager->pusharg(payload);
+ g_ClientSquirrelManager->pusharg(isTeam);
+ g_ClientSquirrelManager->pusharg(isDead);
+ g_ClientSquirrelManager->pusharg(type);
+ g_ClientSquirrelManager->call(5);
+ }
+ else
+ CHudChat__AddGameLine(self, message, inboxId, isTeam, isDead);
}
// void NSChatWrite( int context, string str )