6156: Swap times should be per player, not per team (fixes #6155) r=Learath2 a=def-

<!-- What is the motivation for the changes of this pull request? -->

<!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2023-01-03 15:59:25 +00:00 committed by GitHub
commit b36726bbca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -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;
}
}
}
@ -861,7 +861,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)
@ -871,7 +871,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),

View file

@ -28,7 +28,7 @@ class CGameTeams
uint64_t m_aInvited[NUM_TEAMS];
bool m_aPractice[NUM_TEAMS];
std::shared_ptr<CScoreSaveResult> 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