From a3e19fc39a981ae8c81c37b73d7fc7bd251df751 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 26 Sep 2024 18:57:23 +0200 Subject: [PATCH] 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. --- src/game/server/entities/character.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index ac98c8daa..d785e5179 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -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); }