]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
Fix a stupid typo in the sbar's ctf flag icon filenames.
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index 4527c922f7e58bd15b80b879232e85c94f746132..3fad1afb46913d7abe37b42ff755a81533be8a89 100644 (file)
--- a/image.c
+++ b/image.c
@@ -712,11 +712,6 @@ unsigned char *LoadLMP (const unsigned char *f, int filesize, int matchwidth, in
        return image_buffer;
 }
 
-static unsigned char *LoadLMPRGBA (const unsigned char *f, int filesize, int matchwidth, int matchheight)
-{
-       return LoadLMP(f, filesize, matchwidth, matchheight, false);
-}
-
 
 typedef struct q2wal_s
 {
@@ -767,9 +762,13 @@ unsigned char *LoadWAL (const unsigned char *f, int filesize, int matchwidth, in
 }
 
 
-void Image_StripImageExtension (const char *in, char *out)
+static void Image_StripImageExtension (const char *in, char *out, size_t size_out)
 {
        const char *end, *temp;
+       
+       if (size_out == 0)
+               return;
+
        end = in + strlen(in);
        if ((end - in) >= 4)
        {
@@ -780,12 +779,15 @@ void Image_StripImageExtension (const char *in, char *out)
                 || strcmp(temp, ".png") == 0
                 || strcmp(temp, ".jpg") == 0)
                        end = temp;
-               while (in < end)
+               while (in < end && size_out > 1)
+               {
                        *out++ = *in++;
+                       size_out--;
+               }
                *out++ = 0;
        }
        else
-               strcpy(out, in);
+               strlcpy(out, in, size_out);
 }
 
 typedef struct imageformat_s
@@ -801,17 +803,22 @@ imageformat_t imageformats_tenebrae[] =
        {"override/%s.tga", LoadTGA},
        {"override/%s.png", PNG_LoadImage},
        {"override/%s.jpg", JPEG_LoadImage},
+       {"override/%s.pcx", LoadPCX},
        {NULL, NULL}
 };
 
 imageformat_t imageformats_nopath[] =
 {
+       {"override/%s.tga", LoadTGA},
+       {"override/%s.png", PNG_LoadImage},
+       {"override/%s.jpg", JPEG_LoadImage},
        {"textures/%s.tga", LoadTGA},
        {"textures/%s.png", PNG_LoadImage},
        {"textures/%s.jpg", JPEG_LoadImage},
        {"%s.tga", LoadTGA},
        {"%s.png", PNG_LoadImage},
        {"%s.jpg", JPEG_LoadImage},
+       {"%s.pcx", LoadPCX},
        {NULL, NULL}
 };
 
@@ -831,7 +838,6 @@ imageformat_t imageformats_gfx[] =
        {"%s.png", PNG_LoadImage},
        {"%s.jpg", JPEG_LoadImage},
        {"%s.pcx", LoadPCX},
-       {"%s.lmp", LoadLMPRGBA},
        {NULL, NULL}
 };
 
@@ -854,8 +860,7 @@ unsigned char *loadimagepixels (const char *filename, qboolean complain, int mat
                Mem_CheckSentinelsGlobal();
        if (developer_texturelogging.integer)
                Log_Printf("textures.log", "%s\n", filename);
-       strlcpy(basename, filename, sizeof(basename));
-       Image_StripImageExtension(basename, basename); // strip filename extensions to allow replacement by other types
+       Image_StripImageExtension(filename, basename, sizeof(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 == '*')
@@ -1357,6 +1362,12 @@ void Image_MipReduce(const unsigned char *in, unsigned char *out, int *width, in
        if (*depth != 1 || destdepth != 1)
        {
                Con_Printf ("Image_Resample: 3D resampling not supported\n");
+               if (*width > destwidth)
+                       *width >>= 1;
+               if (*height > destheight)
+                       *height >>= 1;
+               if (*depth > destdepth)
+                       *depth >>= 1;
                return;
        }
        nextrow = *width * bytesperpixel;
@@ -1553,8 +1564,7 @@ int image_loadskin(imageskin_t *s, const char *shadername)
        unsigned char *bumppixels;
        int bumppixels_width, bumppixels_height;
        char name[MAX_QPATH];
-       strlcpy(name, shadername, sizeof(name));
-       Image_StripImageExtension(name, name);
+       Image_StripImageExtension(shadername, name, sizeof(name));
        memset(s, 0, sizeof(*s));
        s->basepixels = loadimagepixels(name, false, 0, 0);
        if (s->basepixels == NULL)