Skip to content

Commit

Permalink
engine: server: check for invoker entity when filtering out host clie…
Browse files Browse the repository at this point in the history
…nt during entities thinking
  • Loading branch information
a1batross committed May 22, 2024
1 parent bcca938 commit 51945f0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion engine/server/sv_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -4182,7 +4182,16 @@ void GAME_EXPORT SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word
continue;
}

if( FBitSet( flags, FEV_NOTHOST ) && cl == sv.current_client && FBitSet( cl->flags, FCL_LOCAL_WEAPONS ))
// a1ba: GoldSrc never cleans up host_client pointer (similar to sv.current_client)
// so it's always points at some client and in singleplayer this check always succeedes
// in Xash, however, sv.current_client might be reset and set to NULL
// this is especially dangerous when weapons play events in Think functions
//
// IMHO, it doesn't make sense to me to compare it against current client when we have
// invoker edict pointer but to preserve behaviour check for them both
//
// if it breaks some mods, probably sv.current_client semantics must be reworked to match GoldSrc
if( FBitSet( flags, FEV_NOTHOST ) && ( cl == sv.current_client || cl->edict == pInvoker ) && FBitSet( cl->flags, FCL_LOCAL_WEAPONS ))
continue; // will be played on client side

if( FBitSet( flags, FEV_HOSTONLY ) && cl->edict != pInvoker )
Expand Down

0 comments on commit 51945f0

Please sign in to comment.