engine: server: merge SV_FindBestBaseline for normal entities and static entities into single function
This commit is contained in:
parent
98e587285b
commit
93c5853356
3 changed files with 16 additions and 41 deletions
|
@ -593,7 +593,7 @@ qboolean SV_CheckID( const char *id );
|
|||
// sv_frame.c
|
||||
//
|
||||
void SV_InactivateClients( void );
|
||||
int SV_FindBestBaselineForStatic( int index, entity_state_t **baseline, entity_state_t *to );
|
||||
int SV_FindBestBaseline( int index, entity_state_t **baseline, entity_state_t *to, client_frame_t *frame, qboolean player );
|
||||
void SV_SkipUpdates( void );
|
||||
|
||||
//
|
||||
|
|
|
@ -178,9 +178,10 @@ Encode a client frame onto the network channel
|
|||
SV_FindBestBaseline
|
||||
|
||||
trying to deltas with previous entities
|
||||
set frame to NULL to check for static entities
|
||||
=============
|
||||
*/
|
||||
static int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **baseline, entity_state_t *to, client_frame_t *frame, qboolean player )
|
||||
int SV_FindBestBaseline( int index, entity_state_t **baseline, entity_state_t *to, client_frame_t *frame, qboolean player )
|
||||
{
|
||||
int bestBitCount;
|
||||
int i, bitCount;
|
||||
|
@ -193,7 +194,13 @@ static int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **bas
|
|||
for( i = index - 1; bestBitCount > 0 && i >= 0 && ( index - i ) < ( MAX_CUSTOM_BASELINES - 1 ); i-- )
|
||||
{
|
||||
// don't worry about underflow in circular buffer
|
||||
entity_state_t *test = &svs.packet_entities[(frame->first_entity+i) % svs.num_client_entities];
|
||||
entity_state_t *test;
|
||||
|
||||
// if set, then it's normal entity
|
||||
if( frame != NULL )
|
||||
test = &svs.packet_entities[(frame->first_entity+i) % svs.num_client_entities];
|
||||
else
|
||||
test = &svs.static_entities[i];
|
||||
|
||||
if( to->entityType == test->entityType )
|
||||
{
|
||||
|
@ -209,44 +216,12 @@ static int SV_FindBestBaseline( sv_client_t *cl, int index, entity_state_t **bas
|
|||
|
||||
// using delta from previous entity as baseline for current
|
||||
if( index != bestfound )
|
||||
*baseline = &svs.packet_entities[(frame->first_entity+bestfound) % svs.num_client_entities];
|
||||
return index - bestfound;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
SV_FindBestBaselineForStatic
|
||||
|
||||
trying to deltas with previous static entities
|
||||
=============
|
||||
*/
|
||||
int SV_FindBestBaselineForStatic( int index, entity_state_t **baseline, entity_state_t *to )
|
||||
{
|
||||
int bestBitCount;
|
||||
int i, bitCount;
|
||||
int bestfound, j;
|
||||
|
||||
bestBitCount = j = Delta_TestBaseline( *baseline, to, false, sv.time );
|
||||
bestfound = index;
|
||||
|
||||
// lookup backward for previous 64 states and try to interpret current delta as baseline
|
||||
for( i = index - 1; bestBitCount > 0 && i >= 0 && ( index - i ) < ( MAX_CUSTOM_BASELINES - 1 ); i-- )
|
||||
{
|
||||
// don't worry about underflow in circular buffer
|
||||
entity_state_t *test = &svs.static_entities[i];
|
||||
|
||||
bitCount = Delta_TestBaseline( test, to, false, sv.time );
|
||||
|
||||
if( bitCount < bestBitCount )
|
||||
{
|
||||
bestBitCount = bitCount;
|
||||
bestfound = i;
|
||||
}
|
||||
if( frame != NULL )
|
||||
*baseline = &svs.packet_entities[(frame->first_entity+bestfound) % svs.num_client_entities];
|
||||
else
|
||||
*baseline = &svs.static_entities[bestfound];
|
||||
}
|
||||
|
||||
// using delta from previous entity as baseline for current
|
||||
if( index != bestfound )
|
||||
*baseline = &svs.static_entities[bestfound];
|
||||
return index - bestfound;
|
||||
}
|
||||
|
||||
|
@ -347,7 +322,7 @@ static void SV_EmitPacketEntities( sv_client_t *cl, client_frame_t *to, sizebuf_
|
|||
// trying to reduce message by select optimal baseline
|
||||
if( !sv_instancedbaseline.value || !sv.num_instanced || sv.last_valid_baseline > newnum )
|
||||
{
|
||||
offset = SV_FindBestBaseline( cl, newindex, &baseline, newent, to, player );
|
||||
offset = SV_FindBestBaseline( newindex, &baseline, newent, to, player );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -578,7 +578,7 @@ qboolean SV_CreateStaticEntity( sizebuf_t *msg, int index )
|
|||
state->number = 0;
|
||||
|
||||
// trying to compress with previous delta's
|
||||
offset = SV_FindBestBaselineForStatic( index, &baseline, state );
|
||||
offset = SV_FindBestBaseline( index, &baseline, state, NULL, false );
|
||||
|
||||
MSG_BeginServerCmd( msg, svc_spawnstatic );
|
||||
MSG_WriteDeltaEntity( baseline, state, msg, true, DELTA_STATIC, sv.time, offset );
|
||||
|
|
Loading…
Add table
Reference in a new issue