Better understanding of the commands

Better understanding of the commands

diff --git a/src/engine/audio/s_mix.cpp b/src/engine/audio/s_mix.cpp
index 4ba06db..25ba209 100644
--- a/src/engine/audio/s_mix.cpp
+++ b/src/engine/audio/s_mix.cpp
@@ -37,41 +37,33 @@ sint*     snd_p;
 sint      snd_linear_count;
 schar16*   snd_out;
 
-void S_WriteLinearBlastStereo16( void )
+static void S_WriteLinearBlastStereo16( void )
 {
-    sint	i, val;
+    sint v1, v2;
     
-    for( i = 0 ; i < snd_linear_count ; i += 2 )
+    for( sint i = 0; i < snd_linear_count; i += 2 )
     {
-        val = snd_p[i] >> 8;
-        
-        if( val > 0x7fff )
+        v1 = snd_p[i] >> 8;
+        if( v1 > 32767 )
         {
-            snd_out[i] = 0x7fff;
+            v1 = 32767;
         }
-        else if( val < -32768 )
+        else if( v1 < -32768 )
         {
-            snd_out[i] = -32768;
+            v1 = -32768;
         }
-        else
-        {
-            snd_out[i] = val;
-        }
-        
-        val = snd_p[i + 1] >> 8;
         
-        if( val > 0x7fff )
+        v2 = snd_p[i + 1] >> 8;
+        if( v2 > 32767 )
         {
-            snd_out[i + 1] = 0x7fff;
+            v2 = 32767;
         }
-        else if( val < -32768 )
+        else if( v2 < -32768 )
         {
-            snd_out[i + 1] = -32768;
-        }
-        else
-        {
-            snd_out[i + 1] = val;
+            v2 = -32768;
         }
+        
+        *( uint* )( &snd_out[i] ) = ( v2 << 16 ) | ( v1 & 0xFFFF );
     }
 }
 
diff --git a/src/engine/server/server.h b/src/engine/server/server.h
index 65975d6..7c4f8a3 100644
--- a/src/engine/server/server.h
+++ b/src/engine/server/server.h
@@ -207,8 +207,8 @@ typedef struct client_s
     sint             ping;
     sint             rate;		// bytes / second
     sint             snapshotMsec;	// requests a snapshot every snapshotMsec unless rate choked
-    sint             pureAuthentic;
-    bool            gotCP;		// TTimo - additional flag to distinguish between a bad pure checksum, and no cp command at all
+    bool             pureAuthentic;
+    bool            pureReceived;		// TTimo - additional flag to distinguish between a bad pure checksum, and no cp command at all
     netchan_t       netchan;
     // TTimo
     // queuing outgoing fragmented messages to send them properly, without udp packet bursts
diff --git a/src/engine/server/serverClient.cpp b/src/engine/server/serverClient.cpp
index 6cb2cf2..4acf828 100644
--- a/src/engine/server/serverClient.cpp
+++ b/src/engine/server/serverClient.cpp
@@ -867,8 +867,8 @@ void idServerClientSystemLocal::SendClientGameState( client_t* client )
     {
         client->state = CS_PRIMED;
     }
-    client->pureAuthentic = 0;
-    client->gotCP = false;
+    client->pureAuthentic = false;
+    client->pureReceived = false;
     
     // when we receive the first packet from the client, we will
     // notice that it is from a different serverid and that the
@@ -1002,8 +1002,9 @@ void idServerClientSystemLocal::CloseDownload( client_t* cl )
     if( cl->download )
     {
         fileSystem->FCloseFile( cl->download );
+        cl->download = 0;
     }
-    cl->download = 0;
+    
     *cl->downloadName = 0;
     
     // Free the temporary buffer space
@@ -1792,15 +1793,15 @@ void idServerClientSystemLocal::VerifyPaks_f( client_t* cl )
             break;
         }
         
-        cl->gotCP = true;
+        cl->pureReceived = true;
         
         if( bGood )
         {
-            cl->pureAuthentic = 1;
+            cl->pureAuthentic = true;
         }
         else
         {
-            cl->pureAuthentic = 0;
+            cl->pureAuthentic = false;
             cl->nextSnapshotTime = -1;
             cl->state = CS_ACTIVE;
             
@@ -1818,8 +1819,8 @@ idServerClientSystemLocal::ResetPureClient_f
 */
 void idServerClientSystemLocal::ResetPureClient_f( client_t* cl )
 {
-    cl->pureAuthentic = 0;
-    cl->gotCP = false;
+    cl->pureAuthentic = false;
+    cl->pureReceived = false;
 }
 
 /*
@@ -2487,7 +2488,7 @@ void idServerClientSystemLocal::UserMove( client_t* cl, msg_t* msg, bool delta )
     // catch the no-cp-yet situation before SV_ClientEnterWorld
     // if CS_ACTIVE, then it's time to trigger a new gamestate emission
     // if not, then we are getting remaining parasite usermove commands, which we should ignore
-    if( sv_pure->integer != 0 && cl->pureAuthentic == 0 && !cl->gotCP )
+    if( sv_pure->integer != 0 && cl->pureAuthentic == false && !cl->pureReceived )
     {
         if( cl->state == CS_ACTIVE )
         {
@@ -2507,7 +2508,7 @@ void idServerClientSystemLocal::UserMove( client_t* cl, msg_t* msg, bool delta )
     }
     
     // a bad cp command was sent, drop the client
-    if( sv_pure->integer != 0 && cl->pureAuthentic == 0 )
+    if( sv_pure->integer != 0 && cl->pureAuthentic == false )
     {
         serverClientLocal.DropClient( cl, "Cannot validate pure client!" );
         return;

GitHub
sha: 91510a43