From d528ec69f15022a8d067675728fd874064656a94 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:28:04 +0200 Subject: [PATCH] Add wrapper for reading netmsg types --- r5dev/engine/net.cpp | 13 +++++++++++++ r5dev/engine/net.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/r5dev/engine/net.cpp b/r5dev/engine/net.cpp index b483cd08..498c186c 100644 --- a/r5dev/engine/net.cpp +++ b/r5dev/engine/net.cpp @@ -178,6 +178,19 @@ void NET_RemoveChannel(CClient* pClient, int nIndex, const char* szReason, uint8 g_ServerPlayer[nIndex].Reset(); // Reset ServerPlayer slot. #endif // !CLIENT_DLL } + +//----------------------------------------------------------------------------- +// Purpose: reads the net message type from buffer +// Input : &outType - +// &buffer - +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +bool NET_ReadMessageType(int* outType, bf_read* buffer) +{ + *outType = buffer->ReadUBitLong(NETMSG_TYPE_BITS); + return !buffer->IsOverflowed(); +} + #endif // !NETCONSOLE //----------------------------------------------------------------------------- diff --git a/r5dev/engine/net.h b/r5dev/engine/net.h index 616b4727..51e1763c 100644 --- a/r5dev/engine/net.h +++ b/r5dev/engine/net.h @@ -48,6 +48,8 @@ void NET_GenerateKey(); void NET_PrintFunc(const char* fmt, ...); void NET_RemoveChannel(CClient* pClient, int nIndex, const char* szReason, uint8_t bBadRep, bool bRemoveNow); +bool NET_ReadMessageType(int* outType, bf_read* buffer); + /////////////////////////////////////////////////////////////////////////////// extern netadr_t* g_pNetAdr; extern netkey_t* g_pNetKey;