engine: server: slight refactoring, hide client calls under XASH_DEDICATED, remove useless dedicated stub

This commit is contained in:
Alibek Omarov 2024-10-03 19:33:51 +03:00
parent 5d79d93aac
commit e11635d15c
3 changed files with 28 additions and 33 deletions

View file

@ -134,11 +134,6 @@ void GAME_EXPORT S_StopSound(int entnum, int channel, const char *soundname)
} }
int S_GetCurrentStaticSounds( soundlist_t *pout, int size )
{
return 0;
}
int GAME_EXPORT CL_GetMaxClients( void ) int GAME_EXPORT CL_GetMaxClients( void )
{ {
return 0; return 0;

View file

@ -643,12 +643,16 @@ Write ambient sounds into demo
*/ */
void SV_RestartAmbientSounds( void ) void SV_RestartAmbientSounds( void )
{ {
// TODO: we don't know sounds state on remote server
// as it's used only for demos, maybe this could be implemented on client side?
#if !XASH_DEDICATED
soundlist_t soundInfo[256]; soundlist_t soundInfo[256];
string curtrack, looptrack; string curtrack, looptrack;
int i, nSounds; int i, nSounds;
int position; int position;
if( !SV_Active( )) return; if( !SV_Active( ) || Host_IsDedicated( ))
return;
nSounds = S_GetCurrentStaticSounds( soundInfo, 256 ); nSounds = S_GetCurrentStaticSounds( soundInfo, 256 );
@ -663,7 +667,6 @@ void SV_RestartAmbientSounds( void )
SV_StartSound( SV_PEntityOfEntIndex( si->entnum, true ), CHAN_STATIC, si->name, si->volume, si->attenuation, 0, si->pitch ); SV_StartSound( SV_PEntityOfEntIndex( si->entnum, true ), CHAN_STATIC, si->name, si->volume, si->attenuation, 0, si->pitch );
} }
#if !XASH_DEDICATED // TODO: ???
// restart soundtrack // restart soundtrack
if( S_StreamGetCurrentState( curtrack, sizeof( curtrack ), looptrack, sizeof( looptrack ), &position )) if( S_StreamGetCurrentState( curtrack, sizeof( curtrack ), looptrack, sizeof( looptrack ), &position ))
{ {

View file

@ -1170,41 +1170,36 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
char name[MAX_QPATH]; char name[MAX_QPATH];
int i, id, version; int i, id, version;
char *pTokenData; char *pTokenData;
decallist_t *decalList; decallist_t *decalList = NULL;
SAVE_CLIENT header; SAVE_CLIENT header = { 0 };
file_t *pFile; file_t *pFile;
// clearing the saving buffer to reuse // clearing the saving buffer to reuse
SaveClear( pSaveData ); SaveClear( pSaveData );
memset( &header, 0, sizeof( header )); header.entityCount = sv.num_static_entities;
// g-cont. add space for studiodecals if present
decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
// initialize client header // initialize client header
#if !XASH_DEDICATED #if !XASH_DEDICATED
if( !Host_IsDedicated() ) if( !Host_IsDedicated( ))
{ {
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList ); // g-cont. add space for studiodecals if present
} decalList = (decallist_t *)Mem_Calloc( host.mempool, sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
else
#endif // XASH_DEDICATED
{
// we probably running a dedicated server
header.decalCount = 0;
}
header.entityCount = sv.num_static_entities;
if( !changelevel ) header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
if( !changelevel ) // sounds won't going across transition
{ {
// sounds won't going across transition
header.soundCount = S_GetCurrentDynamicSounds( soundInfo, MAX_CHANNELS ); header.soundCount = S_GetCurrentDynamicSounds( soundInfo, MAX_CHANNELS );
#if !XASH_DEDICATED
// music not reqiured to save position: it's just continue playing on a next level // music not reqiured to save position: it's just continue playing on a next level
S_StreamGetCurrentState( header.introTrack, sizeof( header.introTrack ), header.mainTrack, sizeof( header.mainTrack ), &header.trackPosition ); S_StreamGetCurrentState(
#endif header.introTrack, sizeof( header.introTrack ),
header.mainTrack, sizeof( header.mainTrack ),
&header.trackPosition );
} }
}
#endif // XASH_DEDICATED
// save viewentity to allow camera works after save\restore // save viewentity to allow camera works after save\restore
if( SV_IsValidEdict( cl->pViewEntity ) && cl->pViewEntity != cl->edict ) if( SV_IsValidEdict( cl->pViewEntity ) && cl->pViewEntity != cl->edict )
@ -1217,7 +1212,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "ClientHeader", &header, gSaveClient, ARRAYSIZE( gSaveClient )); svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "ClientHeader", &header, gSaveClient, ARRAYSIZE( gSaveClient ));
// store decals // store decals
for( i = 0; i < header.decalCount; i++ ) for( i = 0; decalList != NULL && i < header.decalCount; i++ )
{ {
// NOTE: apply landmark offset only for brush entities without origin brushes // NOTE: apply landmark offset only for brush entities without origin brushes
if( pSaveData->fUseLandmark && FBitSet( decalList[i].flags, FDECAL_USE_LANDMARK )) if( pSaveData->fUseLandmark && FBitSet( decalList[i].flags, FDECAL_USE_LANDMARK ))
@ -1225,7 +1220,9 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "DECALLIST", &decalList[i], gDecalEntry, ARRAYSIZE( gDecalEntry )); svgame.dllFuncs.pfnSaveWriteFields( pSaveData, "DECALLIST", &decalList[i], gDecalEntry, ARRAYSIZE( gDecalEntry ));
} }
Z_Free( decalList );
if( decalList )
Mem_Free( decalList );
// write client entities // write client entities
for( i = 0; i < header.entityCount; i++ ) for( i = 0; i < header.entityCount; i++ )