Reworked mp_forcerespawn (related #106)

This commit is contained in:
s1lent 2017-05-04 22:39:34 +07:00
parent 3a1e08abd4
commit 6d613fc9f0

View File

@ -3634,7 +3634,7 @@ void CBasePlayer::PlayerDeathThink()
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
// do not make a corpse if the player goes to respawn. // do not make a corpse if the player goes to respawn.
if (pev->deadflag != DEAD_RESPAWNABLE && forcerespawn.value <= 0) if (pev->deadflag != DEAD_RESPAWNABLE)
#endif #endif
{ {
// if the player has been dead for one second longer than allowed by forcerespawn, // if the player has been dead for one second longer than allowed by forcerespawn,
@ -3652,22 +3652,17 @@ void CBasePlayer::PlayerDeathThink()
// wait for all buttons released // wait for all buttons released
if (pev->deadflag == DEAD_DEAD && m_iTeam != UNASSIGNED && m_iTeam != SPECTATOR) if (pev->deadflag == DEAD_DEAD && m_iTeam != UNASSIGNED && m_iTeam != SPECTATOR)
{ {
#ifdef REGAMEDLL_ADD
// wait for any button down, or mp_forcerespawn is set and the respawn time is up
if (forcerespawn.value > 0 && gpGlobals->time > (m_fDeadTime + forcerespawn.value))
{
respawn(pev, FALSE);
pev->button = 0;
pev->nextthink = -1;
return;
}
#endif
if (fAnyButtonDown) if (fAnyButtonDown)
return; return;
if (g_pGameRules->FPlayerCanRespawn(this)) if (g_pGameRules->FPlayerCanRespawn(this))
{ {
#ifdef REGAMEDLL_ADD
if (forcerespawn.value <= 0 || (m_iTeam != CT && m_iTeam != TERRORIST))
#endif
{
pev->deadflag = DEAD_RESPAWNABLE; pev->deadflag = DEAD_RESPAWNABLE;
}
if (CSGameRules()->IsMultiplayer()) if (CSGameRules()->IsMultiplayer())
CSGameRules()->CheckWinConditions(); CSGameRules()->CheckWinConditions();
@ -3677,13 +3672,27 @@ void CBasePlayer::PlayerDeathThink()
return; return;
} }
#ifdef REGAMEDLL_ADD
if (forcerespawn.value <= 0)
#endif
{
if (pev->deadflag == DEAD_RESPAWNABLE) if (pev->deadflag == DEAD_RESPAWNABLE)
{ {
#ifdef REGAMEDLL_FIXES
if (IsObserver() && (m_afPhysicsFlags & PFLAG_OBSERVER) && (m_iTeam == UNASSIGNED || m_iTeam == SPECTATOR))
return;
// Player cannot respawn while in the Choose Appearance menu
if (m_iMenu == Menu_ChooseAppearance || m_iJoiningState == SHOWTEAMSELECT)
return;
#endif
// don't copy a corpse if we're in deathcam. // don't copy a corpse if we're in deathcam.
respawn(pev, FALSE); respawn(pev, FALSE);
pev->button = 0; pev->button = 0;
pev->nextthink = -1; pev->nextthink = -1;
} }
}
} }
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RoundRespawn) LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RoundRespawn)
@ -9732,15 +9741,12 @@ void CBasePlayer::PlayerRespawnThink()
if (pev->deadflag < DEAD_DYING) if (pev->deadflag < DEAD_DYING)
return; return;
if (forcerespawn.value) if (forcerespawn.value && gpGlobals->time > (CSPlayer()->m_flRespawnPending + forcerespawn.value))
{
if (gpGlobals->time > (CSPlayer()->m_flRespawnPending + forcerespawn.value))
{ {
Spawn(); Spawn();
pev->button = 0; pev->button = 0;
pev->nextthink = -1; pev->nextthink = -1;
return; return;
} }
}
#endif #endif
} }