Great idea, just we don't want out pak files to be inside "My Games\OpenWolf" folder, maybe in the future we will use this

Great idea, just we don’t want out pak files to be inside “My Games\OpenWolf” folder, maybe in the future we will use this

diff --git a/src/engine/framework/FileSystem.cpp b/src/engine/framework/FileSystem.cpp
index a046553..023a255 100644
--- a/src/engine/framework/FileSystem.cpp
+++ b/src/engine/framework/FileSystem.cpp
@@ -3786,7 +3786,6 @@ bool idFileSystemLocal::ComparePaks( valueType* neededpaks, sint len, bool dlstr
 {
     searchpath_t* sp;
     bool havepak, badchecksum;
-    valueType* origpos = neededpaks;
     sint i;
     
     if( !fs_numServerReferencedPaks )
@@ -3808,13 +3807,6 @@ bool idFileSystemLocal::ComparePaks( valueType* neededpaks, sint len, bool dlstr
             continue;
         }
         
-        // Make sure the server cannot make us write to non-quake3 directories.
-        if( strstr( fs_serverReferencedPakNames[i], "../" ) || strstr( fs_serverReferencedPakNames[i], "..\\" ) )
-        {
-            Com_Printf( "WARNING: Invalid download name %s\n", fs_serverReferencedPakNames[i] );
-            continue;
-        }
-        
         for( sp = fs_searchpaths ; sp ; sp = sp->next )
         {
             if( sp->pack && sp->pack->checksum == fs_serverReferencedPaks[i] )
@@ -3830,8 +3822,6 @@ bool idFileSystemLocal::ComparePaks( valueType* neededpaks, sint len, bool dlstr
             
             if( dlstring )
             {
-                origpos += ::strlen( origpos );
-                
                 // Remote name
                 Q_strcat( neededpaks, len, "@" );
                 Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] );
@@ -3853,12 +3843,6 @@ bool idFileSystemLocal::ComparePaks( valueType* neededpaks, sint len, bool dlstr
                     Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] );
                     Q_strcat( neededpaks, len, ".pk3" );
                 }
-                
-                if( ::strlen( origpos ) + ( origpos - neededpaks ) >= len - 1 )
-                {
-                    *origpos = '\0';
-                    break;
-                }
             }
             else
             {
@@ -4477,7 +4461,7 @@ checksums to see if any pk3 files need to be auto-downloaded.
 */
 void idFileSystemLocal::PureServerSetReferencedPaks( pointer pakSums, pointer pakNames )
 {
-    sint i, c, d = 0;
+    sint i, c, d;
     
     cmdSystem->TokenizeString( pakSums );
     
@@ -4487,7 +4471,14 @@ void idFileSystemLocal::PureServerSetReferencedPaks( pointer pakSums, pointer pa
         c = MAX_SEARCH_PATHS;
     }
     
-    for( i = 0 ; i < sizeof( fs_serverReferencedPakNames ) / sizeof( *fs_serverReferencedPakNames ); i++ )
+    fs_numServerReferencedPaks = c;
+    
+    for( i = 0 ; i < c ; i++ )
+    {
+        fs_serverReferencedPaks[i] = atoi( cmdSystem->Argv( i ) );
+    }
+    
+    for( i = 0 ; i < c ; i++ )
     {
         if( fs_serverReferencedPakNames[i] )
         {
@@ -4507,23 +4498,12 @@ void idFileSystemLocal::PureServerSetReferencedPaks( pointer pakSums, pointer pa
         {
             d = MAX_SEARCH_PATHS;
         }
-        else if( d > c )
-        {
-            d = c;
-        }
         
         for( i = 0 ; i < d ; i++ )
         {
             fs_serverReferencedPakNames[i] = CopyString( cmdSystem->Argv( i ) );
         }
     }
-    
-    if( d < c )
-    {
-        c = d;
-    }
-    
-    fs_numServerReferencedPaks = c;
 }
 
 /*
diff --git a/src/engine/qcommon/q_math.cpp b/src/engine/qcommon/q_math.cpp
index b9c87ca..6b5aef2 100644
--- a/src/engine/qcommon/q_math.cpp
+++ b/src/engine/qcommon/q_math.cpp
@@ -240,20 +240,14 @@ vec3_t	bytedirs[NUMVERTEXNORMALS] =
 
 //==============================================================
 
-sint Q_rand( sint* seed )
-{
-    *seed = ( 69069 * *seed + 1 );
-    return *seed;
-}
-
 float32 Q_random( sint* seed )
 {
-    return ( Q_rand( seed ) & 0xffff ) / ( float32 )0x10000;
+    return ( ( rand() & 0x7FFF ) / ( ( float32 )0x8000 ) );
 }
 
 float32 Q_crandom( sint* seed )
 {
-    return 2.0f * ( Q_random( seed ) - 0.5f );
+    return ( 2.0f * ( ( ( rand() & 0x7FFF ) / ( ( float32 )0x7FFF ) ) - 0.5f ) );
 }
 
 
diff --git a/src/engine/qcommon/q_shared.h b/src/engine/qcommon/q_shared.h
index e341d9e..8d0a1ab 100644
--- a/src/engine/qcommon/q_shared.h
+++ b/src/engine/qcommon/q_shared.h
@@ -571,12 +571,11 @@ sint NearestPowerOfTwo( sint val );
 sint Q_log2( sint val );
 float32 Q_acos( float32 c );
 sint Q_isnan( float32 x );
-sint     Q_rand( sint* seed );
 float32   Q_random( sint* seed );
 float32   Q_crandom( sint* seed );
 
-#define random()    ( ( rand() & 0x7fff ) / ( (float32)0x7fff ) )
-#define crandom()   ( 2.0 * ( random() - 0.5 ) )
+#define random()     ( ( rand() & 0x7FFF ) / ( ( float32 )0x8000 ) )
+#define crandom()   ( 2.0f * ( ( ( rand() & 0x7FFF ) / ( ( float32 )0x7FFF ) ) - 0.5f ) )
 
 void vectoangles( const vec3_t value1, vec3_t angles );
 

GitHub
sha: 0cc6f9ba