aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/clientchathooks.cpp
diff options
context:
space:
mode:
authorTom Barham <me@cpdt.dev>2022-03-07 04:45:07 +1000
committerGitHub <noreply@github.com>2022-03-06 18:45:07 +0000
commit17aaab6f250cd4d576fce78392596762e2a09142 (patch)
tree9e4b125126cefc67f64441958111ac12031a6e7c /NorthstarDedicatedTest/clientchathooks.cpp
parent7f7ff36ad258e4cd01dd2fe8742befe3c73f4293 (diff)
downloadNorthstarLauncher-17aaab6f250cd4d576fce78392596762e2a09142.tar.gz
NorthstarLauncher-17aaab6f250cd4d576fce78392596762e2a09142.zip
Fix #101, chat hook memory leak (#105)
Diffstat (limited to 'NorthstarDedicatedTest/clientchathooks.cpp')
-rw-r--r--NorthstarDedicatedTest/clientchathooks.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/NorthstarDedicatedTest/clientchathooks.cpp b/NorthstarDedicatedTest/clientchathooks.cpp
index 62166cb2..74418c06 100644
--- a/NorthstarDedicatedTest/clientchathooks.cpp
+++ b/NorthstarDedicatedTest/clientchathooks.cpp
@@ -17,14 +17,14 @@ struct ChatTags
static void CHudChat__AddGameLineHook(void* self, const char* message, int inboxId, bool isTeam, bool isDead)
{
- if (g_ClientSquirrelManager->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
+ // This hook is called for each HUD, but we only want our logic to run once.
+ if (self != *CHudChat::allHuds)
{
- // This hook is called for each HUD, but we only want our logic to run once.
- if (!IsFirstHud(self))
- {
- return;
- }
+ return;
+ }
+ if (g_ClientSquirrelManager->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
+ {
int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
bool isAnonymous = senderId == 0;
bool isCustom = isAnonymous || (inboxId & CUSTOM_MESSAGE_INDEX_BIT);
@@ -46,7 +46,12 @@ static void CHudChat__AddGameLineHook(void* self, const char* message, int inbox
g_ClientSquirrelManager->call(5);
}
else
- CHudChat__AddGameLine(self, message, inboxId, isTeam, isDead);
+ {
+ for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next)
+ {
+ CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
+ }
+ }
}
// void NSChatWrite( int context, string str )