engine: client: allow CL_GetLocalPlayer to return NULL rather than halting whole server
This commit is contained in:
parent
a834f4996f
commit
ce06b1d3d7
2 changed files with 6 additions and 4 deletions
|
@ -124,7 +124,7 @@ void SCR_DrawPos( void )
|
||||||
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ent = CL_EDICT_NUM( cl.playernum + 1 );
|
ent = CL_GetLocalPlayer();
|
||||||
speed = VectorLength( cl.simvel );
|
speed = VectorLength( cl.simvel );
|
||||||
|
|
||||||
Q_snprintf( msg, MAX_SYSPATH,
|
Q_snprintf( msg, MAX_SYSPATH,
|
||||||
|
|
|
@ -881,10 +881,12 @@ static inline qboolean CL_IsThirdPerson( void )
|
||||||
|
|
||||||
static inline cl_entity_t *CL_GetLocalPlayer( void )
|
static inline cl_entity_t *CL_GetLocalPlayer( void )
|
||||||
{
|
{
|
||||||
cl_entity_t *player;
|
cl_entity_t *player = CL_GetEntityByIndex( cl.playernum + 1 );
|
||||||
|
|
||||||
player = CL_EDICT_NUM( cl.playernum + 1 );
|
// HACKHACK: GoldSrc doesn't do this, but some mods actually check it for null pointer
|
||||||
Assert( player != NULL );
|
// this is a lesser evil than changing semantics of HUD_VidInit and call it after entities are allocated
|
||||||
|
if( !player )
|
||||||
|
Con_Printf( S_WARN "%s: client entities are not initialized yet! Returning NULL...\n", __func__ );
|
||||||
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue