[quake3-commits] r2079 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jul 13 14:57:32 EDT 2011


Author: thilo
Date: 2011-07-13 14:57:32 -0400 (Wed, 13 Jul 2011)
New Revision: 2079

Modified:
   trunk/code/qcommon/common.c
Log:
- Make sure at least one round of download packets and packet queues gets sent each frame
- Fix timeVal select timeout value for case of unlimited data rate and now downloads are active


Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2011-07-13 18:37:26 UTC (rev 2078)
+++ trunk/code/qcommon/common.c	2011-07-13 18:57:32 UTC (rev 2079)
@@ -3104,82 +3104,76 @@
 	
 	do
 	{
-		// Busy sleep the last millisecond for better timeout precision
-		if(timeVal < 2)
-			NET_Sleep(0);
-		else
+		if(com_sv_running->integer)
 		{
-			if(com_sv_running->integer)
+			// Send out fragmented packets now that we're idle
+			delayT = SV_SendQueuedMessages();
+			if(delayT >= 0 && delayT < timeVal)
+				timeVal = delayT;
+
+			if(sv_dlRate->integer)
 			{
-				// Send out fragmented packets now that we're idle
-				delayT = SV_SendQueuedMessages();
-				if(delayT >= 0 && delayT < timeVal)
-					timeVal = delayT;
-					
-				if(sv_dlRate->integer)
+				// Rate limiting. This is very imprecise for high
+				// download rates due to millisecond timedelta resolution
+				dlStart = Sys_Milliseconds();
+				deltaT = dlNextRound - dlStart;
+
+				if(deltaT > 0)
 				{
-					// Rate limiting. This is very imprecise for high
-					// download rates due to millisecond timedelta resolution
-					dlStart = Sys_Milliseconds();
-					deltaT = dlNextRound - dlStart;
+					if(deltaT < timeVal)
+						timeVal = deltaT + 1;
+				}
+				else
+				{
+					numBlocks = SV_SendDownloadMessages();
 
-					if(deltaT > 0)
+					if(numBlocks)
 					{
-						if(deltaT < timeVal)
-							timeVal = deltaT + 1;
-					}
-					else
-					{
-						numBlocks = SV_SendDownloadMessages();
+						// There are active downloads
+						deltaT = Sys_Milliseconds() - dlStart;
 
-						if(numBlocks)
+						delayT = 1000 * numBlocks * MAX_DOWNLOAD_BLKSIZE;
+						delayT /= sv_dlRate->integer * 1024;
+
+						if(delayT <= deltaT + 1)
 						{
-							// There are active downloads
-							deltaT = Sys_Milliseconds() - dlStart;
+							// Sending the last round of download messages
+							// took too long for given rate, don't wait for
+							// next round, but always enforce a 1ms delay
+							// between DL message rounds so we don't hog
+							// all of the bandwidth. This will result in an
+							// effective maximum rate of 1MB/s per user, but the
+							// low download window size limits this anyways.
+							if(timeVal > 2)
+								timeVal = 2;
 
-							delayT = 1000 * numBlocks * MAX_DOWNLOAD_BLKSIZE;
-							delayT /= sv_dlRate->integer * 1024;
+							dlNextRound = dlStart + deltaT + 1;
+						}
+						else
+						{
+							dlNextRound = dlStart + delayT;
+							delayT -= deltaT;
 
-							if(delayT <= deltaT + 1)
-							{
-								// Sending the last round of download messages
-								// took too long for given rate, don't wait for
-								// next round, but always enforce a 1ms delay
-								// between DL message rounds so we don't hog
-								// all of the bandwidth. This will result in an
-								// effective maximum rate of 1MB/s per user, but the
-								// low download window size limits this anyways.
-								if(timeVal > 2)
-									timeVal = 2;
-									
-								dlNextRound = dlStart + deltaT + 1;
-							}
-							else
-							{
-								dlNextRound = dlStart + delayT;
-								delayT -= deltaT;
-								
-								if(delayT < timeVal)
-									timeVal = delayT;
-							}
+							if(delayT < timeVal)
+								timeVal = delayT;
 						}
 					}
 				}
-				else
-				{
-					SV_SendDownloadMessages();
+			}
+			else
+			{
+				if(SV_SendDownloadMessages())
 					timeVal = 1;
-				}
 			}
+		}
 
-			if(timeVal == 0)
-				timeVal = 1;
+		if(timeVal == 0)
+			timeVal = 1;
 
-			if(com_busyWait->integer)
-				NET_Sleep(0);
-			else
-				NET_Sleep(timeVal - 1);
-		}
+		if(com_busyWait->integer)
+			NET_Sleep(0);
+		else
+			NET_Sleep(timeVal - 1);
 
 		msec = Sys_Milliseconds() - com_frameTime;
 		



More information about the quake3-commits mailing list