]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge branch 'sysfprintf' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 10 Jul 2017 17:13:28 +0000 (17:13 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 10 Jul 2017 17:13:28 +0000 (17:13 +0000)
import sys_fprintf changes by Pan7 from GtkRadiant tree

See merge request !35

1  2 
tools/quake3/common/aselib.c
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/portals.c
tools/quake3/q3map2/surface_meta.c

index b60758b85eb1e49f633f277b788fdf789da0ad15,7b0085d281a46ccd1e0ba0ce921ee633705e1fe6..df9b986a845660b14c98352534b99e6501eea65b
@@@ -217,7 -217,7 +217,7 @@@ polyset_t *ASE_GetSurfaceAnimation( in
        {
                numFramesInAnimation = pObject->anim.numFrames;
                if ( maxFrames != -1 ) {
-                       Sys_Printf( "WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\n" );
+                       Sys_FPrintf( SYS_WRN, "WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\n" );
                }
        }
  
@@@ -411,9 -411,9 +411,9 @@@ static void ASE_SkipRestOfLine( void )
  }
  
  static void ASE_KeyMAP_DIFFUSE( const char *token ){
 -      char fullpath[1024], bitmap[1024], modeldir[1024];
 +      char bitmap[1024];
        char filename[1024];
 -      int i = 0, count;
 +      int i = 0;
  
        strcpy( filename, gl_filename );
  
                else
                {
                        sprintf( ase.materials[ase.numMaterials].name, "(not converted: '%s')", bitmap );
-                       Sys_Printf( "WARNING: illegal material name '%s'\n", bitmap );
+                       Sys_FPrintf( SYS_WRN, "WARNING: illegal material name '%s'\n", bitmap );
                }
        }
        else
index 1b4b9bc6d29a97bb997f8d32bb256acaa5c35b62,a20a5963ffa8fa9bb185bf65fd7dc08686a10fd7..eb9bc4326a170c44a4694344586dce6f681d85f0
@@@ -104,7 -104,7 +104,7 @@@ void SetDrawSurfacesBuffer()
  
        bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
  
 -      memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawVert_t ) );
 +      memset( bspDrawSurfaces, 0, MAX_MAP_DRAW_SURFS * sizeof( bspDrawSurface_t ) );
  }
  
  void SetDrawSurfaces( int n ){
  
        bspDrawSurfaces = safe_malloc_info( sizeof( bspDrawSurface_t ) * numBSPDrawSurfacesBuffer, "IncDrawSurfaces" );
  
 -      memset( bspDrawSurfaces, 0, n * sizeof( bspDrawVert_t ) );
 +      memset( bspDrawSurfaces, 0, n * sizeof( bspDrawSurface_t ) );
  }
  
  void BSPFilesCleanup(){
@@@ -268,7 -268,7 +268,7 @@@ int GetLumpElements( bspHeader_t *heade
        /* check for odd size */
        if ( header->lumps[ lump ].length % size ) {
                if ( force ) {
-                       Sys_Printf( "WARNING: GetLumpElements: odd lump size (%d) in lump %d\n", header->lumps[ lump ].length, lump );
+                       Sys_FPrintf( SYS_WRN, "WARNING: GetLumpElements: odd lump size (%d) in lump %d\n", header->lumps[ lump ].length, lump );
                        return 0;
                }
                else{
@@@ -312,7 -312,7 +312,7 @@@ int CopyLump( bspHeader_t *header, int 
        }
        if ( length % size ) {
                if ( force ) {
-                       Sys_Printf( "WARNING: CopyLump: odd lump size (%d) in lump %d\n", length, lump );
+                       Sys_FPrintf( SYS_WRN, "WARNING: CopyLump: odd lump size (%d) in lump %d\n", length, lump );
                        return 0;
                }
                else{
@@@ -831,7 -831,7 +831,7 @@@ vec_t FloatForKey( const entity_t *ent
     gets a 3-element vector value for an entity key
   */
  
 -void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
 +qboolean GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec ){
        const char  *k;
        double v1, v2, v3;
  
        vec[ 0 ] = v1;
        vec[ 1 ] = v2;
        vec[ 2 ] = v3;
 +
 +      /* true if the key is found, false otherwise */
 +      return strlen( k );
  }
  
  
index 78e3c817ea7dd3541872b82b5f2e293e29b179a2,14a69ae8978576c17ca1014fa704bb1b904f809d..c340b9dc03753139f4e65f70dc4c9a94b9974534
@@@ -442,7 -442,7 +442,7 @@@ void CreateEntityLights( void )
                        /* get target */
                        e2 = FindTargetEntity( target );
                        if ( e2 == NULL ) {
-                               Sys_Printf( "WARNING: light at (%i %i %i) has missing target\n",
+                               Sys_FPrintf( SYS_WRN, "WARNING: light at (%i %i %i) has missing target\n",
                                                        (int) light->origin[ 0 ], (int) light->origin[ 1 ], (int) light->origin[ 2 ] );
                                light->photons *= pointScale;
                        }
@@@ -2054,7 -2054,7 +2054,7 @@@ void LightWorld( const char *BSPFilePat
                SetupEnvelopes( qfalse, fastbounce );
                if ( numLights == 0 ) {
                        Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
 -                      break;
 +                      return;
                }
  
                /* add to lightgrid */
                bounce--;
                b++;
        }
 +      /* ydnar: store off lightmaps */
 +      StoreSurfaceLightmaps( fastAllocate );
  }
  
  
@@@ -2515,7 -2513,7 +2515,7 @@@ int LightMain( int argc, char **argv )
  
                        /* must be a power of 2 and greater than 2 */
                        if ( ( ( lmCustomSize - 1 ) & lmCustomSize ) || lmCustomSize < 2 ) {
-                               Sys_Printf( "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
+                               Sys_FPrintf( SYS_WRN, "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
                                lmCustomSize = game->lightmapSize;
                        }
                        i++;
                /* unhandled args */
                else
                {
-                       Sys_Printf( "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
+                       Sys_FPrintf( SYS_WRN, "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
                }
  
        }
        /* light the world */
        LightWorld( BSPFilePath, fastAllocate );
  
 -      /* ydnar: store off lightmaps */
 -      StoreSurfaceLightmaps( fastAllocate );
 -
        /* write out the bsp */
        UnparseEntities();
        Sys_Printf( "Writing %s\n", BSPFilePath );
index 5bb8438da0a5227b8dfb83ba4863da45862e51e0,1edff9e38c346566eac5173367af60cf81962cb2..34c22833b64f1821d71a55f219cd37463e92908d
@@@ -1740,9 -1740,8 +1740,8 @@@ static qboolean SubmapRawLuxel( rawLigh
                origin2 = SUPER_ORIGIN( x, y );
                //%     normal2 = SUPER_NORMAL( x, y );
        }
-       else
-       {
-               Error( "Spurious lightmap S vector\n" );
+       else{
+               Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap S vector\n" );
        }
  
        VectorSubtract( origin2, origin, originVecs[ 0 ] );
                //%     normal2 = SUPER_NORMAL( x, y );
        }
        else{
-               Sys_Printf( "WARNING: Spurious lightmap T vector\n" );
+               Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
        }
  
        VectorSubtract( origin2, origin, originVecs[ 1 ] );
@@@ -2196,7 -2195,7 +2195,7 @@@ void IlluminateRawLightmap( int rawLigh
  
                        /* max of MAX_LIGHTMAPS (4) styles allowed to hit a surface/lightmap */
                        if ( lightmapNum >= MAX_LIGHTMAPS ) {
-                               Sys_Printf( "WARNING: Hit per-surface style limit (%d)\n", MAX_LIGHTMAPS );
+                               Sys_FPrintf( SYS_WRN, "WARNING: Hit per-surface style limit (%d)\n", MAX_LIGHTMAPS );
                                continue;
                        }
  
                        }
  
                        /* set luxel filter radius */
 -                      luxelFilterRadius = superSample * filterRadius / lm->sampleSize;
 +                      luxelFilterRadius = lm->sampleSize != 0 ? superSample * filterRadius / lm->sampleSize : 0;
                        if ( luxelFilterRadius == 0 && ( filterRadius > 0.0f || filter ) ) {
                                luxelFilterRadius = 1;
                        }
@@@ -3795,7 -3794,7 +3794,7 @@@ void SetupEnvelopes( qboolean forGrid, 
                                        for ( i = 0; i < 3; i++ )
                                        {
                                                if ( mins[ i ] > light->origin[ i ] || maxs[ i ] < light->origin[ i ] ) {
-                                                       //% Sys_Printf( "WARNING: Light PVS bounds (%.0f, %.0f, %.0f) -> (%.0f, %.0f, %.0f)\ndo not encompass light %d (%f, %f, %f)\n",
+                                                       //% Sys_FPrintf( SYS_WRN, "WARNING: Light PVS bounds (%.0f, %.0f, %.0f) -> (%.0f, %.0f, %.0f)\ndo not encompass light %d (%f, %f, %f)\n",
                                                        //%     mins[ 0 ], mins[ 1 ], mins[ 2 ],
                                                        //%     maxs[ 0 ], maxs[ 1 ], maxs[ 2 ],
                                                        //%     numLights, light->origin[ 0 ], light->origin[ 1 ], light->origin[ 2 ] );
index c5633ae372d3f754eafc70c61ab4f0e0e6e8578c,7366f757b01a4fd5aeb68b7bf5e218542ab58cbd..83f0776d1104bc12f6fa7d512a74845fee978e08
@@@ -127,7 -127,7 +127,7 @@@ void ExportLightmaps( void )
  
        /* sanity check */
        if ( bspLightBytes == NULL ) {
-               Sys_Printf( "WARNING: No BSP lightmap data\n" );
+               Sys_FPrintf( SYS_WRN, "WARNING: No BSP lightmap data\n" );
                return;
        }
  
@@@ -226,7 -226,7 +226,7 @@@ int ImportLightmapsMain( int argc, cha
                buffer = NULL;
                len = vfsLoadFile( filename, (void*) &buffer, -1 );
                if ( len < 0 ) {
-                       Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+                       Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
                        continue;
                }
  
  
                /* sanity check it */
                if ( pixels == NULL ) {
-                       Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+                       Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
                        continue;
                }
                if ( width != game->lightmapSize || height != game->lightmapSize ) {
-                       Sys_Printf( "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
+                       Sys_FPrintf( SYS_WRN, "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
                                                filename, width, height, game->lightmapSize, game->lightmapSize );
                }
  
@@@ -525,7 -525,7 +525,7 @@@ qboolean AddPatchToRawLightmap( int num
        length = 0;
        for ( x = 0; x < ( mesh->width - 1 ); x++ )
                length += widthTable[ x ];
 -      lm->w = ceil( length / lm->sampleSize ) + 1;
 +      lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
        if ( lm->w < ds->patchWidth ) {
                lm->w = ds->patchWidth;
        }
        length = 0;
        for ( y = 0; y < ( mesh->height - 1 ); y++ )
                length += heightTable[ y ];
 -      lm->h = ceil( length / lm->sampleSize ) + 1;
 +      lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
        if ( lm->h < ds->patchHeight ) {
                lm->h = ds->patchHeight;
        }
@@@ -752,7 -752,7 +752,7 @@@ qboolean AddSurfaceToRawLightmap( int n
  
        /* check for bogus axis */
        if ( faxis[ axisNum ] == 0.0f ) {
-               Sys_Printf( "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
+               Sys_FPrintf( SYS_WRN, "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
                lm->w = lm->h = 0;
                return qfalse;
        }
@@@ -971,7 -971,7 +971,7 @@@ void SetupSurfaceLightmaps( void )
                superSample = 1;
        }
        else if ( superSample > 8 ) {
-               Sys_Printf( "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
+               Sys_FPrintf( SYS_WRN, "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
                superSample = 8;
        }
  
index 20ed301bee31cc0a205dc725fa88692b1546a84e,de00fe80ba76d2e6b0d09ba81fc6e3d65843db45..209ad60dbd4f6d576c003a6b19f39625ee715730
@@@ -519,7 -519,7 +519,7 @@@ void MakeTreePortals_r( node_t *node )
  
        CalcNodeBounds( node );
        if ( node->mins[0] >= node->maxs[0] ) {
-               Sys_Printf( "WARNING: node without a volume\n" );
+               Sys_FPrintf( SYS_WRN, "WARNING: node without a volume\n" );
                Sys_Printf( "node has %d tiny portals\n", node->tinyportals );
                Sys_Printf( "node reference point %1.2f %1.2f %1.2f\n", node->referencepoint[0],
                                        node->referencepoint[1],
@@@ -664,7 -664,7 +664,7 @@@ qboolean PlaceOccupant( node_t *headnod
  int FloodEntities( tree_t *tree ){
        int i, s;
        vec3_t origin, offset, scale, angles;
 -      qboolean r, inside, skybox;
 +      qboolean r, inside, skybox, found;
        node_t      *headnode;
        entity_t    *e, *tripped;
        const char  *value;
                e = &entities[ i ];
  
                /* get origin */
 -              GetVectorForKey( e, "origin", origin );
 +              found = GetVectorForKey( e, "origin", origin );
  
                /* as a special case, allow origin-less entities */
 -              if ( VectorCompare( origin, vec3_origin ) ) {
 +              if ( !found ) {
                        continue;
                }
  
@@@ -811,7 -811,7 +811,7 @@@ void FloodAreas_r( node_t *node )
  
                // note the current area as bounding the portal
                if ( b->portalareas[ 1 ] != -1 ) {
-                       Sys_Printf( "WARNING: areaportal brush %i touches > 2 areas\n", b->brushNum );
+                       Sys_FPrintf( SYS_WRN, "WARNING: areaportal brush %i touches > 2 areas\n", b->brushNum );
                        return;
                }
                if ( b->portalareas[ 0 ] != -1 ) {
@@@ -898,7 -898,7 +898,7 @@@ void CheckAreas_r( node_t *node )
  
        if ( node->cluster != -1 ) {
                if ( node->area == -1 ) {
-                       Sys_Printf( "WARNING: cluster %d has area set to -1\n", node->cluster );
+                       Sys_FPrintf( SYS_WRN, "WARNING: cluster %d has area set to -1\n", node->cluster );
                }
        }
        if ( node->areaportal ) {
  
                // check if the areaportal touches two areas
                if ( b->portalareas[0] == -1 || b->portalareas[1] == -1 ) {
-                       Sys_Printf( "WARNING: areaportal brush %i doesn't touch two areas\n", b->brushNum );
+                       Sys_FPrintf( SYS_WRN, "WARNING: areaportal brush %i doesn't touch two areas\n", b->brushNum );
                }
        }
  }
index f3afa1a6caf036b4dc759b596a4f58d77fc1715e,19131c99191b8547991b2567e88ce5df4af34f18..2c9641bc7b0e15095f310339fa6742adb3178da2
@@@ -1594,7 -1594,7 +1594,7 @@@ static int AddMetaTriangleToSurface( ma
                         ( bi == ds->indexes[ i ] && ci == ds->indexes[ i + 2 ] && ai == ds->indexes[ i + 1 ] ) ||
                         ( ci == ds->indexes[ i ] && ai == ds->indexes[ i + 2 ] && bi == ds->indexes[ i + 1 ] ) ) {
                        /* warn about it */
-                       Sys_Printf( "WARNING: Flipped triangle: (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f)\n",
+                       Sys_FPrintf( SYS_WRN, "WARNING: Flipped triangle: (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f)\n",
                                                ds->verts[ ai ].xyz[ 0 ], ds->verts[ ai ].xyz[ 1 ], ds->verts[ ai ].xyz[ 2 ],
                                                ds->verts[ bi ].xyz[ 0 ], ds->verts[ bi ].xyz[ 1 ], ds->verts[ bi ].xyz[ 2 ],
                                                ds->verts[ ci ].xyz[ 0 ], ds->verts[ ci ].xyz[ 1 ], ds->verts[ ci ].xyz[ 2 ] );
@@@ -1704,8 -1704,8 +1704,8 @@@ static void MetaTrianglesToSurface( in
                ClearBounds( ds->mins, ds->maxs );
  
                /* clear verts/indexes */
 -              memset( verts, 0, sizeof( verts ) );
 -              memset( indexes, 0, sizeof( indexes ) );
 +              memset( verts, 0, sizeof( *verts ) * maxSurfaceVerts );
 +              memset( indexes, 0, sizeof( *indexes ) * maxSurfaceIndexes );
  
                /* add the first triangle */
                if ( AddMetaTriangleToSurface( ds, seed, qfalse ) ) {