mirror of
https://github.com/R2Northstar/NorthstarLauncher
synced 2024-09-27 10:40:39 +02:00
use vanilla chat logic if codecallbacks are missing
This commit is contained in:
parent
1fda5cab9d
commit
f2b56ee582
@ -17,32 +17,36 @@ struct ChatTags
|
|||||||
|
|
||||||
static void CHudChat__AddGameLineHook(void* self, const char* message, int inboxId, bool isTeam, bool isDead)
|
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 (g_ClientSquirrelManager->setupfunc("CHudChat_ProcessMessageStartThread") != SQRESULT_ERROR)
|
||||||
if (!IsFirstHud(self))
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
|
// 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->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
|
||||||
int senderId = inboxId & CUSTOM_MESSAGE_INDEX_MASK;
|
CHudChat__AddGameLine(self, message, inboxId, isTeam, isDead);
|
||||||
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_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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void NSChatWrite( int context, string str )
|
// void NSChatWrite( int context, string str )
|
||||||
|
@ -15,7 +15,7 @@ class CRecipientFilter
|
|||||||
char unknown[58];
|
char unknown[58];
|
||||||
};
|
};
|
||||||
|
|
||||||
CServerGameDLL* gServer;
|
CServerGameDLL* g_pServerGameDLL;
|
||||||
|
|
||||||
typedef void(__fastcall* CServerGameDLL__OnReceivedSayTextMessageType)(
|
typedef void(__fastcall* CServerGameDLL__OnReceivedSayTextMessageType)(
|
||||||
CServerGameDLL* self, unsigned int senderPlayerId, const char* text, int channelId);
|
CServerGameDLL* self, unsigned int senderPlayerId, const char* text, int channelId);
|
||||||
@ -76,18 +76,22 @@ static void CServerGameDLL__OnReceivedSayTextMessageHook(CServerGameDLL* self, u
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ServerSquirrelManager->setupfunc("CServerGameDLL_ProcessMessageStartThread");
|
if (g_ServerSquirrelManager->setupfunc("CServerGameDLL_ProcessMessageStartThread") != SQRESULT_ERROR)
|
||||||
g_ServerSquirrelManager->pusharg((int)senderPlayerId - 1);
|
{
|
||||||
g_ServerSquirrelManager->pusharg(text);
|
g_ServerSquirrelManager->pusharg((int)senderPlayerId - 1);
|
||||||
g_ServerSquirrelManager->pusharg(isTeam);
|
g_ServerSquirrelManager->pusharg(text);
|
||||||
g_ServerSquirrelManager->call(3);
|
g_ServerSquirrelManager->pusharg(isTeam);
|
||||||
|
g_ServerSquirrelManager->call(3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CServerGameDLL__OnReceivedSayTextMessageHookBase(self, senderPlayerId, text, isTeam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatSendMessage(unsigned int playerIndex, const char* text, bool isteam)
|
void ChatSendMessage(unsigned int playerIndex, const char* text, bool isteam)
|
||||||
{
|
{
|
||||||
isSkippingHook = true;
|
isSkippingHook = true;
|
||||||
CServerGameDLL__OnReceivedSayTextMessage(
|
CServerGameDLL__OnReceivedSayTextMessage(
|
||||||
gServer,
|
g_pServerGameDLL,
|
||||||
// Ensure the first bit isn't set, since this indicates a custom message
|
// Ensure the first bit isn't set, since this indicates a custom message
|
||||||
(playerIndex + 1) & CUSTOM_MESSAGE_INDEX_MASK, text, isteam);
|
(playerIndex + 1) & CUSTOM_MESSAGE_INDEX_MASK, text, isteam);
|
||||||
}
|
}
|
||||||
@ -164,7 +168,7 @@ SQRESULT SQ_BroadcastMessage(void* sqvm)
|
|||||||
return SQRESULT_NULL;
|
return SQRESULT_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitialiseServerChatHooks_Engine(HMODULE baseAddress) { gServer = (CServerGameDLL*)((char*)baseAddress + 0x13F0AA98); }
|
void InitialiseServerChatHooks_Engine(HMODULE baseAddress) { g_pServerGameDLL = (CServerGameDLL*)((char*)baseAddress + 0x13F0AA98); }
|
||||||
|
|
||||||
void InitialiseServerChatHooks_Server(HMODULE baseAddress)
|
void InitialiseServerChatHooks_Server(HMODULE baseAddress)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user