From: havoc Date: Tue, 24 Dec 2002 23:00:59 +0000 (+0000) Subject: loadimagepixels is a little cleaner now (yes made cleaner by goto...) and dprints... X-Git-Tag: RELEASE_0_2_0_RC1~24 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=11a196e65f1632e082eefd4b0e480cbc5fd678d6;ds=inline loadimagepixels is a little cleaner now (yes made cleaner by goto...) and dprints info about loaded images critical bug in image_loadskin fixed (s->basepixels_width and height were not being set) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2684 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/image.c b/image.c index c26befb4..aa7f0ef9 100644 --- a/image.c +++ b/image.c @@ -554,76 +554,78 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth, if (f) { data = LoadTGA (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "override/%s.jpg", basename); f = COM_LoadFile(name, true); if (f) { data = JPEG_LoadImage (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "textures/%s.tga", basename); f = COM_LoadFile(name, true); if (f) { data = LoadTGA (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "textures/%s.jpg", basename); f = COM_LoadFile(name, true); if (f) { data = JPEG_LoadImage (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "textures/%s.pcx", basename); f = COM_LoadFile(name, true); if (f) { data = LoadPCX (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "%s.tga", basename); f = COM_LoadFile(name, true); if (f) { data = LoadTGA (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "%s.jpg", basename); f = COM_LoadFile(name, true); if (f) { data = JPEG_LoadImage (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "%s.pcx", basename); f = COM_LoadFile(name, true); if (f) { data = LoadPCX (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } sprintf (name, "%s.lmp", basename); f = COM_LoadFile(name, true); if (f) { data = LoadLMP (f, matchwidth, matchheight); - Mem_Free(f); - return data; + goto loaded; } if (complain) Con_Printf ("Couldn't load %s.tga, .jpg, .pcx, .lmp\n", filename); return NULL; +loaded: + Mem_Free(f); + Con_DPrintf("loaded image %s (%dx%d)\n", name); + if (image_width == 0 || image_height == 0) + { + Con_Printf("error loading image %s - it is a %dx%d pixel image!\n", name); + if (data != NULL) + Mem_Free(data); + data = NULL; + } + return data; } int image_makemask (const qbyte *in, qbyte *out, int size) @@ -1414,6 +1416,8 @@ int image_loadskin(imageskin_t *s, char *name) s->basepixels = loadimagepixels(name, false, 0, 0); if (s->basepixels == NULL) return false; + s->basepixels_width = image_width; + s->basepixels_height = image_height; bumppixels = NULL;bumppixels_width = 0;bumppixels_height = 0; for (j = 3;j < s->basepixels_width * s->basepixels_height * 4;j += 4)