]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/surface.c
Merge commit 'f73cc19a6166fc04269f953c980175779f81b9b0' into garux-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / surface.c
index 65a651c425b471e8ab8dc063479a2a8bba249140..96f7270c8d4b37067a3dce8f9d3fb93c04e8b80f 100644 (file)
@@ -569,7 +569,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
                                if ( fabs( dist ) > PLANAR_EPSILON ) {
                                        //%     if( ds->planeNum >= 0 )
                                        //%     {
-                                       //%             Sys_Printf( "WARNING: Planar surface marked unplanar (%f > %f)\n", fabs( dist ), PLANAR_EPSILON );
+                                       //%             Sys_FPrintf( SYS_WRN, "WARNING: Planar surface marked unplanar (%f > %f)\n", fabs( dist ), PLANAR_EPSILON );
                                        //%             ds->verts[ i ].color[ 0 ][ 0 ] = ds->verts[ i ].color[ 0 ][ 2 ] = 0;
                                        //%     }
                                        ds->planar = qfalse;
@@ -590,7 +590,7 @@ void ClassifySurfaces( int numSurfs, mapDrawSurface_t *ds ){
                        ds->planeNum = -1;
                        VectorClear( ds->lightmapVecs[ 2 ] );
                        //% if( ds->type == SURF_META || ds->type == SURF_FACE )
-                       //%             Sys_Printf( "WARNING: Non-planar face (%d): %s\n", ds->planeNum, ds->shaderInfo->shader );
+                       //%             Sys_FPrintf( SYS_WRN, "WARNING: Non-planar face (%d): %s\n", ds->planeNum, ds->shaderInfo->shader );
                }
 
                /* -----------------------------------------------------------------
@@ -781,6 +781,10 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t
 }
 
 
+#define snprintf_ignore(s, n, format, ...) do { \
+    size_t __n = snprintf(s, n, format, __VA_ARGS__); \
+    if (n >= n) {} /* truncated, ignore */ \
+} while (0)
 
 /*
    GetIndexedShader() - ydnar
@@ -827,10 +831,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
 
        /* make a shader name */
        if ( minShaderIndex == maxShaderIndex ) {
-               sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%d", im->shader, maxShaderIndex );
        }
        else{
-               sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
        }
 
        /* get the shader */
@@ -926,17 +930,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
        /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
        if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
                //%     Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
-               sprintf( tempShader, "%s_lf", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_lf", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_rt", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_rt", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_ft", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_ft", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_bk", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_bk", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_up", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_up", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_dn", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_dn", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
        }
 
@@ -1164,7 +1168,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( entity_t *e, parseMesh_t *p, mesh_t *mesh
 
        /* spew forth errors */
        if ( VectorLength( plane ) < 0.001f ) {
-               Sys_Printf( "BOGUS " );
+               Sys_Printf( "DrawSurfaceForMesh: bogus plane\n" );
        }
 
        /* test each vert */
@@ -2051,6 +2055,8 @@ int FilterPointIntoTree_r( vec3_t point, mapDrawSurface_t *ds, node_t *node ){
        return AddReferenceToLeaf( ds, node );
 }
 
+
+
 /*
    FilterPointConvexHullIntoTree_r() - ydnar
    filters the convex hull of multiple points from a surface into the tree
@@ -2101,6 +2107,7 @@ int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurfac
 }
 
 
+
 /*
    FilterWindingIntoTree_r() - ydnar
    filters a winding from a drawsurface into the tree
@@ -2124,7 +2131,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                   si->mins[ 2 ] != 0.0f || si->maxs[ 2 ] != 0.0f ) ) {
                static qboolean warned = qfalse;
                if ( !warned ) {
-                       Sys_Printf( "WARNING: this map uses the deformVertexes move hack\n" );
+                       Sys_FPrintf( SYS_WRN, "WARNING: this map uses the deformVertexes move hack\n" );
                        warned = qtrue;
                }
 
@@ -2184,6 +2191,7 @@ int FilterWindingIntoTree_r( winding_t *w, mapDrawSurface_t *ds, node_t *node ){
                                return FilterWindingIntoTree_r( w, ds, node->children[ 1 ] );
                        }
                        #else
+                       (void) plane2;
                        /* div0: this is the cholera (doesn't hit enough) */
 
                        /* the drawsurf might have an associated plane, if so, force a filter here */
@@ -2518,7 +2526,7 @@ void EmitDrawIndexes( mapDrawSurface_t *ds, bspDrawSurface_t *out ){
                        /* validate the index */
                        if ( ds->type != SURFACE_PATCH ) {
                                if ( bspDrawIndexes[ numBSPDrawIndexes ] < 0 || bspDrawIndexes[ numBSPDrawIndexes ] >= ds->numVerts ) {
-                                       Sys_Printf( "WARNING: %d %s has invalid index %d (%d)\n",
+                                       Sys_FPrintf( SYS_WRN, "WARNING: %d %s has invalid index %d (%d)\n",
                                                                numBSPDrawSurfaces,
                                                                ds->shaderInfo->shader,
                                                                bspDrawIndexes[ numBSPDrawIndexes ],
@@ -2589,6 +2597,8 @@ void EmitFlareSurface( mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    EmitPatchSurface()
    emits a bsp patch drawsurface
@@ -2696,6 +2706,8 @@ void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds ){
        numSurfacesByType[ ds->type ]++;
 }
 
+
+
 /*
    OptimizeTriangleSurface() - ydnar
    optimizes the vertex/index data in a triangle surface
@@ -2966,6 +2978,7 @@ static void EmitFaceSurface( mapDrawSurface_t *ds ){
 }
 
 
+
 /*
    MakeDebugPortalSurfs_r() - ydnar
    generates drawsurfaces for passable portals in the bsp
@@ -3753,7 +3766,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ){
                                bspDrawSurface_t    *out;
                                out = &bspDrawSurfaces[ numBSPDrawSurfaces - 1 ];
                                if ( out->numVerts == 3 && out->numIndexes > 3 ) {
-                                       Sys_Printf( "\nWARNING: Potentially bad %s surface (%d: %d, %d)\n     %s\n",
+                                       Sys_FPrintf( SYS_WRN, "WARNING: Potentially bad %s surface (%d: %d, %d)\n     %s\n",
                                                                surfaceTypes[ ds->type ],
                                                                numBSPDrawSurfaces - 1, out->numVerts, out->numIndexes, si->shader );
                                }