engine: hide ref calls under Host_IsDedicated checks, replace ref function ptr checks by \!Host_IsDedicated
This commit is contained in:
parent
5f849c4823
commit
62f04137a5
4 changed files with 89 additions and 80 deletions
|
@ -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
|
|
||||||
|
|
||||||
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) &&
|
|
||||||
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) )
|
|
||||||
SetBits( world.flags, FWORLD_SKYSPHERE );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// texture loading order:
|
|
||||||
// 1. from wad
|
|
||||||
// 2. internal from map
|
|
||||||
|
|
||||||
// trying wad texture (force while r_wadtextures is 1)
|
|
||||||
if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || ( mt->offsets[0] <= 0 ))
|
|
||||||
{
|
{
|
||||||
Q_snprintf( texname, sizeof( texname ), "%s.mip", mt->name );
|
// check for multi-layered sky texture (quake1 specific)
|
||||||
|
if( bmod->isworld && !Q_strncmp( mt->name, "sky", 3 ) && (( mt->width / mt->height ) == 2 ) )
|
||||||
// check wads in reverse order
|
|
||||||
for( j = bmod->wadlist.count - 1; j >= 0; j-- )
|
|
||||||
{
|
{
|
||||||
char *texpath = va( "%s.wad/%s", bmod->wadlist.wadnames[j], texname );
|
ref.dllFuncs.R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
|
||||||
|
|
||||||
if( FS_FileExists( texpath, false ))
|
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) &&
|
||||||
|
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) )
|
||||||
|
SetBits( world.flags, FWORLD_SKYSPHERE );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// texture loading order:
|
||||||
|
// 1. from wad
|
||||||
|
// 2. internal from map
|
||||||
|
|
||||||
|
// trying wad texture (force while r_wadtextures is 1)
|
||||||
|
if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || ( mt->offsets[0] <= 0 ))
|
||||||
|
{
|
||||||
|
Q_snprintf( texname, sizeof( texname ), "%s.mip", mt->name );
|
||||||
|
|
||||||
|
// 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)
|
// wad failed, so use internal texture (if present)
|
||||||
if( mt->offsets[0] > 0 && !tx->gl_texturenum )
|
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 )
|
|
||||||
{
|
{
|
||||||
// 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 );
|
||||||
src = FS_LoadFile( texpath, &srcSize, false );
|
|
||||||
bmod->wadlist.wadusage[j]++; // this wad are really used
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t srcSize = 0;
|
||||||
|
byte *src = NULL;
|
||||||
|
|
||||||
// okay, loading it from wad or hi-res version
|
// NOTE: we can't loading it from wad as normal because _luma texture doesn't exist
|
||||||
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
|
// and not be loaded. But original texture is already loaded and can't be modified
|
||||||
if( src ) Mem_Free( src );
|
// So load original texture manually and convert it to luma
|
||||||
|
|
||||||
|
// check wads in reverse order
|
||||||
|
for( j = bmod->wadlist.count - 1; j >= 0; j-- )
|
||||||
|
{
|
||||||
|
char *texpath = va( "%s.wad/%s.mip", bmod->wadlist.wadnames[j], tx->name );
|
||||||
|
|
||||||
|
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
|
||||||
|
tx->fb_texturenum = ref.dllFuncs.GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,7 +619,7 @@ void SV_RestartDecals( void )
|
||||||
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
||||||
|
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
if( ref.dllFuncs.R_CreateDecalList )
|
if( !Host_IsDedicated() )
|
||||||
{
|
{
|
||||||
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
|
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
|
||||||
|
|
||||||
|
|
|
@ -2006,7 +2006,7 @@ const char* pfnGetModelName( int modelindex )
|
||||||
static const byte *GL_TextureData( unsigned int texnum )
|
static const byte *GL_TextureData( unsigned int texnum )
|
||||||
{
|
{
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
return ref.dllFuncs.GL_TextureData ? ref.dllFuncs.GL_TextureData( texnum ) : NULL;
|
return Host_IsDedicated() ? NULL : ref.dllFuncs.GL_TextureData( texnum );
|
||||||
#else // XASH_DEDICATED
|
#else // XASH_DEDICATED
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // XASH_DEDICATED
|
#endif // XASH_DEDICATED
|
||||||
|
|
|
@ -1131,7 +1131,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
|
||||||
|
|
||||||
// initialize client header
|
// initialize client header
|
||||||
#ifndef XASH_DEDICATED
|
#ifndef XASH_DEDICATED
|
||||||
if( ref.dllFuncs.R_CreateDecalList )
|
if( !Host_IsDedicated() )
|
||||||
{
|
{
|
||||||
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
|
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue