Merge pull request #1778 from d3fault/instant-respawn

respawn is now instant, but rate limited to 3 sec unless player clicks mouse1
This commit is contained in:
Dennis Felsing 2019-06-11 18:04:52 +02:00 committed by GitHub
commit 617d123024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -901,7 +901,8 @@ void CCharacter::Die(int Killer, int Weapon)
// a nice sound
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
// this is for auto respawn after 3 secs
// this is to rate limit respawning to 3 secs
m_pPlayer->m_PreviousDieTick = m_pPlayer->m_DieTick;
m_pPlayer->m_DieTick = Server()->Tick();
m_Alive = false;

View file

@ -12,6 +12,7 @@
#include "gamemodes/DDRace.h"
#include <time.h>
#include <algorithm>
MACRO_ALLOC_POOL_ID_IMPL(CPlayer, MAX_CLIENTS)
@ -37,6 +38,7 @@ CPlayer::~CPlayer()
void CPlayer::Reset()
{
m_DieTick = Server()->Tick();
m_PreviousDieTick = m_DieTick;
m_JoinTick = Server()->Tick();
delete m_pCharacter;
m_pCharacter = 0;
@ -196,7 +198,9 @@ void CPlayer::Tick()
if(!GameServer()->m_World.m_Paused)
{
if(!m_pCharacter && m_DieTick+Server()->TickSpeed()*3 <= Server()->Tick())
int EarliestRespawnTick = m_PreviousDieTick+Server()->TickSpeed()*3;
int RespawnTick = std::max(m_DieTick, EarliestRespawnTick);
if(!m_pCharacter && RespawnTick <= Server()->Tick())
m_Spawning = true;
if(m_pCharacter)
@ -219,6 +223,7 @@ void CPlayer::Tick()
else
{
++m_DieTick;
++m_PreviousDieTick;
++m_JoinTick;
++m_LastActionTick;
++m_TeamChangeTick;

View file

@ -92,6 +92,7 @@ public:
} m_TeeInfos;
int m_DieTick;
int m_PreviousDieTick;
int m_Score;
int m_JoinTick;
bool m_ForceBalanced;