mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 21:48:19 +00:00
Make CCharacter::SetSuper() idempotent
Specifically, SetSuper(false) followed by SetSuper(false) should not change teams. The following commit relies on this, but it is generally a good idea to remove this footgun.
This commit is contained in:
parent
e1b09787ae
commit
a3e19fc39a
|
@ -174,14 +174,15 @@ void CCharacter::SetSolo(bool Solo)
|
||||||
|
|
||||||
void CCharacter::SetSuper(bool Super)
|
void CCharacter::SetSuper(bool Super)
|
||||||
{
|
{
|
||||||
|
bool WasSuper = m_Core.m_Super;
|
||||||
m_Core.m_Super = Super;
|
m_Core.m_Super = Super;
|
||||||
if(Super)
|
if(Super && !WasSuper)
|
||||||
{
|
{
|
||||||
m_TeamBeforeSuper = Team();
|
m_TeamBeforeSuper = Team();
|
||||||
Teams()->SetCharacterTeam(GetPlayer()->GetCid(), TEAM_SUPER);
|
Teams()->SetCharacterTeam(GetPlayer()->GetCid(), TEAM_SUPER);
|
||||||
m_DDRaceState = DDRACE_CHEAT;
|
m_DDRaceState = DDRACE_CHEAT;
|
||||||
}
|
}
|
||||||
else
|
else if(!Super && WasSuper)
|
||||||
{
|
{
|
||||||
Teams()->SetForceCharacterTeam(GetPlayer()->GetCid(), m_TeamBeforeSuper);
|
Teams()->SetForceCharacterTeam(GetPlayer()->GetCid(), m_TeamBeforeSuper);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue