]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
collision code cleanups (model->brush.TraceBox is now used for everything except...
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index 4c7aa0f6dd26517b7497d0b2a8d7f0b9c80e52d9..c84b86323e1620bf09c112a1ef4eeccd0d94469f 100644 (file)
--- a/image.c
+++ b/image.c
@@ -482,7 +482,7 @@ qbyte *LoadWAL (qbyte *f, int matchwidth, int matchheight)
        qbyte *image_rgba;
        const q2wal_t *inwal = (const void *)f;
 
-       if (fs_filesize < sizeof(q2wal_t))
+       if (fs_filesize < (int) sizeof(q2wal_t))
        {
                Con_Printf("LoadWAL: invalid WAL file\n");
                return NULL;
@@ -498,7 +498,7 @@ qbyte *LoadWAL (qbyte *f, int matchwidth, int matchheight)
        if ((matchwidth && image_width != matchwidth) || (matchheight && image_height != matchheight))
                return NULL;
 
-       if (fs_filesize < sizeof(q2wal_t) + LittleLong(inwal->offsets[0]) + image_width * image_height)
+       if ((int) fs_filesize < (int) sizeof(q2wal_t) + (int) LittleLong(inwal->offsets[0]) + image_width * image_height)
        {
                Con_Printf("LoadWAL: invalid WAL file\n");
                return NULL;
@@ -565,7 +565,11 @@ void Image_StripImageExtension (const char *in, char *out)
        if ((end - in) >= 4)
        {
                temp = end - 4;
-               if (strcmp(temp, ".tga") == 0 || strcmp(temp, ".pcx") == 0 || strcmp(temp, ".lmp") == 0)
+               if (strcmp(temp, ".tga") == 0
+                || strcmp(temp, ".pcx") == 0
+                || strcmp(temp, ".lmp") == 0
+                || strcmp(temp, ".png") == 0
+                || strcmp(temp, ".jpg") == 0)
                        end = temp;
                while (in < end)
                        *out++ = *in++;
@@ -600,6 +604,8 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth,
        int i;
        qbyte *f, *data = NULL;
        char basename[MAX_QPATH], name[MAX_QPATH], *c;
+       if (developer_memorydebug.integer)
+               Mem_CheckSentinelsGlobal();
        Image_StripImageExtension(filename, 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++)
@@ -612,6 +618,8 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth,
                {
                        Mem_Free(f);
                        Con_DPrintf("loaded image %s (%dx%d)\n", name, image_width, image_height);
+                       if (developer_memorydebug.integer)
+                               Mem_CheckSentinelsGlobal();
                        return data;
                }
        }
@@ -624,6 +632,8 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth,
                        Con_Printf (i == 0 ? "\"%s\"" : (imageformats[i+1].formatstring ? ", \"%s\"" : " or \"%s\".\n"), imageformats[i].formatstring);
                }
        }
+       if (developer_memorydebug.integer)
+               Mem_CheckSentinelsGlobal();
        return NULL;
 }
 
@@ -1414,11 +1424,13 @@ void Image_HeightmapToNormalmap(const unsigned char *inpixels, unsigned char *ou
        }
 }
 
-int image_loadskin(imageskin_t *s, char *name)
+int image_loadskin(imageskin_t *s, char *shadername)
 {
        int j;
        qbyte *bumppixels;
        int bumppixels_width, bumppixels_height;
+       char name[MAX_QPATH];
+       Image_StripImageExtension(shadername, name);
        memset(s, 0, sizeof(*s));
        s->basepixels = loadimagepixels(name, false, 0, 0);
        if (s->basepixels == NULL)