add global text chat

use sv_forceChatToTeamOnly 0 to enable global chat
This commit is contained in:
rexx 2022-09-18 20:42:16 +01:00
parent 6f7e275b9a
commit 7d8d515190
3 changed files with 41 additions and 1 deletions

View File

@ -191,6 +191,7 @@ void Systems_Init()
#ifndef CLIENT_DLL
Persistence_Attach();
IVEngineServer_Attach();
CServerGameDLL_Attach();
#endif // !CLIENT_DLL
SQAPI_Attach();
@ -317,6 +318,7 @@ void Systems_Shutdown()
#ifndef CLIENT_DLL
Persistence_Detach();
IVEngineServer_Detach();
CServerGameDLL_Detach();
#endif // !CLIENT_DLL
SQAPI_Detach();
SQVM_Detach();

View File

@ -56,6 +56,29 @@ float CServerGameDLL::GetTickInterval(void)
return CallVFunc<float>(index, this);
}
void __fastcall CServerGameDLL::OnReceivedSayTextMessage(void* thisptr, int senderId, const char* text, bool isTeamChat)
{
#if defined(GAMEDLL_S3)
// set isTeamChat to false so that we can let the convar sv_forceChatToTeamOnly decide whether team chat should be enforced
// this isn't a great way of doing it but it works so meh
CServerGameDLL__OnReceivedSayTextMessage(thisptr, senderId, text, false);
#endif
}
void CServerGameDLL_Attach()
{
#if defined(GAMEDLL_S3)
DetourAttach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage);
#endif
}
void CServerGameDLL_Detach()
{
#if defined(GAMEDLL_S3)
DetourDetach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage);
#endif
}
// Pointer to CServerGameDLL virtual function table.
CServerGameDLL* g_pServerGameDLL = nullptr;
CServerGameClients* g_pServerGameClients = nullptr;

View File

@ -13,14 +13,22 @@ public:
void LevelShutdown(void);
void GameShutdown(void);
float GetTickInterval(void);
static void __fastcall OnReceivedSayTextMessage(void* thisptr, int senderId, const char* text, bool isTeamChat);
};
class CServerGameClients
{
};
inline CMemory p_CServerGameDLL__OnReceivedSayTextMessage;
inline auto CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast<void(__fastcall*)(void* thisptr, int senderId, const char* text, bool isTeamChat)>();
extern CServerGameDLL* g_pServerGameDLL;
extern CServerGameClients* g_pServerGameClients;
void CServerGameDLL_Attach();
void CServerGameDLL_Detach();
///////////////////////////////////////////////////////////////////////////////
class VServerGameDLL : public IDetour
{
@ -30,7 +38,14 @@ class VServerGameDLL : public IDetour
spdlog::debug("| VAR: g_pServerGameClients : {:#18x} |\n", reinterpret_cast<uintptr_t>(g_pServerGameClients));
spdlog::debug("+----------------------------------------------------------------+\n");
}
virtual void GetFun(void) const { }
virtual void GetFun(void) const
{
#if defined(GAMEDLL_S3)
p_CServerGameDLL__OnReceivedSayTextMessage = g_GameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x85\xD2\x0F\x8E\x00\x00\x00\x00\x4C\x8B\xDC"), "xxxx????xxx");
CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast<void(__fastcall*)(void* thisptr, int senderId, const char* text, bool isTeamChat)>();
#endif
}
virtual void GetVar(void) const
{
g_pServerGameDLL = p_SV_CreateBaseline.Offset(0x0).FindPatternSelf("48 8B", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).Deref().RCast<CServerGameDLL*>();