mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Engine: add implementation for registering new netmessages
This commit is contained in:
parent
3b3127c2cf
commit
8abbed283e
@ -264,6 +264,18 @@ bool CClient::VConnect(CClient* pClient, const char* szName, CNetChan* pNetChan,
|
||||
return pClient->Connect(szName, pNetChan, bFakePlayer, conVars, szMessage, nMessageSize);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers net messages
|
||||
// Input : *pClient -
|
||||
// *pChan -
|
||||
// Output : true if setup was successful, false otherwise
|
||||
//---------------------------------------------------------------------------------
|
||||
bool CClient::VConnectionStart(CClient* pClient, CNetChan* pChan)
|
||||
{
|
||||
pClient->RegisterNetMsgs(pChan);
|
||||
return CClient__ConnectionStart(pClient, pChan);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: disconnect client
|
||||
// Input : nRepLvl -
|
||||
@ -309,6 +321,14 @@ void CClient::VActivatePlayer(CClient* pClient)
|
||||
#endif // !CLIENT_DLL
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers net messages
|
||||
// Input : *chan
|
||||
//---------------------------------------------------------------------------------
|
||||
void CClient::RegisterNetMsgs(CNetChan* chan)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: send a net message with replay.
|
||||
// set 'CNetMessage::m_nGroup' to 'NoReplay' to disable replay.
|
||||
@ -618,6 +638,7 @@ void VClient::Detour(const bool bAttach) const
|
||||
#ifndef CLIENT_DLL
|
||||
DetourSetup(&CClient__Clear, &CClient::VClear, bAttach);
|
||||
DetourSetup(&CClient__Connect, &CClient::VConnect, bAttach);
|
||||
DetourSetup(&CClient__ConnectionStart, &CClient::VConnectionStart, bAttach);
|
||||
DetourSetup(&CClient__ActivatePlayer, &CClient::VActivatePlayer, bAttach);
|
||||
DetourSetup(&CClient__SendNetMsgEx, &CClient::VSendNetMsgEx, bAttach);
|
||||
//DetourSetup(&CClient__SendSnapshot, &CClient::VSendSnapshot, bAttach);
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
inline bool IsFakeClient(void) const { return m_bFakePlayer; }
|
||||
inline bool IsHumanPlayer(void) const { if (!IsConnected() || IsFakeClient()) { return false; } return true; }
|
||||
|
||||
void RegisterNetMsgs(CNetChan* chan);
|
||||
bool SendNetMsgEx(CNetMessage* pMsg, bool bLocal, bool bForceReliable, bool bVoice);
|
||||
|
||||
bool Authenticate(const char* const playerName, char* const reasonBuf, const size_t reasonBufLen);
|
||||
@ -117,6 +118,8 @@ public: // Hook statics:
|
||||
static bool VConnect(CClient* pClient, const char* szName, CNetChan* pNetChan, bool bFakePlayer,
|
||||
CUtlVector<NET_SetConVar::cvar_t>* conVars, char* szMessage, int nMessageSize);
|
||||
|
||||
static bool VConnectionStart(CClient* pClient, CNetChan* pChan);
|
||||
|
||||
static void VActivatePlayer(CClient* pClient);
|
||||
static void* VSendSnapshot(CClient* pClient, CClientFrame* pFrame, int nTick, int nTickAck);
|
||||
static bool VSendNetMsgEx(CClient* pClient, CNetMessage* pMsg, bool bLocal, bool bForceReliable, bool bVoice);
|
||||
@ -291,6 +294,7 @@ private:
|
||||
/* ==== CBASECLIENT ===================================================================================================================================================== */
|
||||
inline bool(*CClient__Connect)(CClient* pClient, const char* szName, CNetChan* pNetChan, bool bFakePlayer, CUtlVector<NET_SetConVar::cvar_t>* conVars, char* szMessage, int nMessageSize);
|
||||
inline bool(*CClient__Disconnect)(CClient* pClient, const Reputation_t nRepLvl, const char* szReason, ...);
|
||||
inline bool(*CClient__ConnectionStart)(CClient* pClient, CNetChan* pChan);
|
||||
inline void(*CClient__Clear)(CClient* pClient);
|
||||
inline void(*CClient__ActivatePlayer)(CClient* pClient);
|
||||
inline bool(*CClient__SetSignonState)(CClient* pClient, SIGNONSTATE signon);
|
||||
@ -309,6 +313,7 @@ class VClient : public IDetour
|
||||
{
|
||||
LogFunAdr("CClient::Connect", CClient__Connect);
|
||||
LogFunAdr("CClient::Disconnect", CClient__Disconnect);
|
||||
LogFunAdr("CClient::ConnectionStart", CClient__ConnectionStart);
|
||||
LogFunAdr("CClient::Clear", CClient__Clear);
|
||||
LogFunAdr("CClient::ActivatePlayer", CClient__ActivatePlayer);
|
||||
LogFunAdr("CClient::SetSignonState", CClient__SetSignonState);
|
||||
@ -324,6 +329,7 @@ class VClient : public IDetour
|
||||
{
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 56 48 83 EC 20 41 0F B6 E9").GetPtr(CClient__Connect);
|
||||
g_GameDll.FindPatternSIMD("48 8B C4 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ?? 49 8B F8 8B F2").GetPtr(CClient__Disconnect);
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC ?? 48 8B 05 ?? ?? ?? ?? 48 8B EA 4C 8B F1").GetPtr(CClient__ConnectionStart);
|
||||
g_GameDll.FindPatternSIMD("40 53 41 56 41 57 48 83 EC 20 48 8B D9 48 89 74").GetPtr(CClient__Clear);
|
||||
g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 8B 81 B0 03 ?? ?? 48 8B D9 C6").GetPtr(CClient__ActivatePlayer);
|
||||
g_GameDll.FindPatternSIMD("40 53 55 56 57 41 56 48 83 EC 40 48 8B 05 ?? ?? ?? ??").GetPtr(CClient__SendNetMsgEx);
|
||||
|
@ -162,6 +162,18 @@ float CClientState::GetFrameTime() const
|
||||
return m_flFrameTime;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers net messages
|
||||
// Input : *pClient -
|
||||
// *pChan -
|
||||
// Output : true if setup was successful, false otherwise
|
||||
//---------------------------------------------------------------------------------
|
||||
bool CClientState::VConnectionStart(CClientState* pClient, CNetChan* pChan)
|
||||
{
|
||||
pClient->RegisterNetMsgs(pChan);
|
||||
return CClientState__ConnectionStart(pClient, pChan);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose: called when connection to the server has been closed
|
||||
//------------------------------------------------------------------------------
|
||||
@ -491,8 +503,17 @@ void CClientState::Reconnect()
|
||||
Cbuf_AddText(ECommandTarget_t::CBUF_FIRST_PLAYER, buf, cmd_source_t::kCommandSrcCode);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: registers net messages
|
||||
// Input : *chan
|
||||
//---------------------------------------------------------------------------------
|
||||
void CClientState::RegisterNetMsgs(CNetChan* chan)
|
||||
{
|
||||
}
|
||||
|
||||
void VClientState::Detour(const bool bAttach) const
|
||||
{
|
||||
DetourSetup(&CClientState__ConnectionStart, &CClientState::VConnectionStart, bAttach);
|
||||
DetourSetup(&CClientState__ConnectionClosing, &CClientState::VConnectionClosing, bAttach);
|
||||
DetourSetup(&CClientState__ProcessStringCmd, &CClientState::_ProcessStringCmd, bAttach);
|
||||
DetourSetup(&CClientState__ProcessServerTick, &CClientState::VProcessServerTick, bAttach);
|
||||
|
@ -36,6 +36,7 @@ class CClientState : CS_INetChannelHandler, IConnectionlessPacketHandler, IServe
|
||||
{
|
||||
friend class ClientDataBlockReceiver;
|
||||
public: // Hook statics.
|
||||
static bool VConnectionStart(CClientState* pClient, CNetChan* pChan);
|
||||
static void VConnectionClosing(CClientState* thisptr, const char* szReason);
|
||||
static bool _ProcessStringCmd(CClientState* thisptr, NET_StringCmd* msg);
|
||||
static bool VProcessServerTick(CClientState* thisptr, SVC_ServerTick* msg);
|
||||
@ -66,6 +67,8 @@ public:
|
||||
|
||||
void Reconnect();
|
||||
|
||||
void RegisterNetMsgs(CNetChan* chan);
|
||||
|
||||
protected:
|
||||
FORCEINLINE CClientState* GetShiftedBasePointer(void)
|
||||
{
|
||||
@ -225,6 +228,7 @@ extern CClientState** g_pClientState_Shifted; // Shifted by 0x10 forward!
|
||||
inline void(*CClientState__RunFrame)(CClientState* thisptr);
|
||||
inline void(*CClientState__Connect)(CClientState* thisptr, connectparams_t* connectParams);
|
||||
inline void(*CClientState__Disconnect)(CClientState* thisptr, bool bSendTrackingContext);
|
||||
inline bool(*CClientState__ConnectionStart)(CClientState* thisptr, CNetChan* chan);
|
||||
inline void(*CClientState__ConnectionClosing)(CClientState* thisptr, const char* szReason);
|
||||
inline bool(*CClientState__HookClientStringTable)(CClientState* thisptr, const char* tableName);
|
||||
|
||||
@ -241,6 +245,7 @@ class VClientState : public IDetour
|
||||
LogFunAdr("CClientState::RunFrame", CClientState__RunFrame);
|
||||
LogFunAdr("CClientState::Connect", CClientState__Connect);
|
||||
LogFunAdr("CClientState::Disconnect", CClientState__Disconnect);
|
||||
LogFunAdr("CClientState::ConnectionStart", CClientState__ConnectionStart);
|
||||
LogFunAdr("CClientState::ConnectionClosing", CClientState__ConnectionClosing);
|
||||
LogFunAdr("CClientState::HookClientStringTable", CClientState__HookClientStringTable);
|
||||
LogFunAdr("CClientState::ProcessStringCmd", CClientState__ProcessStringCmd);
|
||||
@ -255,6 +260,7 @@ class VClientState : public IDetour
|
||||
g_GameDll.FindPatternSIMD("40 53 48 81 EC ?? ?? ?? ?? 83 B9 ?? ?? ?? ?? ?? 48 8B D9 7D 0B").GetPtr(CClientState__RunFrame);
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 81 EC ?? ?? ?? ?? 48 8B 32").GetPtr(CClientState__Connect);
|
||||
g_GameDll.FindPatternSIMD("40 56 57 41 54 41 55 41 57 48 83 EC 30 44 0F B6 FA").GetPtr(CClientState__Disconnect);
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC ?? 48 8B 05 ?? ?? ?? ?? 48 8B F2").GetPtr(CClientState__ConnectionStart);
|
||||
g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 83 B9 ?? ?? ?? ?? ?? 48 8B DA 0F 8E ?? ?? ?? ??").GetPtr(CClientState__ConnectionClosing);
|
||||
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 20 48 8B D9 48 8B FA 48 8B 89 ?? ?? ?? ?? 48 85 C9 0F 84 ?? ?? ?? ??").GetPtr(CClientState__HookClientStringTable);
|
||||
g_GameDll.FindPatternSIMD("40 53 48 81 EC ?? ?? ?? ?? 80 B9 ?? ?? ?? ?? ?? 48 8B DA").GetPtr(CClientState__ProcessStringCmd);
|
||||
|
@ -7,6 +7,21 @@
|
||||
#define MAX_FLOWS 2 // in & out
|
||||
#include "tier1/NetAdr.h"
|
||||
|
||||
#define REGISTER_NET_MSG( name ) \
|
||||
NET_##name * p##name = new NET_##name(); \
|
||||
p##name->m_pMessageHandler = this; \
|
||||
chan->RegisterMessage( p##name ); \
|
||||
|
||||
#define REGISTER_SVC_MSG( name ) \
|
||||
SVC_##name * p##name = new SVC_##name(); \
|
||||
p##name->m_pMessageHandler = this; \
|
||||
chan->RegisterMessage( p##name ); \
|
||||
|
||||
#define REGISTER_CLC_MSG( name ) \
|
||||
CLC_##name * p##name = new CLC_##name(); \
|
||||
p##name->m_pMessageHandler = this; \
|
||||
chan->RegisterMessage( p##name ); \
|
||||
|
||||
class IClientMessageHandler
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user