4475: Enable swapping in team 0 r=heinrich5991 a=def-

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

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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] 2022-04-28 14:37:56 +00:00 committed by GitHub
commit fbbc8baa8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -697,7 +697,7 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
int Team = Teams.m_Core.Team(pResult->m_ClientID);
if(Team < TEAM_FLOCK || (Team == TEAM_FLOCK && g_Config.m_SvTeam != SV_TEAM_FORCED_SOLO) || Team >= TEAM_SUPER)
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
{
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
@ -735,14 +735,23 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
return;
}
if(!Teams.IsStarted(Team))
CPlayer *pSwapPlayer = pSelf->m_apPlayers[TargetClientId];
if(Team == TEAM_FLOCK && g_Config.m_SvTeam != 3)
{
CCharacter *pChr = pPlayer->GetCharacter();
CCharacter *pSwapChr = pSwapPlayer->GetCharacter();
if(!pChr || !pSwapChr || pChr->m_DDRaceState != DDRACE_STARTED || pSwapChr->m_DDRaceState != DDRACE_STARTED)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "You and other player need to have started the map");
return;
}
}
else if(!Teams.IsStarted(Team))
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Need to have started the map to swap with a player.");
return;
}
CPlayer *pSwapPlayer = pSelf->m_apPlayers[TargetClientId];
bool SwapPending = pSwapPlayer->m_SwapTargetsClientID != pResult->m_ClientID;
if(SwapPending)
{