From 2aaec6944f323a6f90c2cd4e4b8c3f40300354ab Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:30:53 +0800 Subject: [PATCH] [raknet] Match `RakPeer::NotifyAndFlagForDisconnect(...)` --- raknet/RakPeer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/raknet/RakPeer.cpp b/raknet/RakPeer.cpp index 8e0cac6..f3a5719 100644 --- a/raknet/RakPeer.cpp +++ b/raknet/RakPeer.cpp @@ -2624,17 +2624,22 @@ void RakPeer::OnConnectionRequest( RakPeer::RemoteSystemStruct *remoteSystem, un // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void RakPeer::NotifyAndFlagForDisconnect( const PlayerID playerId, bool performImmediate, unsigned char orderingChannel ) { + if (playerId == UNASSIGNED_PLAYER_ID) return; + RakNet::BitStream temp( sizeof(unsigned char) ); temp.Write( (unsigned char) ID_DISCONNECTION_NOTIFICATION ); if (performImmediate) { - SendImmediate((char*)temp.GetData(), temp.GetNumberOfBitsUsed(), LOW_PRIORITY, RELIABLE_ORDERED, orderingChannel, playerId, false, false, RakNet::GetTime()); - RemoteSystemStruct *rss=GetRemoteSystemFromPlayerID(playerId, true, true); - rss->connectMode=RemoteSystemStruct::DISCONNECT_ASAP; + RemoteSystemStruct *rss=GetRemoteSystemFromPlayerID(playerId, false, true); + if (rss) + { + SendImmediate((char*)temp.GetData(), temp.GetNumberOfBitsUsed(), HIGH_PRIORITY, UNRELIABLE, orderingChannel, playerId, false, false, RakNet::GetTime()); + rss->connectMode=RemoteSystemStruct::DISCONNECT_ASAP; + } } else { - SendBuffered((const char*)temp.GetData(), temp.GetNumberOfBitsUsed(), LOW_PRIORITY, RELIABLE_ORDERED, orderingChannel, playerId, false, RemoteSystemStruct::DISCONNECT_ASAP); + SendBuffered((const char*)temp.GetData(), temp.GetNumberOfBitsUsed(), HIGH_PRIORITY, UNRELIABLE, orderingChannel, playerId, false, RemoteSystemStruct::DISCONNECT_ASAP); } } // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------