2022-04-27 16:29:14 +02:00
|
|
|
//===============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
// $NoKeywords: $
|
|
|
|
//
|
|
|
|
//===============================================================================//
|
|
|
|
// netmessages.cpp: implementation of the CNetMessage types.
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "core/stdafx.h"
|
2022-08-15 02:59:41 +02:00
|
|
|
#include "engine/net.h"
|
2022-04-27 16:29:14 +02:00
|
|
|
#include "common/netmessages.h"
|
|
|
|
|
2022-08-15 14:44:54 +02:00
|
|
|
bool SVC_Print::ProcessImpl()
|
2022-04-27 16:29:14 +02:00
|
|
|
{
|
2022-04-27 18:42:49 +02:00
|
|
|
if (this->m_szText)
|
2022-04-27 16:29:14 +02:00
|
|
|
{
|
2022-04-27 18:42:49 +02:00
|
|
|
DevMsg(eDLL_T::SERVER, this->m_szText);
|
2022-04-27 16:29:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true; // Original just return true also.
|
|
|
|
}
|
|
|
|
|
2022-08-15 14:44:54 +02:00
|
|
|
bool SVC_UserMessage::ProcessImpl()
|
2022-04-30 03:00:24 +02:00
|
|
|
{
|
|
|
|
bf_read buf = m_DataIn;
|
2022-08-15 02:59:41 +02:00
|
|
|
int type = buf.ReadByte();
|
2022-04-30 03:00:24 +02:00
|
|
|
|
2022-08-15 02:59:41 +02:00
|
|
|
if (type == HUD_PRINTCONSOLE ||
|
|
|
|
type == HUD_PRINTCENTER)
|
2022-04-30 03:00:24 +02:00
|
|
|
{
|
2022-08-15 02:59:41 +02:00
|
|
|
char text[MAX_USER_MSG_DATA];
|
2022-04-30 03:00:24 +02:00
|
|
|
buf.ReadString(text, sizeof(text));
|
2022-08-15 02:59:41 +02:00
|
|
|
if (strnlen_s(text, sizeof(text)) >= NET_MIN_MESSAGE)
|
2022-04-30 03:00:24 +02:00
|
|
|
{
|
|
|
|
DevMsg(eDLL_T::SERVER, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SVC_UserMessage_Process(this); // Need to return original.
|
|
|
|
}
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
void V_NetMessages::Attach() const
|
2022-04-27 16:29:14 +02:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
#if !defined(DEDICATED)
|
2022-08-15 14:44:54 +02:00
|
|
|
auto SVCPrint = &SVC_Print::ProcessImpl;
|
|
|
|
auto SVCUserMessage = &SVC_UserMessage::ProcessImpl;
|
2022-09-09 19:47:31 +02:00
|
|
|
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VFTable, (LPVOID&)SVCPrint, 3, (LPVOID*)&SVC_Print_Process);
|
|
|
|
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VFTable, (LPVOID&)SVCUserMessage, 3, (LPVOID*)&SVC_UserMessage_Process);
|
2023-01-25 02:26:52 +01:00
|
|
|
#endif // DEDICATED
|
2022-04-27 16:29:14 +02:00
|
|
|
}
|
|
|
|
|
2023-01-25 02:26:52 +01:00
|
|
|
void V_NetMessages::Detach() const
|
2022-04-27 16:29:14 +02:00
|
|
|
{
|
2023-01-25 02:26:52 +01:00
|
|
|
#if !defined(DEDICATED)
|
2022-04-30 03:00:24 +02:00
|
|
|
void* hkRestore = nullptr;
|
2022-09-09 19:47:31 +02:00
|
|
|
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VFTable, (LPVOID)SVC_Print_Process, 3, (LPVOID*)&hkRestore);
|
|
|
|
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VFTable, (LPVOID)SVC_UserMessage_Process, 3, (LPVOID*)&hkRestore);
|
2023-01-25 02:26:52 +01:00
|
|
|
#endif // DEDICATED
|
2022-04-27 16:29:14 +02:00
|
|
|
}
|