diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 139be701..ea6017a9 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -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, diff --git a/engine/client/client.h b/engine/client/client.h index 476a8828..6b33578c 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -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; }