sources/network/rconsession.cpp

branch
protocol5
changeset 170
40d8d7231a36
parent 169
febc3ed5435c
child 171
d0fba0d7ad03
--- a/sources/network/rconsession.cpp	Sat Jul 23 12:34:05 2016 +0300
+++ b/sources/network/rconsession.cpp	Sat Jul 23 12:35:43 2016 +0300
@@ -121,29 +121,29 @@
 	// Check for new packets in our socket
 	for (Datagram datagram; m_socket.read(datagram);)
 	{
-		// Packet came from the wrong address, ignore
-		if (datagram.address != m_address)
-			continue;
-
-		// Parse and cut off the header.
-		PacketHeader header;
+		// Only process packets that originate from the game server.
+		if (datagram.address == m_address)
 		{
-			// Read the header, and find the sequence number
-			Bytestream stream(datagram.message);
-			header.header = stream.readLong();
-			header.sequenceNumber = (header.header != 0) ? stream.readLong() : -1;
-			datagram.message = datagram.message.splice(stream.position(), datagram.message.size());
-		}
+			// Parse and cut off the header.
+			PacketHeader header;
+			{
+				// Read the header, and find the sequence number
+				Bytestream stream(datagram.message);
+				header.header = stream.readLong();
+				header.sequenceNumber = (header.header != 0) ? stream.readLong() : -1;
+				datagram.message = datagram.message.splice(stream.position(), datagram.message.size());
+			}
 
-		// Try to store this packet into the queue. However, do not try to store packets without a sequence number.
-		bool stored = false;
+			// Try to store this packet into the queue. However, do not try to store packets without a sequence number.
+			bool stored = false;
 
-		if (header.sequenceNumber != -1)
-			stored = m_packetQueue.addPacket(header.sequenceNumber, datagram.message);
+			if (header.sequenceNumber != -1)
+				stored = m_packetQueue.addPacket(header.sequenceNumber, datagram.message);
 
-		// If the packet was not stored, we are to just process it right away.
-		if (stored == false)
-			handlePacket(datagram.message);
+			// If the packet was not stored, we are to just process it right away.
+			if (stored == false)
+				handlePacket(datagram.message);
+		}
 	}
 
 	// Check if we can now also process some packets from the queue.

mercurial