]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
changed most Sys_Error calls to Con_Printf with appropriate error returns
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index 745aac100106482b53c0742ab6e24a01f6c2058b..4e372a85aea5dbf3e2dd04a918ebb61ef0fd1b1e 100644 (file)
--- a/image.c
+++ b/image.c
@@ -692,7 +692,8 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth,
                Mem_CheckSentinelsGlobal();
        if (developer_texturelogging.integer)
                Log_Printf("textures.log", "%s\n", filename);
-       Image_StripImageExtension(filename, basename); // strip filename extensions to allow replacement by other types
+       strlcpy(basename, filename, sizeof(basename));
+       Image_StripImageExtension(basename, basename); // strip filename extensions to allow replacement by other types
        // replace *'s with #, so commandline utils don't get confused when dealing with the external files
        for (c = basename;*c;c++)
                if (*c == '*')
@@ -1302,7 +1303,10 @@ Image_Resample
 void Image_Resample (const void *indata, int inwidth, int inheight, int indepth, void *outdata, int outwidth, int outheight, int outdepth, int bytesperpixel, int quality)
 {
        if (indepth != 1 || outdepth != 1)
-               Sys_Error("Image_Resample: 3D resampling not supported\n");
+       {
+               Con_Printf ("Image_Resample: 3D resampling not supported\n");
+               return;
+       }
        if (bytesperpixel == 4)
        {
                if (quality)
@@ -1318,7 +1322,7 @@ void Image_Resample (const void *indata, int inwidth, int inheight, int indepth,
                        Image_Resample24Nolerp(indata, inwidth, inheight, outdata, outwidth, outheight);
        }
        else
-               Sys_Error("Image_Resample: unsupported bytesperpixel %i\n", bytesperpixel);
+               Con_Printf ("Image_Resample: unsupported bytesperpixel %i\n", bytesperpixel);
 }
 
 // in can be the same as out
@@ -1326,7 +1330,10 @@ void Image_MipReduce(const qbyte *in, qbyte *out, int *width, int *height, int *
 {
        int x, y, nextrow;
        if (*depth != 1 || destdepth != 1)
-               Sys_Error("Image_Resample: 3D resampling not supported\n");
+       {
+               Con_Printf ("Image_Resample: 3D resampling not supported\n");
+               return;
+       }
        nextrow = *width * bytesperpixel;
        if (*width > destwidth)
        {
@@ -1367,7 +1374,7 @@ void Image_MipReduce(const qbyte *in, qbyte *out, int *width, int *height, int *
                                }
                        }
                        else
-                               Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+                               Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
                }
                else
                {
@@ -1402,7 +1409,7 @@ void Image_MipReduce(const qbyte *in, qbyte *out, int *width, int *height, int *
                                }
                        }
                        else
-                               Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+                               Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
                }
        }
        else
@@ -1443,10 +1450,10 @@ void Image_MipReduce(const qbyte *in, qbyte *out, int *width, int *height, int *
                                }
                        }
                        else
-                               Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+                               Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
                }
                else
-                       Sys_Error("Image_MipReduce: desired size already achieved\n");
+                       Con_Printf ("Image_MipReduce: desired size already achieved\n");
        }
 }
 
@@ -1494,8 +1501,8 @@ void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *ou
                        n[1] = dv[0][2]*dv[1][0]-dv[0][0]*dv[1][2];
                        n[2] = dv[0][0]*dv[1][1]-dv[0][1]*dv[1][0];
                        */
-                       n[0] = ((p1[0] + p1[1] + p1[2]) - (p0[0] + p0[1] + p0[2]));
-                       n[1] = ((p0[0] + p0[1] + p0[2]) - (p2[0] + p2[1] + p2[2]));
+                       n[0] = ((p0[0] + p0[1] + p0[2]) - (p1[0] + p1[1] + p1[2]));
+                       n[1] = ((p2[0] + p2[1] + p2[2]) - (p0[0] + p0[1] + p0[2]));
                        n[2] = ibumpscale;
                        VectorNormalize(n);
                        /*
@@ -1521,7 +1528,8 @@ int image_loadskin(imageskin_t *s, char *shadername)
        qbyte *bumppixels;
        int bumppixels_width, bumppixels_height;
        char name[MAX_QPATH];
-       Image_StripImageExtension(shadername, name);
+       strlcpy(name, shadername, sizeof(name));
+       Image_StripImageExtension(name, name);
        memset(s, 0, sizeof(*s));
        s->basepixels = loadimagepixels(name, false, 0, 0);
        if (s->basepixels == NULL)