From 15c6723c1061c6f85959ab9d149da784636f7dbb Mon Sep 17 00:00:00 2001 From: Charles Lohr Date: Fri, 13 Aug 2004 21:03:22 +0000 Subject: [PATCH] Only proceed when proper handshake is received --- stepmania/src/NetworkSyncManager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/stepmania/src/NetworkSyncManager.cpp b/stepmania/src/NetworkSyncManager.cpp index e51cc579e0..bd291c236a 100644 --- a/stepmania/src/NetworkSyncManager.cpp +++ b/stepmania/src/NetworkSyncManager.cpp @@ -115,12 +115,19 @@ void NetworkSyncManager::PostStartUp(CString ServerIP) //Move mode to blocking in order to give CPU back to the //system, and not wait. + bool dontExit=true; NetPlayerClient->blocking=true; - NetPlayerClient->ReadPack((char*)m_packet.Data,NETMAXBUFFERSIZE); + while (dontExit) + { + ClearPacket(m_packet); + if (NetPlayerClient->ReadPack((char *)&m_packet, NETMAXBUFFERSIZE)<1) + dontExit=false; // Also allow exit if there is a problem on the socket + if (Read1(m_packet) == (128+2)) + dontExit=false; + //Only allow passing on handshake. + //Otherwise scoreboard updates and such will confuse us. + } NetPlayerClient->blocking=false; - - //int command = Read1(m_packet); - Read1(m_packet); m_ServerVersion = Read1(m_packet); m_ServerName = ReadNT(m_packet);