diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index ab5716acb..170ee5af2 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -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); diff --git a/src/game/server/scoreworker.h b/src/game/server/scoreworker.h index 7a2ca5400..411c25044 100644 --- a/src/game/server/scoreworker.h +++ b/src/game/server/scoreworker.h @@ -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 diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index c10623eb7..1cff6a384 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -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))