Remove respawn dependency on forcerespawn cvar (#537)

* Remove respawn dependency on forcerespawn cvar
Able to set custom respawn time for m_flRespawnPending without mp_forcerespawn enabled
* workaround when disabling forcerespawn must stop works immediately
* just block respawn then cvar disabled without reset for correct cvar logic
This commit is contained in:
fl0werD 2020-05-27 05:20:59 +04:00 committed by GitHub
parent c6875e5b12
commit a20362389e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -538,10 +538,12 @@ void CCSPlayer::Reset()
m_iWeaponInfiniteAmmo = 0;
m_iWeaponInfiniteIds = 0;
m_bCanShootOverride = false;
m_bGameForcingRespawn = false;
}
void CCSPlayer::OnSpawn()
{
m_bGameForcingRespawn = false;
m_flRespawnPending = 0.0f;
}
@ -550,6 +552,7 @@ void CCSPlayer::OnKilled()
#ifdef REGAMEDLL_ADD
if (forcerespawn.value > 0)
{
m_bGameForcingRespawn = true;
m_flRespawnPending = gpGlobals->time + forcerespawn.value;
}

View File

@ -9935,10 +9935,13 @@ void CBasePlayer::PlayerRespawnThink()
if (pev->deadflag < DEAD_DYING)
return;
if (forcerespawn.value > 0 &&
CSPlayer()->m_flRespawnPending > 0 &&
if (CSPlayer()->m_flRespawnPending > 0 &&
CSPlayer()->m_flRespawnPending <= gpGlobals->time)
{
// Pending respawn caused by game doesn't respawn with disabled CVar
if (CSPlayer()->m_bGameForcingRespawn && !forcerespawn.value)
return;
Spawn();
pev->button = 0;
pev->nextthink = -1;

View File

@ -45,7 +45,8 @@ public:
m_flSpawnProtectionEndTime(0),
m_iWeaponInfiniteAmmo(0),
m_iWeaponInfiniteIds(0),
m_bCanShootOverride(false)
m_bCanShootOverride(false),
m_bGameForcingRespawn(false)
{
m_szModel[0] = '\0';
}
@ -123,6 +124,7 @@ public:
int m_iWeaponInfiniteAmmo;
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
bool m_bGameForcingRespawn;
};
// Inlines