engine: common: mod_bmodel: fix crash on Quake sky textures, pass real miptex data to Mod_InitSkyClouds instead of the on-stack header copy

Fixes: ef5295c5a ("engine: workaround the misalignment issue when reading textures in BSP")
This commit is contained in:
Alibek Omarov
2026-08-08 17:58:30 +05:00
parent f864494603
commit b2ebe5adfd

View File

@@ -2620,7 +2620,7 @@ static qboolean Mod_SearchForTextureReplacement( char *out, size_t size, const c
return false;
}
static void Mod_InitSkyClouds( model_t *mod, const mip_t *mt, texture_t *tx, qboolean custom_palette )
static void Mod_InitSkyClouds( model_t *mod, const mip_t *mt, const byte *mtdata, texture_t *tx, qboolean custom_palette )
{
#if !XASH_DEDICATED
rgbdata_t r_temp, *r_sky;
@@ -2679,7 +2679,7 @@ static void Mod_InitSkyClouds( model_t *mod, const mip_t *mt, texture_t *tx, qbo
size += sizeof( short ) + 768;
Image_SetForceFlags( IL_HOST_ENDIAN );
r_sky = FS_LoadImage( texname, (byte *)mt, size );
r_sky = FS_LoadImage( texname, mtdata, size );
}
else
{
@@ -2795,7 +2795,7 @@ static void Mod_LoadTextureData( model_t *mod, dbspmodel_t *bmod, int textureInd
// check for multi-layered sky texture (quake1 specific)
if( bmod->isworld && Q_strncmp( mipTex.name, "sky", 3 ) == 0 && ( mipTex.width / mipTex.height ) == 2 )
{
Mod_InitSkyClouds( mod, &mipTex, texture, usesCustomPalette ); // load quake sky
Mod_InitSkyClouds( mod, &mipTex, mipRaw, texture, usesCustomPalette ); // load quake sky
return;
}