Skip to content

Commit

Permalink
Implement CBasePlayer::HasTimePassedSinceDeath() for m_fDeadTime (#…
Browse files Browse the repository at this point in the history
…648)

* Implement CBasePlayer::HasTimePassedSinceDied() for m_fDeadTime
  • Loading branch information
SergeyShorokhov authored Jun 21, 2021
1 parent 59c297d commit 1ac96b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ void CBasePlayer::Observer_CheckTarget()
else if (target->pev->effects & EF_NODRAW)
{
#ifdef REGAMEDLL_FIXES
bool bStillDying = (target->pev->deadflag == DEAD_DYING || (target->pev->deadflag == DEAD_DEAD && (gpGlobals->time <= target->m_fDeadTime + 2.0f)));
bool bStillDying = (target->pev->deadflag == DEAD_DYING || (target->pev->deadflag == DEAD_DEAD && !target->HasTimePassedSinceDeath(2.0f)));
if (!bStillDying || (target->m_afPhysicsFlags & PFLAG_OBSERVER)) // keep observing to victim until dying, even if it is invisible
#endif
Observer_FindNextPlayer(false);
}
else if (target->pev->deadflag == DEAD_DEAD && gpGlobals->time > target->m_fDeadTime + 2.0f)
else if (target->pev->deadflag == DEAD_DEAD && target->HasTimePassedSinceDeath(2.0f))
{
// 2 secs after death change target
Observer_FindNextPlayer(false);
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3762,7 +3762,7 @@ void CBasePlayer::PlayerDeathThink()
{
// if the player has been dead for one second longer than allowed by forcerespawn,
// forcerespawn isn't on. Send the player off to an intermission camera until they choose to respawn.
if (g_pGameRules->IsMultiplayer() && gpGlobals->time > m_fDeadTime + 3 && !(m_afPhysicsFlags & PFLAG_OBSERVER))
if (g_pGameRules->IsMultiplayer() && HasTimePassedSinceDeath(3.0f) && !(m_afPhysicsFlags & PFLAG_OBSERVER))
{
// Send message to everybody to spawn a corpse.
SpawnClientSideCorpse();
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ class CBasePlayer: public CBaseMonster {
bool IsHittingShield(Vector &vecDirection, TraceResult *ptr);
bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
bool IsReloading() const;
bool HasTimePassedSinceDeath(float duration) const;
bool IsBlind() const { return (m_blindUntilTime > gpGlobals->time); }
bool IsAutoFollowAllowed() const { return (gpGlobals->time > m_allowAutoFollowTime); }
void InhibitAutoFollow(float duration) { m_allowAutoFollowTime = gpGlobals->time + duration; }
Expand Down Expand Up @@ -928,6 +929,11 @@ inline bool CBasePlayer::IsReloading() const
return false;
}

inline bool CBasePlayer::HasTimePassedSinceDeath(float duration) const
{
return gpGlobals->time > (m_fDeadTime + duration);
}

#ifdef REGAMEDLL_API
inline CCSPlayer *CBasePlayer::CSPlayer() const {
return reinterpret_cast<CCSPlayer *>(this->m_pEntity);
Expand Down

0 comments on commit 1ac96b8

Please sign in to comment.