Browse Source

engine: server: do not assert if SetFatPVS/PAS were called without active player

Fixes issues with POD-Bot based bots.
pull/2/head
Alibek Omarov 1 year ago
parent
commit
4c02c25506
  1. 12
      engine/server/sv_game.c

12
engine/server/sv_game.c

@ -4207,8 +4207,7 @@ byte *pfnSetFatPVS( const float *org )
if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY )) if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
{ {
vec3_t viewPos, offset; vec3_t viewPos, offset;
qboolean client_active = pfnGetCurrentPlayer() != -1;
ASSERT( pfnGetCurrentPlayer() != -1 );
// see code from client.cpp for understanding: // see code from client.cpp for understanding:
// org = pView->v.origin + pView->v.view_ofs; // org = pView->v.origin + pView->v.view_ofs;
@ -4218,7 +4217,7 @@ byte *pfnSetFatPVS( const float *org )
// } // }
// so we have unneeded duck calculations who have affect when player // so we have unneeded duck calculations who have affect when player
// is ducked into water. Remove offset to restore right PVS position // is ducked into water. Remove offset to restore right PVS position
if( FBitSet( sv.current_client->edict->v.flags, FL_DUCKING )) if( client_active && FBitSet( sv.current_client->edict->v.flags, FL_DUCKING ))
{ {
VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset ); VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset );
VectorSubtract( org, offset, viewPos ); VectorSubtract( org, offset, viewPos );
@ -4227,6 +4226,8 @@ byte *pfnSetFatPVS( const float *org )
// build a new PVS frame // build a new PVS frame
Mod_FatPVS( viewPos, FATPVS_RADIUS, fatpvs, world.fatbytes, false, fullvis ); Mod_FatPVS( viewPos, FATPVS_RADIUS, fatpvs, world.fatbytes, false, fullvis );
if( client_active )
VectorCopy( viewPos, viewPoint[pfnGetCurrentPlayer()] ); VectorCopy( viewPos, viewPoint[pfnGetCurrentPlayer()] );
} }
else else
@ -4257,8 +4258,7 @@ byte *pfnSetFatPAS( const float *org )
if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY )) if( !FBitSet( sv.hostflags, SVF_MERGE_VISIBILITY ))
{ {
vec3_t viewPos, offset; vec3_t viewPos, offset;
qboolean client_active = pfnGetCurrentPlayer() != -1;
ASSERT( pfnGetCurrentPlayer() != -1 );
// see code from client.cpp for understanding: // see code from client.cpp for understanding:
// org = pView->v.origin + pView->v.view_ofs; // org = pView->v.origin + pView->v.view_ofs;
@ -4268,7 +4268,7 @@ byte *pfnSetFatPAS( const float *org )
// } // }
// so we have unneeded duck calculations who have affect when player // so we have unneeded duck calculations who have affect when player
// is ducked into water. Remove offset to restore right PVS position // is ducked into water. Remove offset to restore right PVS position
if( FBitSet( sv.current_client->edict->v.flags, FL_DUCKING )) if( client_active && FBitSet( sv.current_client->edict->v.flags, FL_DUCKING ))
{ {
VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset ); VectorSubtract( svgame.pmove->player_mins[0], svgame.pmove->player_mins[1], offset );
VectorSubtract( org, offset, viewPos ); VectorSubtract( org, offset, viewPos );

Loading…
Cancel
Save