|
|
@ -1801,8 +1801,11 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
// release old sky layers first
|
|
|
|
// release old sky layers first
|
|
|
|
ref.dllFuncs.R_FreeSharedTexture( REF_ALPHASKY_TEXTURE ); |
|
|
|
if( !Host_IsDedicated() ) |
|
|
|
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE ); |
|
|
|
{ |
|
|
|
|
|
|
|
ref.dllFuncs.R_FreeSharedTexture( REF_ALPHASKY_TEXTURE ); |
|
|
|
|
|
|
|
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE ); |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1827,8 +1830,11 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) |
|
|
|
|
|
|
|
|
|
|
|
Q_strncpy( tx->name, "*default", sizeof( tx->name )); |
|
|
|
Q_strncpy( tx->name, "*default", sizeof( tx->name )); |
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ); |
|
|
|
if( !Host_IsDedicated() ) |
|
|
|
tx->width = tx->height = 16; |
|
|
|
{ |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ); |
|
|
|
|
|
|
|
tx->width = tx->height = 16; |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
continue; // missed
|
|
|
|
continue; // missed
|
|
|
|
} |
|
|
|
} |
|
|
@ -1869,99 +1875,102 @@ static void Mod_LoadTextures( dbspmodel_t *bmod ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
#ifndef XASH_DEDICATED |
|
|
|
// check for multi-layered sky texture (quake1 specific)
|
|
|
|
if( !Host_IsDedicated() ) |
|
|
|
if( bmod->isworld && !Q_strncmp( mt->name, "sky", 3 ) && (( mt->width / mt->height ) == 2 )) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ref.dllFuncs.R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
|
|
|
|
// check for multi-layered sky texture (quake1 specific)
|
|
|
|
|
|
|
|
if( bmod->isworld && !Q_strncmp( mt->name, "sky", 3 ) && (( mt->width / mt->height ) == 2 ) ) |
|
|
|
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) && |
|
|
|
{ |
|
|
|
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) ) |
|
|
|
ref.dllFuncs.R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
|
|
|
|
SetBits( world.flags, FWORLD_SKYSPHERE ); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// texture loading order:
|
|
|
|
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) && |
|
|
|
// 1. from wad
|
|
|
|
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) ) |
|
|
|
// 2. internal from map
|
|
|
|
SetBits( world.flags, FWORLD_SKYSPHERE ); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// trying wad texture (force while r_wadtextures is 1)
|
|
|
|
// texture loading order:
|
|
|
|
if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || ( mt->offsets[0] <= 0 )) |
|
|
|
// 1. from wad
|
|
|
|
{ |
|
|
|
// 2. internal from map
|
|
|
|
Q_snprintf( texname, sizeof( texname ), "%s.mip", mt->name ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check wads in reverse order
|
|
|
|
// trying wad texture (force while r_wadtextures is 1)
|
|
|
|
for( j = bmod->wadlist.count - 1; j >= 0; j-- ) |
|
|
|
if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || ( mt->offsets[0] <= 0 )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *texpath = va( "%s.wad/%s", bmod->wadlist.wadnames[j], texname ); |
|
|
|
Q_snprintf( texname, sizeof( texname ), "%s.mip", mt->name ); |
|
|
|
|
|
|
|
|
|
|
|
if( FS_FileExists( texpath, false )) |
|
|
|
// check wads in reverse order
|
|
|
|
|
|
|
|
for( j = bmod->wadlist.count - 1; j >= 0; j-- ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS ); |
|
|
|
char *texpath = va( "%s.wad/%s", bmod->wadlist.wadnames[j], texname ); |
|
|
|
bmod->wadlist.wadusage[j]++; // this wad are really used
|
|
|
|
|
|
|
|
break; |
|
|
|
if( FS_FileExists( texpath, false )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS ); |
|
|
|
|
|
|
|
bmod->wadlist.wadusage[j]++; // this wad are really used
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wad failed, so use internal texture (if present)
|
|
|
|
|
|
|
|
if( mt->offsets[0] > 0 && !tx->gl_texturenum ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// NOTE: imagelib detect miptex version by size
|
|
|
|
|
|
|
|
// 770 additional bytes is indicated custom palette
|
|
|
|
|
|
|
|
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( custom_palette ) size += sizeof( short ) + 768; |
|
|
|
|
|
|
|
Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name ); |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if texture is completely missed
|
|
|
|
|
|
|
|
if( !tx->gl_texturenum ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( host.type != HOST_DEDICATED ) |
|
|
|
|
|
|
|
Con_DPrintf( S_ERROR "unable to find %s.mip\n", mt->name ); |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check for luma texture
|
|
|
|
|
|
|
|
if( FBitSet( REF_GET_PARM( PARM_TEX_FLAGS, tx->gl_texturenum ), TF_HAS_LUMA )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Q_snprintf( texname, sizeof( texname ), "#%s:%s_luma.mip", loadstat.name, mt->name ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( mt->offsets[0] > 0 ) |
|
|
|
// wad failed, so use internal texture (if present)
|
|
|
|
|
|
|
|
if( mt->offsets[0] > 0 && !tx->gl_texturenum ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOTE: imagelib detect miptex version by size
|
|
|
|
// NOTE: imagelib detect miptex version by size
|
|
|
|
// 770 additional bytes is indicated custom palette
|
|
|
|
// 770 additional bytes is indicated custom palette
|
|
|
|
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); |
|
|
|
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); |
|
|
|
|
|
|
|
|
|
|
|
if( custom_palette ) size += sizeof( short ) + 768; |
|
|
|
if( custom_palette ) size += sizeof( short ) + 768; |
|
|
|
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA ); |
|
|
|
Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name ); |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
|
|
|
|
// if texture is completely missed
|
|
|
|
|
|
|
|
if( !tx->gl_texturenum ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
size_t srcSize = 0; |
|
|
|
if( host.type != HOST_DEDICATED ) |
|
|
|
byte *src = NULL; |
|
|
|
Con_DPrintf( S_ERROR "unable to find %s.mip\n", mt->name ); |
|
|
|
|
|
|
|
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: we can't loading it from wad as normal because _luma texture doesn't exist
|
|
|
|
// check for luma texture
|
|
|
|
// and not be loaded. But original texture is already loaded and can't be modified
|
|
|
|
if( FBitSet( REF_GET_PARM( PARM_TEX_FLAGS, tx->gl_texturenum ), TF_HAS_LUMA )) |
|
|
|
// So load original texture manually and convert it to luma
|
|
|
|
{ |
|
|
|
|
|
|
|
Q_snprintf( texname, sizeof( texname ), "#%s:%s_luma.mip", loadstat.name, mt->name ); |
|
|
|
|
|
|
|
|
|
|
|
// check wads in reverse order
|
|
|
|
if( mt->offsets[0] > 0 ) |
|
|
|
for( j = bmod->wadlist.count - 1; j >= 0; j-- ) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
char *texpath = va( "%s.wad/%s.mip", bmod->wadlist.wadnames[j], tx->name ); |
|
|
|
// NOTE: imagelib detect miptex version by size
|
|
|
|
|
|
|
|
// 770 additional bytes is indicated custom palette
|
|
|
|
|
|
|
|
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6); |
|
|
|
|
|
|
|
|
|
|
|
if( FS_FileExists( texpath, false )) |
|
|
|
if( custom_palette ) size += sizeof( short ) + 768; |
|
|
|
|
|
|
|
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
size_t srcSize = 0; |
|
|
|
|
|
|
|
byte *src = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: we can't loading it from wad as normal because _luma texture doesn't exist
|
|
|
|
|
|
|
|
// and not be loaded. But original texture is already loaded and can't be modified
|
|
|
|
|
|
|
|
// So load original texture manually and convert it to luma
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check wads in reverse order
|
|
|
|
|
|
|
|
for( j = bmod->wadlist.count - 1; j >= 0; j-- ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
src = FS_LoadFile( texpath, &srcSize, false ); |
|
|
|
char *texpath = va( "%s.wad/%s.mip", bmod->wadlist.wadnames[j], tx->name ); |
|
|
|
bmod->wadlist.wadusage[j]++; // this wad are really used
|
|
|
|
|
|
|
|
break; |
|
|
|
if( FS_FileExists( texpath, false )) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
src = FS_LoadFile( texpath, &srcSize, false ); |
|
|
|
|
|
|
|
bmod->wadlist.wadusage[j]++; // this wad are really used
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// okay, loading it from wad or hi-res version
|
|
|
|
// okay, loading it from wad or hi-res version
|
|
|
|
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA ); |
|
|
|
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA ); |
|
|
|
if( src ) Mem_Free( src ); |
|
|
|
if( src ) Mem_Free( src ); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -2242,7 +2251,7 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef XASH_DEDICATED // TODO: Do we need subdivide on server?
|
|
|
|
#ifndef XASH_DEDICATED // TODO: Do we need subdivide on server?
|
|
|
|
if( FBitSet( out->flags, SURF_DRAWTURB )) |
|
|
|
if( FBitSet( out->flags, SURF_DRAWTURB ) && !Host_IsDedicated() ) |
|
|
|
ref.dllFuncs.GL_SubdivideSurface( out ); // cut up polygon for warps
|
|
|
|
ref.dllFuncs.GL_SubdivideSurface( out ); // cut up polygon for warps
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|