]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/vis.c
Merge commit 'c5a6237a2b002c9811719172931b0c9cc5a725f4' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / vis.c
index b6340473daea2945925fbb5cfb25a417239e0a6a..5e3bf7efeb64b320f6d31b0be1fde93c94b63c3a 100644 (file)
@@ -66,8 +66,7 @@ fixedWinding_t *NewFixedWinding( int points ){
        }
 
        size = (int)( (size_t)( (fixedWinding_t *)0 )->points[points] );
-       w = safe_malloc( size );
-       memset( w, 0, size );
+       w = safe_malloc0( size );
 
        return w;
 }
@@ -163,7 +162,9 @@ int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
    Merges the portal visibility for a leaf
    ===============
  */
+
 static int clustersizehistogram[MAX_MAP_LEAFS] = {0};
+
 void ClusterMerge( int leafnum ){
        leaf_t      *leaf;
        byte portalvector[MAX_PORTALS / 8];
@@ -204,7 +205,7 @@ void ClusterMerge( int leafnum ){
        numvis = LeafVectorFromPortalVector( portalvector, uncompressed );
 
 //     if (uncompressed[leafnum>>3] & (1<<(leafnum&7)))
-//             Sys_Printf ("WARNING: Leaf portals saw into leaf\n");
+//             Sys_FPrintf (SYS_WRN, "WARNING: Leaf portals saw into leaf\n");
 
 //     uncompressed[leafnum>>3] |= (1<<(leafnum&7));
 
@@ -318,16 +319,25 @@ void CalcVis( void ){
        }
        if ( value[ 0 ] != '\0' ) {
                farPlaneDist = atof( value );
-               if ( farPlaneDist > 0.0f ) {
+               farPlaneDistMode = value[strlen(value) - 1 ];
+               if ( farPlaneDist != 0.0f ) {
                        Sys_Printf( "farplane distance = %.1f\n", farPlaneDist );
                }
-               else{
-                       farPlaneDist = 0.0f;
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'o' ) {
+                       Sys_Printf( "farplane Origin2Origin mode on\n" );
+               }
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'r' ) {
+                       Sys_Printf( "farplane Radius+Radius mode on\n" );
                }
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'e' ) {
+                       Sys_Printf( "farplane Exact distance mode on\n" );
+               }
+
        }
 
 
 
+
        Sys_Printf( "\n--- BasePortalVis (%d) ---\n", numportals * 2 );
        RunThreadsOnIndividual( numportals * 2, qtrue, BasePortalVis );
 
@@ -934,11 +944,9 @@ void LoadPortals( char *name ){
        portallongs = portalbytes / sizeof( long );
 
        // each file portal is split into two memory portals
-       portals = safe_malloc( 2 * numportals * sizeof( vportal_t ) );
-       memset( portals, 0, 2 * numportals * sizeof( vportal_t ) );
+       portals = safe_malloc0( 2 * numportals * sizeof( vportal_t ) );
 
-       leafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
-       memset( leafs, 0, portalclusters * sizeof( leaf_t ) );
+       leafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
 
        for ( i = 0; i < portalclusters; i++ )
                leafs[i].merged = -1;
@@ -1034,11 +1042,9 @@ void LoadPortals( char *name ){
 
        }
 
-       faces = safe_malloc( 2 * numfaces * sizeof( vportal_t ) );
-       memset( faces, 0, 2 * numfaces * sizeof( vportal_t ) );
+       faces = safe_malloc0( 2 * numfaces * sizeof( vportal_t ) );
 
-       faceleafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
-       memset( faceleafs, 0, portalclusters * sizeof( leaf_t ) );
+       faceleafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
 
        for ( i = 0, p = faces; i < numfaces; i++ )
        {
@@ -1140,7 +1146,7 @@ int VisMain( int argc, char **argv ){
                }
                else if ( !strcmp( argv[ i ], "-v" ) ) {
                        debugCluster = qtrue;
-                       Sys_Printf( "Extra verbous mode enabled\n" );
+                       Sys_Printf( "Extra verbose mode enabled\n" );
                }
                else if ( !strcmp( argv[i],"-tmpin" ) ) {
                        strcpy( inbase, "/tmp" );
@@ -1158,7 +1164,9 @@ int VisMain( int argc, char **argv ){
                else if ( !strcmp( argv[ i ], "-prtfile" ) )
                {
                        strcpy( portalFilePath, argv[i + 1] );
+                       argv[ i ] = NULL;
                        i++;
+                       argv[ i ] = NULL;
                        Sys_Printf( "Use %s as portal file\n", portalFilePath );
                }
 
@@ -1179,6 +1187,16 @@ int VisMain( int argc, char **argv ){
        Sys_Printf( "Loading %s\n", source );
        LoadBSPFile( source );
 
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               strcat( source, ".tex" );
+               LoadSurfaceFlags( source );
+               StripExtension( source );
+               strcat( source, ".bsp" );
+       }
+
        /* load the portal file */
        if (!portalFilePath[0]) {
                sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
@@ -1221,6 +1239,14 @@ int VisMain( int argc, char **argv ){
                remove( portalFilePath );
        }
 
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               WriteTexFile( source );
+               DefaultExtension( source, ".bsp" );
+       }
+
        /* write the bsp file */
        Sys_Printf( "Writing %s\n", source );
        WriteBSPFile( source );