From: James O'Neill <hemebond@gmail.com>
Date: Sun, 21 Apr 2024 15:07:23 +0000 (+0900)
Subject: Merge PR 'Compare Q1BSP sky textures properly when loading'
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5dc4083f462f3a21d6acc4d69e6da1dd6f4ed8a5;p=xonotic%2Fdarkplaces.git

Merge PR 'Compare Q1BSP sky textures properly when loading'

Fixes https://github.com/DarkPlacesEngine/darkplaces/issues/58 by loading sky textures with CRC checking, previously they
were always considered duplicates by `R_SkinFrame_LoadInternalBGRA`
because they reuse the same names.

Closes https://github.com/DarkPlacesEngine/darkplaces/issues/105

See https://github.com/DarkPlacesEngine/darkplaces/pull/153

---------

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
---

diff --git a/model_brush.c b/model_brush.c
index 3357d0df..83645cf3 100644
--- a/model_brush.c
+++ b/model_brush.c
@@ -1625,8 +1625,21 @@ static void Mod_Q1BSP_LoadSplitSky (unsigned char *src, int width, int height, i
 		}
 	}
 
-	loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_solidtexture", 0         , (unsigned char *) solidpixels, w, h, 0, 0, 0, vid.sRGB3D);
-	loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA("sky_alphatexture", TEXF_ALPHA, (unsigned char *) alphapixels, w, h, 0, 0, 0, vid.sRGB3D);
+	// Load the solid and alpha parts of the sky texture as separate textures
+	loadmodel->brush.solidskyskinframe = R_SkinFrame_LoadInternalBGRA(
+		"sky_solidtexture",
+		0,
+		(unsigned char *) solidpixels,
+		w, h, w, h,
+		CRC_Block((unsigned char *) solidpixels, w*h*4),
+		vid.sRGB3D);
+	loadmodel->brush.alphaskyskinframe = R_SkinFrame_LoadInternalBGRA(
+		"sky_alphatexture",
+		TEXF_ALPHA,
+		(unsigned char *) alphapixels,
+		w, h, w, h,
+		CRC_Block((unsigned char *) alphapixels, w*h*4),
+		vid.sRGB3D);
 	Mem_Free(solidpixels);
 	Mem_Free(alphapixels);
 }