mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #5461
5461: add penatly to the whole team r=def- a=BloodWod-513 this should fix it #5460 ## 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 if it works standalone, system.c especially - [ ] 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: BloodWod-513 <dayn_2013@mail.ru>
This commit is contained in:
commit
29be9a79fd
|
@ -852,9 +852,9 @@ void CGameTeams::RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int T
|
|||
m_LastSwap[Team] = Server()->Tick();
|
||||
}
|
||||
|
||||
void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team)
|
||||
void CGameTeams::SwapTeamCharacters(CPlayer *pPrimaryPlayer, CPlayer *pTargetPlayer, int Team)
|
||||
{
|
||||
if(!pPlayer || !pTargetPlayer)
|
||||
if(!pPrimaryPlayer || !pTargetPlayer)
|
||||
return;
|
||||
|
||||
char aBuf[128];
|
||||
|
@ -866,7 +866,7 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
|
|||
"You have to wait %d seconds until you can swap.",
|
||||
g_Config.m_SvSaveSwapGamesDelay - Since);
|
||||
|
||||
GameServer()->SendChatTarget(pPlayer->GetCID(), aBuf);
|
||||
GameServer()->SendChatTarget(pPrimaryPlayer->GetCID(), aBuf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -886,34 +886,43 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
|
|||
"Your swap request timed out %d seconds ago. Use /swap again to re-initiate it.",
|
||||
Since - g_Config.m_SvSwapTimeout);
|
||||
|
||||
GameServer()->SendChatTarget(pPlayer->GetCID(), aBuf);
|
||||
GameServer()->SendChatTarget(pPrimaryPlayer->GetCID(), aBuf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CSaveTee PrimarySavedTee;
|
||||
PrimarySavedTee.Save(pPlayer->GetCharacter());
|
||||
PrimarySavedTee.Save(pPrimaryPlayer->GetCharacter());
|
||||
|
||||
CSaveTee SecondarySavedTee;
|
||||
SecondarySavedTee.Save(pTargetPlayer->GetCharacter());
|
||||
|
||||
PrimarySavedTee.Load(pTargetPlayer->GetCharacter(), Team, true);
|
||||
SecondarySavedTee.Load(pPlayer->GetCharacter(), Team, true);
|
||||
SecondarySavedTee.Load(pPrimaryPlayer->GetCharacter(), Team, true);
|
||||
|
||||
std::swap(m_TeeStarted[pPlayer->GetCID()], m_TeeStarted[pTargetPlayer->GetCID()]);
|
||||
std::swap(m_TeeFinished[pPlayer->GetCID()], m_TeeFinished[pTargetPlayer->GetCID()]);
|
||||
std::swap(pPlayer->GetCharacter()->GetRescueTeeRef(), pTargetPlayer->GetCharacter()->GetRescueTeeRef());
|
||||
if(Team >= 1)
|
||||
{
|
||||
for(const auto &pPlayer : GameServer()->m_apPlayers)
|
||||
{
|
||||
CCharacter *pChar = pPlayer ? pPlayer->GetCharacter() : nullptr;
|
||||
if(pChar && pChar->Team() == Team && pChar != pPrimaryPlayer->GetCharacter() && pChar != pTargetPlayer->GetCharacter())
|
||||
pChar->m_StartTime = pPrimaryPlayer->GetCharacter()->m_StartTime;
|
||||
}
|
||||
}
|
||||
std::swap(m_TeeStarted[pPrimaryPlayer->GetCID()], m_TeeStarted[pTargetPlayer->GetCID()]);
|
||||
std::swap(m_TeeFinished[pPrimaryPlayer->GetCID()], m_TeeFinished[pTargetPlayer->GetCID()]);
|
||||
std::swap(pPrimaryPlayer->GetCharacter()->GetRescueTeeRef(), pTargetPlayer->GetCharacter()->GetRescueTeeRef());
|
||||
|
||||
GameServer()->m_World.SwapClients(pPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
GameServer()->m_World.SwapClients(pPrimaryPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
|
||||
if(GameServer()->TeeHistorianActive())
|
||||
{
|
||||
GameServer()->TeeHistorian()->RecordPlayerSwap(pPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
GameServer()->TeeHistorian()->RecordPlayerSwap(pPrimaryPlayer->GetCID(), pTargetPlayer->GetCID());
|
||||
}
|
||||
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"%s has swapped with %s.",
|
||||
Server()->ClientName(pPlayer->GetCID()), Server()->ClientName(pTargetPlayer->GetCID()));
|
||||
Server()->ClientName(pPrimaryPlayer->GetCID()), Server()->ClientName(pTargetPlayer->GetCID()));
|
||||
|
||||
GameServer()->SendChatTeam(Team, aBuf);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
void KillSavedTeam(int ClientID, int Team);
|
||||
void ResetSavedTeam(int ClientID, int Team);
|
||||
void RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team);
|
||||
void SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team);
|
||||
void SwapTeamCharacters(CPlayer *pPrimaryPlayer, CPlayer *pTargetPlayer, int Team);
|
||||
void ProcessSaveTeam();
|
||||
|
||||
int GetFirstEmptyTeam() const;
|
||||
|
|
Loading…
Reference in a new issue