From bd815a050740eb8d24b31a5ff35a027e393e872c Mon Sep 17 00:00:00 2001 From: def Date: Sat, 17 Dec 2022 23:56:08 +0100 Subject: [PATCH] Swap times should be per player, not per team (fixes #6155) --- src/game/server/teams.cpp | 6 +++--- src/game/server/teams.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 8e6ca9955..6a43b8717 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -41,7 +41,6 @@ void CGameTeams::ResetRoundState(int Team) ResetInvited(Team); if(Team != TEAM_SUPER) ResetSwitchers(Team); - m_aLastSwap[Team] = 0; m_aPractice[Team] = false; m_aTeamUnfinishableKillTick[Team] = -1; @@ -51,6 +50,7 @@ void CGameTeams::ResetRoundState(int Team) { GameServer()->m_apPlayers[i]->m_VotedForPractice = false; GameServer()->m_apPlayers[i]->m_SwapTargetsClientID = -1; + m_aLastSwap[i] = 0; } } } @@ -857,7 +857,7 @@ void CGameTeams::RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int T } pPlayer->m_SwapTargetsClientID = pTargetPlayer->GetCID(); - m_aLastSwap[Team] = Server()->Tick(); + m_aLastSwap[pPlayer->GetCID()] = Server()->Tick(); } void CGameTeams::SwapTeamCharacters(CPlayer *pPrimaryPlayer, CPlayer *pTargetPlayer, int Team) @@ -867,7 +867,7 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPrimaryPlayer, CPlayer *pTargetPla char aBuf[128]; - int Since = (Server()->Tick() - m_aLastSwap[Team]) / Server()->TickSpeed(); + int Since = (Server()->Tick() - m_aLastSwap[pTargetPlayer->GetCID()]) / Server()->TickSpeed(); if(Since < g_Config.m_SvSaveSwapGamesDelay) { str_format(aBuf, sizeof(aBuf), diff --git a/src/game/server/teams.h b/src/game/server/teams.h index e43cb0b97..c1d593b8f 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -28,7 +28,7 @@ class CGameTeams uint64_t m_aInvited[NUM_TEAMS]; bool m_aPractice[NUM_TEAMS]; std::shared_ptr m_apSaveTeamResult[NUM_TEAMS]; - uint64_t m_aLastSwap[NUM_TEAMS]; + uint64_t m_aLastSwap[MAX_CLIENTS]; // index is id of player who initiated swap bool m_aTeamSentStartWarning[NUM_TEAMS]; // `m_aTeamUnfinishableKillTick` is -1 by default and gets set when a // team becomes unfinishable. If the team hasn't entered practice mode