Don't respawn if m_flRespawnPending isn't set

Minor refactoring
This commit is contained in:
s1lent 2019-09-23 04:31:23 +07:00
parent e199b16463
commit 0b517e036f
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
3 changed files with 32 additions and 8 deletions

View File

@ -533,3 +533,23 @@ void CCSPlayer::Reset()
m_iWeaponInfiniteAmmo = 0; m_iWeaponInfiniteAmmo = 0;
m_iWeaponInfiniteIds = 0; m_iWeaponInfiniteIds = 0;
} }
void CCSPlayer::OnSpawn()
{
m_flRespawnPending = 0.0f;
}
void CCSPlayer::OnKilled()
{
#ifdef REGAMEDLL_ADD
if (forcerespawn.value > 0)
{
m_flRespawnPending = gpGlobals->time + forcerespawn.value;
}
if (GetProtectionState() == ProtectionSt_Active)
{
BasePlayer()->RemoveSpawnProtection();
}
#endif
}

View File

@ -2168,13 +2168,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
BuyZoneIcon_Clear(this); BuyZoneIcon_Clear(this);
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
if (forcerespawn.value > 0) { CSPlayer()->OnKilled();
CSPlayer()->m_flRespawnPending = gpGlobals->time + forcerespawn.value;
}
if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active) {
RemoveSpawnProtection();
}
#endif #endif
SetThink(&CBasePlayer::PlayerDeathThink); SetThink(&CBasePlayer::PlayerDeathThink);
@ -5294,6 +5288,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Spawn)()
m_idrowndmg = 0; m_idrowndmg = 0;
m_idrownrestored = 0; m_idrownrestored = 0;
#ifdef REGAMEDLL_ADD
CSPlayer()->OnSpawn();
#endif
if (m_iObserverC4State) if (m_iObserverC4State)
{ {
m_iObserverC4State = 0; m_iObserverC4State = 0;
@ -9800,7 +9798,9 @@ void CBasePlayer::PlayerRespawnThink()
if (pev->deadflag < DEAD_DYING) if (pev->deadflag < DEAD_DYING)
return; return;
if (forcerespawn.value > 0 && gpGlobals->time > CSPlayer()->m_flRespawnPending) if (forcerespawn.value > 0 &&
CSPlayer()->m_flRespawnPending > 0 &&
CSPlayer()->m_flRespawnPending <= gpGlobals->time)
{ {
Spawn(); Spawn();
pev->button = 0; pev->button = 0;

View File

@ -96,6 +96,10 @@ public:
virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false);
void Reset(); void Reset();
void OnSpawn();
void OnKilled();
CBasePlayer *BasePlayer() const; CBasePlayer *BasePlayer() const;
public: public: