]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image.c
Fix some warnings found by cppcheck
[xonotic/darkplaces.git] / image.c
diff --git a/image.c b/image.c
index 77b9435e66695d1cf3d1638bc667dfd323af4beb..a072df248dd460dd7195013a8061a791331c77ae 100644 (file)
--- a/image.c
+++ b/image.c
@@ -20,7 +20,7 @@ static void Image_CopyAlphaFromBlueBGRA(unsigned char *outpixels, const unsigned
 }
 
 #if 1
-// written by LordHavoc in a readable way, optimized by Vic, further optimized by LordHavoc (the non-special index case), readable version preserved below this
+// written by LadyHavoc in a readable way, optimized by Vic, further optimized by LadyHavoc (the non-special index case), readable version preserved below this
 void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int inputwidth, int inputheight, qboolean inputflipx, qboolean inputflipy, qboolean inputflipdiagonal, int numoutputcomponents, int numinputcomponents, int *outputinputcomponentindices)
 {
        int index, c, x, y;
@@ -210,7 +210,7 @@ static unsigned char* LoadPCX_BGRA (const unsigned char *f, int filesize, int *m
        memcpy(&pcx, fin, sizeof(pcx));
        fin += sizeof(pcx);
 
-       // LordHavoc: big-endian support ported from QF newtree
+       // LadyHavoc: big-endian support ported from QF newtree
        pcx.xmax = LittleShort (pcx.xmax);
        pcx.xmin = LittleShort (pcx.xmin);
        pcx.ymax = LittleShort (pcx.ymax);
@@ -300,7 +300,7 @@ qboolean LoadPCX_QWSkin(const unsigned char *f, int filesize, unsigned char *pix
        memcpy(&pcx, fin, sizeof(pcx));
        fin += sizeof(pcx);
 
-       // LordHavoc: big-endian support ported from QF newtree
+       // LadyHavoc: big-endian support ported from QF newtree
        pcx.xmax = LittleShort (pcx.xmax);
        pcx.xmin = LittleShort (pcx.xmin);
        pcx.ymax = LittleShort (pcx.ymax);
@@ -878,7 +878,7 @@ static unsigned char* LoadLMP_BGRA(const unsigned char *f, int filesize, int *mi
 }
 
 // gfx/conchars is a raw 128x128 image with 0 as transparent color rather than 255
-unsigned char *LoadConChars_BGRA(const unsigned char *f, int filesize, int *miplevel)
+static unsigned char *LoadConChars_BGRA(const unsigned char *f, int filesize, int *miplevel)
 {
        unsigned char *image_buffer;
        int i;
@@ -970,28 +970,46 @@ imageformat_t;
 imageformat_t imageformats_tenebrae[] =
 {
        {"override/%s.tga", LoadTGA_BGRA},
+       {"override/%s.TGA", LoadTGA_BGRA},
        {"override/%s.png", PNG_LoadImage_BGRA},
+       {"override/%s.PNG", PNG_LoadImage_BGRA},
        {"override/%s.jpg", JPEG_LoadImage_BGRA},
+       {"override/%s.JPG", JPEG_LoadImage_BGRA},
        {"override/%s.pcx", LoadPCX_BGRA},
+       {"override/%s.PCX", LoadPCX_BGRA},      
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.PNG", PNG_LoadImage_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.pcx", LoadPCX_BGRA},
+       {"%s.PCX", LoadPCX_BGRA},
        {NULL, NULL}
 };
 
 imageformat_t imageformats_nopath[] =
 {
        {"override/%s.tga", LoadTGA_BGRA},
+       {"override/%s.TGA", LoadTGA_BGRA},
        {"override/%s.png", PNG_LoadImage_BGRA},
+       {"override/%s.PNG", PNG_LoadImage_BGRA},
        {"override/%s.jpg", JPEG_LoadImage_BGRA},
+       {"override/%s.JPG", JPEG_LoadImage_BGRA},
        {"textures/%s.tga", LoadTGA_BGRA},
+       {"textures/%s.TGA", LoadTGA_BGRA},
        {"textures/%s.png", PNG_LoadImage_BGRA},
+       {"textures/%s.PNG", PNG_LoadImage_BGRA},
        {"textures/%s.jpg", JPEG_LoadImage_BGRA},
+       {"textures/%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.PNG", PNG_LoadImage_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.pcx", LoadPCX_BGRA},
+       {"%s.PCX", LoadPCX_BGRA},
        {NULL, NULL}
 };
 
@@ -1003,39 +1021,58 @@ imageformat_t imageformats_nopath[] =
 imageformat_t imageformats_dq[] =
 {
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},        
        {"texturemaps/%s.tga", LoadTGA_BGRA},
+       {"texturemaps/%s.TGA", LoadTGA_BGRA},   
        {"texturemaps/%s.jpg", JPEG_LoadImage_BGRA},
+       {"texturemaps/%s.JPG", JPEG_LoadImage_BGRA},    
        {NULL, NULL}
 };
 
 imageformat_t imageformats_textures[] =
 {
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.PNG", PNG_LoadImage_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.pcx", LoadPCX_BGRA},
+       {"%s.PCX", LoadPCX_BGRA},
        {"%s.wal", LoadWAL_BGRA},
+       {"%s.WAL", LoadWAL_BGRA},       
        {NULL, NULL}
 };
 
 imageformat_t imageformats_gfx[] =
 {
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.PNG", PNG_LoadImage_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.pcx", LoadPCX_BGRA},
+       {"%s.PCX", LoadPCX_BGRA},
        {"%s.lmp", LoadLMP_BGRA},
+       {"%s.LMP", LoadLMP_BGRA},
        {NULL, NULL}
 };
 
 imageformat_t imageformats_other[] =
 {
        {"%s.tga", LoadTGA_BGRA},
+       {"%s.TGA", LoadTGA_BGRA},
        {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.PNG", PNG_LoadImage_BGRA},
        {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.JPG", JPEG_LoadImage_BGRA},
        {"%s.pcx", LoadPCX_BGRA},
+       {"%s.PCX", LoadPCX_BGRA},
        {"%s.lmp", LoadLMP_BGRA},
+       {"%s.LMP", LoadLMP_BGRA},       
        {NULL, NULL}
 };
 
@@ -1044,6 +1081,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo
 {
        fs_offset_t filesize;
        imageformat_t *firstformat, *format;
+       int mymiplevel;
        unsigned char *f, *data = NULL, *data2 = NULL;
        char basename[MAX_QPATH], name[MAX_QPATH], name2[MAX_QPATH], path[MAX_QPATH], afterpath[MAX_QPATH], *c;
        char vabuf[1024];
@@ -1086,7 +1124,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo
                f = FS_LoadFile(name, tempmempool, true, &filesize);
                if (f)
                {
-                       int mymiplevel = miplevel ? *miplevel : 0;
+                       mymiplevel = miplevel ? *miplevel : 0;
                        image_width = 0;
                        image_height = 0;
                        data = format->loadfunc(f, (int)filesize, &mymiplevel);
@@ -1152,7 +1190,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo
                        if (developer_loading.integer)
                                Con_Printf("loading gfx.wad lump \"%s\"\n", afterpath);
 
-                       int mymiplevel = miplevel ? *miplevel : 0;
+                       mymiplevel = miplevel ? *miplevel : 0;
                        if (!strcmp(afterpath, "conchars"))
                        {
                                // conchars is a raw image and with color 0 as transparent instead of 255
@@ -1370,19 +1408,19 @@ int fixtransparentpixels(unsigned char *data, int w, int h)
        return changedPixels;
 }
 
-void Image_FixTransparentPixels_f(void)
+void Image_FixTransparentPixels_f(cmd_state_t *cmd)
 {
        const char *filename, *filename_pattern;
        fssearch_t *search;
        int i, n;
        char outfilename[MAX_QPATH], buf[MAX_QPATH];
        unsigned char *data;
-       if(Cmd_Argc() != 2)
+       if(Cmd_Argc(cmd) != 2)
        {
-               Con_Printf("Usage: %s imagefile\n", Cmd_Argv(0));
+               Con_Printf("Usage: %s imagefile\n", Cmd_Argv(cmd, 0));
                return;
        }
-       filename_pattern = Cmd_Argv(1);
+       filename_pattern = Cmd_Argv(cmd, 1);
        search = FS_Search(filename_pattern, true, true);
        if(!search)
                return;
@@ -2094,7 +2132,7 @@ unsigned char *Image_GetEmbeddedPicBGRA(const char *name)
                        return data;
                }
        }
-       if (!strcmp(name, "white"))
+       if (!strcmp(name, "white") || !strcmp(name, "#white") || !strcmp(name, "*white") || !strcmp(name, "$whiteimage"))
                return Image_GenerateWhite();
        if (!strcmp(name, "gfx/conchars"))
                return Image_GenerateConChars();