From a11012f3bf521650f0229e077c9fd320cfdf76fe Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 16 Apr 2023 11:58:37 +0200 Subject: [PATCH] Set port on global netadr object Set the port so it could be used to compare addresses. --- r5dev/engine/net.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/r5dev/engine/net.cpp b/r5dev/engine/net.cpp index 58978d2a..36686c84 100644 --- a/r5dev/engine/net.cpp +++ b/r5dev/engine/net.cpp @@ -75,6 +75,15 @@ unsigned int NET_Decompress(CLZSS* lzss, unsigned char* pInput, unsigned char* p return lzss->SafeUncompress(pInput, pOutput, unBufSize); } +//----------------------------------------------------------------------------- +// Purpose: configures the network system +//----------------------------------------------------------------------------- +void NET_Config() +{ + v_NET_Config(); + g_pNetAdr->SetPort(htons(u_short(hostport->GetInt()))); +} + //----------------------------------------------------------------------------- // Purpose: sets the user specified encryption key // Input : svNetKey - @@ -300,6 +309,7 @@ const char* NET_ErrorString(int iCode) /////////////////////////////////////////////////////////////////////////////// void VNet::Attach() const { + DetourAttach((LPVOID*)&v_NET_Config, &NET_Config); DetourAttach((LPVOID*)&v_NET_ReceiveDatagram, &NET_ReceiveDatagram); DetourAttach((LPVOID*)&v_NET_SendDatagram, &NET_SendDatagram); DetourAttach((LPVOID*)&v_NET_Decompress, &NET_Decompress); @@ -311,6 +321,7 @@ void VNet::Attach() const void VNet::Detach() const { + DetourDetach((LPVOID*)&v_NET_Config, &NET_Config); DetourDetach((LPVOID*)&v_NET_ReceiveDatagram, &NET_ReceiveDatagram); DetourDetach((LPVOID*)&v_NET_SendDatagram, &NET_SendDatagram); DetourDetach((LPVOID*)&v_NET_Decompress, &NET_Decompress);