Merge pull request #7392 from furo321/fix-demo-ending-early

Delay server race demo ending by 1 second.
This commit is contained in:
Dennis Felsing 2023-10-30 09:40:00 +00:00 committed by GitHub
commit 3235e3eac9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 3 deletions

View file

@ -918,7 +918,16 @@ bool CCharacter::IncreaseArmor(int Amount)
void CCharacter::Die(int Killer, int Weapon, bool SendKillMsg)
{
if(Server()->IsRecording(m_pPlayer->GetCID()))
Server()->StopRecord(m_pPlayer->GetCID());
{
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
if(pData->m_RecordStopTick - Server()->Tick() <= Server()->TickSpeed() && pData->m_RecordStopTick != -1)
Server()->SaveDemo(m_pPlayer->GetCID(), pData->m_RecordFinishTime);
else
Server()->StopRecord(m_pPlayer->GetCID());
pData->m_RecordStopTick = -1;
}
int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon);

View file

@ -233,6 +233,8 @@ public:
m_BestTime = 0;
for(float &BestTimeCp : m_aBestTimeCp)
BestTimeCp = 0;
m_RecordStopTick = -1;
}
void Set(float Time, const float aTimeCp[NUM_CHECKPOINTS])
@ -244,6 +246,9 @@ public:
float m_BestTime;
float m_aBestTimeCp[NUM_CHECKPOINTS];
int m_RecordStopTick;
float m_RecordFinishTime;
};
struct CTeamrank

View file

@ -212,6 +212,19 @@ void CGameTeams::Tick()
{
int Now = Server()->Tick();
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayerData *pData = GameServer()->Score()->PlayerData(i);
if(!Server()->IsRecording(i))
continue;
if(Now >= pData->m_RecordStopTick && pData->m_RecordStopTick != -1)
{
Server()->SaveDemo(i, pData->m_RecordFinishTime);
pData->m_RecordStopTick = -1;
}
}
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_aTeamUnfinishableKillTick[i] == -1 || m_aTeamState[i] != TEAMSTATE_STARTED_UNFINISHABLE)
@ -692,7 +705,8 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp)
if(Time - pData->m_BestTime < 0)
{
// new record \o/
Server()->SaveDemo(ClientID, Time);
pData->m_RecordStopTick = Server()->Tick() + Server()->TickSpeed();
pData->m_RecordFinishTime = Time;
if(Diff >= 60)
str_format(aBuf, sizeof(aBuf), "New record: %d minute(s) %5.2f second(s) better.",
@ -728,7 +742,8 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp)
}
else
{
Server()->SaveDemo(ClientID, Time);
pData->m_RecordStopTick = Server()->Tick() + Server()->TickSpeed();
pData->m_RecordFinishTime = Time;
}
if(!Server()->IsSixup(ClientID))