shithub: qk1

Download patch

ref: 4ccf8bb9ef7dcfda6d7e0ab172df2dbdae74110c
parent: 612fcd2a36544c584e9933ccdcc04407edaa3485
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Dec 31 12:10:09 EST 2023

bsp30: don't trust map's builtin non-0 mipmap levels when it comes to fences - scale them as well

--- a/i_wad.c
+++ b/i_wad.c
@@ -184,10 +184,10 @@
 		fb = strchr(name, '~') != nil;
 		for(n = 0; n < num; n++, t++, out++){
 			x = *t*3;
-			if(x >= palsz || (name[0] == '{' && x == palsz-3))
+			if(x >= palsz || (name[0] == '{' && x >= palsz-3))
 				*out = 0;
 			else
-				*out = ((fb && x >= (256-32)*3) ? 0 : 0xff)<<24 | pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2];
+				*out = ((fb && x >= palsz-32*3) ? 0 : 0xff)<<24 | pal[x+0]<<16 | pal[x+1]<<8 | pal[x+2];
 		}
 	}
 	return num;
--- a/model_bsp30.c
+++ b/model_bsp30.c
@@ -156,16 +156,28 @@
 			if((palsz = le16(x)) > 0){
 				pal3torgbx(p, tx->pixels, pixels, x, palsz);
 				if(tx->name[0] == '{'){
-					/* last color is transparent */
+					pixels = w*h;
 					for(j = 0; j < pixels; j++){
-						if(p[j] == palsz-1)
+						if(p[j] >= palsz-1) /* last color is transparent */
 							tx->pixels[j] = 0;
 					}
+					for(j = 1; j < MIPLEVELS; j++){
+						w /= 2;
+						h /= 2;
+						pixels_resize(
+							tx->pixels+tx->offsets[0],
+							tx->pixels+tx->offsets[j],
+							tx->width, tx->height,
+							w, h,
+							false,
+							true
+						);
+					}
 				}
 				if(strchr(tx->name, '~') != nil){
 					/* last 32 colors are fullbright */
 					for(j = 0; j < pixels; j++){
-						if(p[j] >= 256-32)
+						if(p[j] >= palsz-32)
 							tx->pixels[j] &= 0xffffff;
 					}
 				}