Skip to content

Commit

Permalink
engine: client: allow CL_GetLocalPlayer to return NULL rather than ha…
Browse files Browse the repository at this point in the history
…lting whole server
  • Loading branch information
a1batross committed Dec 20, 2024
1 parent a834f49 commit ce06b1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion engine/client/cl_scrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ce06b1d

Please sign in to comment.