mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: client: allow CL_GetLocalPlayer to return NULL rather than halting whole server
This commit is contained in:
@@ -124,7 +124,7 @@ void SCR_DrawPos( void )
|
||||
if( cls.state != ca_active || !cl_showpos.value || cl.background )
|
||||
return;
|
||||
|
||||
ent = CL_EDICT_NUM( cl.playernum + 1 );
|
||||
ent = CL_GetLocalPlayer();
|
||||
speed = VectorLength( cl.simvel );
|
||||
|
||||
Q_snprintf( msg, MAX_SYSPATH,
|
||||
|
||||
@@ -881,10 +881,12 @@ static inline qboolean CL_IsThirdPerson( 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 );
|
||||
Assert( player != NULL );
|
||||
// HACKHACK: GoldSrc doesn't do this, but some mods actually check it for null pointer
|
||||
// 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user