aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/clientchathooks.cpp
diff options
context:
space:
mode:
authorEmma Miler <emma.pi@protonmail.com>2022-11-21 00:38:42 +0100
committerGitHub <noreply@github.com>2022-11-20 23:38:42 +0000
commit9e469ac28b610ecb8bce3e6c279660fae78861cf (patch)
tree57274f3be03cb160e42af7ed939274a2a028dbf0 /NorthstarDLL/clientchathooks.cpp
parent70b71ba3d3ad7121c6aabe55271542f55abe4008 (diff)
downloadNorthstarLauncher-9e469ac28b610ecb8bce3e6c279660fae78861cf.tar.gz
NorthstarLauncher-9e469ac28b610ecb8bce3e6c279660fae78861cf.zip
Squirrel bridge v3 (#310)
* Initial * Move squirrelmanager to virtual base class * Implement changes from code review * Formatting * Update squirrel.cpp * Formatting shit * Fix filters * Fix up Use new squirrel autobind syntax Move from `std::vector` to `std::queue` for message buffer Add `NSTestMessageBuffer` * Update squirrel.cpp * Update squirrel.h * Remove inline virtual final because this is stupid I probably had a bit of a brain fart when this was written * Moved to running ProcessMessages in-engine * Remove TestMessageBuffer * Formatting * Rename pushSQObject -> pushobject * Rename some stuff * Update squirrel.h * Formattting * Remove unneeded global access * Oops
Diffstat (limited to 'NorthstarDLL/clientchathooks.cpp')
-rw-r--r--NorthstarDLL/clientchathooks.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/NorthstarDLL/clientchathooks.cpp b/NorthstarDLL/clientchathooks.cpp
index 1a25c897..847b5eb1 100644
--- a/NorthstarDLL/clientchathooks.cpp
+++ b/NorthstarDLL/clientchathooks.cpp
@@ -17,29 +17,22 @@ void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bo
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;
- }
+ int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
+ bool isAnonymous = senderId == 0;
+ bool isCustom = isAnonymous || (inboxId & CUSTOM_MESSAGE_INDEX_BIT);
- g_pSquirrel<ScriptContext::CLIENT>->pushinteger(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, (int)senderId - 1);
- g_pSquirrel<ScriptContext::CLIENT>->pushstring(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, payload);
- g_pSquirrel<ScriptContext::CLIENT>->pushbool(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, isTeam);
- g_pSquirrel<ScriptContext::CLIENT>->pushbool(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, isDead);
- g_pSquirrel<ScriptContext::CLIENT>->pushinteger(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, type);
- g_pSquirrel<ScriptContext::CLIENT>->call(g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM->sqvm, 5);
+ // 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;
}
- else
+
+ SQRESULT result = g_pSquirrel<ScriptContext::CLIENT>->Call(
+ "CHudChat_ProcessMessageStartThread", static_cast<int>(senderId) - 1, payload, isTeam, isDead, type);
+ if (result == SQRESULT_ERROR)
for (CHudChat* hud = *CHudChat::allHuds; hud != NULL; hud = hud->next)
CHudChat__AddGameLine(hud, message, inboxId, isTeam, isDead);
}