X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=image.c;h=538620fd0c43be6390d490a728dd47d50c0b076f;hb=e09ad7bab9b7037ef361b913a81b73c423b33bc2;hp=b41f780141bc1c940451936590bb00e877ada4d0;hpb=fd091d66e2673b19eb9c7d73d95160ef874de5e6;p=xonotic%2Fdarkplaces.git diff --git a/image.c b/image.c index b41f7801..538620fd 100644 --- a/image.c +++ b/image.c @@ -26,14 +26,14 @@ void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int if (inputflipdiagonal) { for (x = 0, line = inpixels + col_ofs; x < inputwidth; x++, line += col_inc) - for (y = 0, in = line + row_ofs; y < inputheight; y++, in += row_inc, outpixels += numinputcomponents) + for (y = 0, in = line + row_ofs; y < inputheight; y++, in += row_inc, outpixels += numoutputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = ((index = outputinputcomponentindices[c]) & 0x80000000) ? index : in[index]; } else { for (y = 0, line = inpixels + row_ofs; y < inputheight; y++, line += row_inc) - for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numinputcomponents) + for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numoutputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = ((index = outputinputcomponentindices[c]) & 0x80000000) ? index : in[index]; } @@ -44,14 +44,14 @@ void Image_CopyMux(unsigned char *outpixels, const unsigned char *inpixels, int if (inputflipdiagonal) { for (x = 0, line = inpixels + col_ofs; x < inputwidth; x++, line += col_inc) - for (y = 0, in = line + row_ofs; y < inputheight; y++, in += row_inc, outpixels += numinputcomponents) + for (y = 0, in = line + row_ofs; y < inputheight; y++, in += row_inc, outpixels += numoutputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = in[outputinputcomponentindices[c]]; } else { for (y = 0, line = inpixels + row_ofs; y < inputheight; y++, line += row_inc) - for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numinputcomponents) + for (x = 0, in = line + col_ofs; x < inputwidth; x++, in += col_inc, outpixels += numoutputcomponents) for (c = 0; c < numoutputcomponents; c++) outpixels[c] = in[outputinputcomponentindices[c]]; } @@ -327,14 +327,15 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize) targa_header.y_origin = f[10] + f[11] * 256; targa_header.width = image_width = f[12] + f[13] * 256; targa_header.height = image_height = f[14] + f[15] * 256; + targa_header.pixel_size = f[16]; + targa_header.attributes = f[17]; + if (image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0) { Con_Print("LoadTGA: invalid size\n"); PrintTargaHeader(&targa_header); return NULL; } - targa_header.pixel_size = f[16]; - targa_header.attributes = f[17]; // advance to end of header fin = f + 18; @@ -702,6 +703,10 @@ imageformat_t imageformats_tenebrae[] = {"override/%s.png", PNG_LoadImage_BGRA}, {"override/%s.jpg", JPEG_LoadImage_BGRA}, {"override/%s.pcx", LoadPCX_BGRA}, + {"%s.tga", LoadTGA_BGRA}, + {"%s.png", PNG_LoadImage_BGRA}, + {"%s.jpg", JPEG_LoadImage_BGRA}, + {"%s.pcx", LoadPCX_BGRA}, {NULL, NULL} }; @@ -720,6 +725,20 @@ imageformat_t imageformats_nopath[] = {NULL, NULL} }; +// GAME_DELUXEQUAKE only +// VorteX: the point why i use such messy texture paths is +// that GtkRadiant can't detect normal/gloss textures +// and exclude them from texture browser +// so i just use additional folder to store this textures +imageformat_t imageformats_dq[] = +{ + {"%s.tga", LoadTGA_BGRA}, + {"%s.jpg", JPEG_LoadImage_BGRA}, + {"texturemaps/%s.tga", LoadTGA_BGRA}, + {"texturemaps/%s.jpg", JPEG_LoadImage_BGRA}, + {NULL, NULL} +}; + imageformat_t imageformats_textures[] = { {"%s.tga", LoadTGA_BGRA}, @@ -774,6 +793,8 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo } if (gamemode == GAME_TENEBRAE) firstformat = imageformats_tenebrae; + else if (gamemode == GAME_DELUXEQUAKE) + firstformat = imageformats_dq; else if (!strcasecmp(name, "textures")) firstformat = imageformats_textures; else if (!strcasecmp(name, "gfx")) @@ -785,7 +806,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo // now try all the formats in the selected list for (format = firstformat;format->formatstring;format++) { - sprintf (name, format->formatstring, basename); + dpsnprintf (name, sizeof(name), format->formatstring, basename); f = FS_LoadFile(name, tempmempool, true, &filesize); if (f) { @@ -816,10 +837,7 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo return data; } else - { - if (developer.integer >= 1) - Con_DPrintf("Error loading image %s (file loaded but decode failed)\n", name); - } + Con_DPrintf("Error loading image %s (file loaded but decode failed)\n", name); } } if (complain) @@ -827,10 +845,14 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo Con_Printf("Couldn't load %s using ", filename); for (format = firstformat;format->formatstring;format++) { - sprintf (name, format->formatstring, basename); + dpsnprintf (name, sizeof(name), format->formatstring, basename); Con_Printf(format == firstformat ? "\"%s\"" : (format[1].formatstring ? ", \"%s\"" : " or \"%s\".\n"), format->formatstring); } } + + // texture loading can take a while, so make sure we're sending keepalives + CL_KeepaliveMessage(false); + if (developer_memorydebug.integer) Mem_CheckSentinelsGlobal(); return NULL; @@ -855,7 +877,7 @@ int fixtransparentpixels(unsigned char *data, int w, int h) int const FIXTRANS_HAS_U = 8; int const FIXTRANS_HAS_D = 16; int const FIXTRANS_FIXED = 32; - unsigned char *fixMask = Mem_Alloc(tempmempool, w * h); + unsigned char *fixMask = (unsigned char *) Mem_Alloc(tempmempool, w * h); int fixPixels = 0; int changedPixels = 0; int x, y;