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:
Tim Schumacher 2024-09-26 18:57:23 +02:00
parent e1b09787ae
commit a3e19fc39a

View file

@ -174,14 +174,15 @@ void CCharacter::SetSolo(bool Solo)
void CCharacter::SetSuper(bool Super)
{
bool WasSuper = m_Core.m_Super;
m_Core.m_Super = Super;
if(Super)
if(Super && !WasSuper)
{
m_TeamBeforeSuper = Team();
Teams()->SetCharacterTeam(GetPlayer()->GetCid(), TEAM_SUPER);
m_DDRaceState = DDRACE_CHEAT;
}
else
else if(!Super && WasSuper)
{
Teams()->SetForceCharacterTeam(GetPlayer()->GetCid(), m_TeamBeforeSuper);
}