mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
engine: make dedicated work again
This commit is contained in:
parent
92b89936b3
commit
743c5ca8d5
@ -15,6 +15,9 @@ GNU General Public License for more details.
|
||||
#ifdef XASH_DEDICATED
|
||||
#include "common.h"
|
||||
#include "mathlib.h"
|
||||
#include "ref_api.h"
|
||||
|
||||
ref_globals_t refState;
|
||||
|
||||
const char *svc_strings[256] =
|
||||
{
|
||||
@ -319,189 +322,9 @@ void CL_StopPlayback( void )
|
||||
|
||||
}
|
||||
|
||||
#include "sprite.h"
|
||||
|
||||
/*
|
||||
====================
|
||||
Mod_LoadSpriteModel
|
||||
|
||||
load sprite model
|
||||
====================
|
||||
*/
|
||||
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags )
|
||||
void CL_ClearStaticEntities( void )
|
||||
{
|
||||
dsprite_q1_t *pinq1;
|
||||
dsprite_hl_t *pinhl;
|
||||
dsprite_t *pin;
|
||||
short *numi = NULL;
|
||||
dframetype_t *pframetype;
|
||||
msprite_t *psprite;
|
||||
int i, size;
|
||||
|
||||
if( loaded ) *loaded = false;
|
||||
pin = (dsprite_t *)buffer;
|
||||
mod->type = mod_sprite;
|
||||
i = pin->version;
|
||||
|
||||
if( pin->ident != IDSPRITEHEADER )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s has wrong id (%x should be %x)\n", mod->name, pin->ident, IDSPRITEHEADER );
|
||||
return;
|
||||
}
|
||||
|
||||
if( i != SPRITE_VERSION_Q1 && i != SPRITE_VERSION_HL && i != SPRITE_VERSION_32 )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s has wrong version number (%i should be %i or %i)\n", mod->name, i, SPRITE_VERSION_Q1, SPRITE_VERSION_HL );
|
||||
return;
|
||||
}
|
||||
|
||||
mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name ));
|
||||
|
||||
if( i == SPRITE_VERSION_Q1 || i == SPRITE_VERSION_32 )
|
||||
{
|
||||
pinq1 = (dsprite_q1_t *)buffer;
|
||||
size = sizeof( msprite_t ) + ( pinq1->numframes - 1 ) * sizeof( psprite->frames );
|
||||
psprite = Mem_Calloc( mod->mempool, size );
|
||||
mod->cache.data = psprite; // make link to extradata
|
||||
|
||||
psprite->type = pinq1->type;
|
||||
psprite->texFormat = SPR_ADDITIVE; //SPR_ALPHTEST;
|
||||
psprite->numframes = mod->numframes = pinq1->numframes;
|
||||
psprite->facecull = SPR_CULL_FRONT;
|
||||
psprite->radius = pinq1->boundingradius;
|
||||
psprite->synctype = pinq1->synctype;
|
||||
|
||||
mod->mins[0] = mod->mins[1] = -pinq1->bounds[0] * 0.5f;
|
||||
mod->maxs[0] = mod->maxs[1] = pinq1->bounds[0] * 0.5f;
|
||||
mod->mins[2] = -pinq1->bounds[1] * 0.5f;
|
||||
mod->maxs[2] = pinq1->bounds[1] * 0.5f;
|
||||
numi = NULL;
|
||||
}
|
||||
else if( i == SPRITE_VERSION_HL )
|
||||
{
|
||||
pinhl = (dsprite_hl_t *)buffer;
|
||||
size = sizeof( msprite_t ) + ( pinhl->numframes - 1 ) * sizeof( psprite->frames );
|
||||
psprite = Mem_Calloc( mod->mempool, size );
|
||||
mod->cache.data = psprite; // make link to extradata
|
||||
|
||||
psprite->type = pinhl->type;
|
||||
psprite->texFormat = pinhl->texFormat;
|
||||
psprite->numframes = mod->numframes = pinhl->numframes;
|
||||
psprite->facecull = pinhl->facetype;
|
||||
psprite->radius = pinhl->boundingradius;
|
||||
psprite->synctype = pinhl->synctype;
|
||||
|
||||
mod->mins[0] = mod->mins[1] = -pinhl->bounds[0] * 0.5f;
|
||||
mod->maxs[0] = mod->maxs[1] = pinhl->bounds[0] * 0.5f;
|
||||
mod->mins[2] = -pinhl->bounds[1] * 0.5f;
|
||||
mod->maxs[2] = pinhl->bounds[1] * 0.5f;
|
||||
numi = (short *)(pinhl + 1);
|
||||
}
|
||||
|
||||
if( Host_IsDedicated() )
|
||||
{
|
||||
// skip frames loading
|
||||
if( loaded ) *loaded = true; // done
|
||||
psprite->numframes = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( numi == NULL )
|
||||
{
|
||||
rgbdata_t *pal;
|
||||
|
||||
pal = FS_LoadImage( "#id.pal", (byte *)&i, 768 );
|
||||
pframetype = (dframetype_t *)(pinq1 + 1);
|
||||
FS_FreeImage( pal ); // palette installed, no reason to keep this data
|
||||
}
|
||||
else if( *numi == 256 )
|
||||
{
|
||||
byte *src = (byte *)(numi+1);
|
||||
rgbdata_t *pal;
|
||||
|
||||
// install palette
|
||||
switch( psprite->texFormat )
|
||||
{
|
||||
case SPR_INDEXALPHA:
|
||||
pal = FS_LoadImage( "#gradient.pal", src, 768 );
|
||||
break;
|
||||
case SPR_ALPHTEST:
|
||||
pal = FS_LoadImage( "#masked.pal", src, 768 );
|
||||
break;
|
||||
default:
|
||||
pal = FS_LoadImage( "#normal.pal", src, 768 );
|
||||
break;
|
||||
}
|
||||
|
||||
pframetype = (dframetype_t *)(src + 768);
|
||||
FS_FreeImage( pal ); // palette installed, no reason to keep this data
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s has wrong number of palette colors %i (should be 256)\n", mod->name, *numi );
|
||||
return;
|
||||
}
|
||||
|
||||
if( mod->numframes < 1 )
|
||||
{
|
||||
Con_Reportf( S_ERROR "%s has invalid # of frames: %d\n", mod->name, mod->numframes );
|
||||
return;
|
||||
}
|
||||
|
||||
if( loaded ) *loaded = true; // done
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
Mod_UnloadSpriteModel
|
||||
|
||||
release sprite model and frames
|
||||
====================
|
||||
*/
|
||||
void Mod_UnloadSpriteModel( model_t *mod )
|
||||
{
|
||||
msprite_t *psprite;
|
||||
mspritegroup_t *pspritegroup;
|
||||
mspriteframe_t *pspriteframe;
|
||||
int i, j;
|
||||
|
||||
Assert( mod != NULL );
|
||||
|
||||
#ifndef XASH_DEDICATED
|
||||
if( mod->type == mod_sprite )
|
||||
{
|
||||
if( host.type != HOST_DEDICATED )
|
||||
{
|
||||
psprite = mod->cache.data;
|
||||
|
||||
if( psprite )
|
||||
{
|
||||
// release all textures
|
||||
for( i = 0; i < psprite->numframes; i++ )
|
||||
{
|
||||
if( psprite->frames[i].type == SPR_SINGLE )
|
||||
{
|
||||
pspriteframe = psprite->frames[i].frameptr;
|
||||
GL_FreeTexture( pspriteframe->gl_texturenum );
|
||||
}
|
||||
else
|
||||
{
|
||||
pspritegroup = (mspritegroup_t *)psprite->frames[i].frameptr;
|
||||
|
||||
for( j = 0; j < pspritegroup->numframes; j++ )
|
||||
{
|
||||
pspriteframe = pspritegroup->frames[i];
|
||||
GL_FreeTexture( pspriteframe->gl_texturenum );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Mem_FreePool( &mod->mempool );
|
||||
memset( mod, 0, sizeof( *mod ));
|
||||
}
|
||||
|
||||
#endif // XASH_DEDICATED
|
||||
|
@ -2368,7 +2368,9 @@ void HTTP_Run( void )
|
||||
}
|
||||
|
||||
// update progress
|
||||
#ifndef XASH_DEDICATED
|
||||
Cvar_SetValue( "scr_download", flProgress/iProgressCount * 100 );
|
||||
#endif // XASH_DEDICATED
|
||||
|
||||
HTTP_AutoClean();
|
||||
}
|
||||
|
@ -618,6 +618,7 @@ void SV_RestartDecals( void )
|
||||
// g-cont. add space for studiodecals if present
|
||||
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
||||
|
||||
#ifndef XASH_DEDICATED
|
||||
if( ref.dllFuncs.R_CreateDecalList )
|
||||
{
|
||||
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
|
||||
@ -626,6 +627,7 @@ void SV_RestartDecals( void )
|
||||
ref.dllFuncs.R_ClearAllDecals();
|
||||
}
|
||||
else
|
||||
#endif // XASH_DEDICATED
|
||||
{
|
||||
// we probably running a dedicated server
|
||||
host.numdecals = 0;
|
||||
|
@ -2005,7 +2005,11 @@ const char* pfnGetModelName( int modelindex )
|
||||
|
||||
static const byte *GL_TextureData( unsigned int texnum )
|
||||
{
|
||||
return ref.dllFuncs.GL_TextureData( texnum );
|
||||
#ifndef XASH_DEDICATED
|
||||
return ref.dllFuncs.GL_TextureData ? ref.dllFuncs.GL_TextureData( texnum ) : NULL;
|
||||
#else // XASH_DEDICATED
|
||||
return NULL;
|
||||
#endif // XASH_DEDICATED
|
||||
}
|
||||
|
||||
static server_physics_api_t gPhysicsAPI =
|
||||
|
@ -1130,11 +1130,13 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
|
||||
decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
|
||||
|
||||
// initialize client header
|
||||
#ifndef XASH_DEDICATED
|
||||
if( ref.dllFuncs.R_CreateDecalList )
|
||||
{
|
||||
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
|
||||
}
|
||||
else
|
||||
#endif // XASH_DEDICATED
|
||||
{
|
||||
// we probably running a dedicated server
|
||||
header.decalCount = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user