From aa08cfabc285856eba41a7d4e1cc36adc21562f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 4 Apr 2023 15:50:12 +0200 Subject: [PATCH] Fix swapping with dragger beams and plasmas The client ID referenced by dragger beams and plasmas must also be swapped when two clients are swapped, as those entities should refer to the same character entity as before the swap. For dragger beams, swapping previously caused the active beams to switch target to another character. For plasmas, swapping previously caused already shot plasmas to not have an effect on their original target character. Closes #5865. --- src/game/server/entities/dragger_beam.cpp | 5 +++++ src/game/server/entities/dragger_beam.h | 1 + src/game/server/entities/plasma.cpp | 5 +++++ src/game/server/entities/plasma.h | 1 + 4 files changed, 12 insertions(+) diff --git a/src/game/server/entities/dragger_beam.cpp b/src/game/server/entities/dragger_beam.cpp index 500318ee9..3be6a81b8 100644 --- a/src/game/server/entities/dragger_beam.cpp +++ b/src/game/server/entities/dragger_beam.cpp @@ -123,3 +123,8 @@ void CDraggerBeam::Snap(int SnappingClient) GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(), m_Pos, TargetPos, StartTick, -1, LASERTYPE_DOOR); } + +void CDraggerBeam::SwapClients(int Client1, int Client2) +{ + m_ForClientID = m_ForClientID == Client1 ? Client2 : m_ForClientID == Client2 ? Client1 : m_ForClientID; +} diff --git a/src/game/server/entities/dragger_beam.h b/src/game/server/entities/dragger_beam.h index ffce1f2b1..ce3f65d98 100644 --- a/src/game/server/entities/dragger_beam.h +++ b/src/game/server/entities/dragger_beam.h @@ -38,6 +38,7 @@ public: void Reset() override; void Tick() override; void Snap(int SnappingClient) override; + void SwapClients(int Client1, int Client2) override; }; #endif // GAME_SERVER_ENTITIES_DRAGGER_BEAM_H diff --git a/src/game/server/entities/plasma.cpp b/src/game/server/entities/plasma.cpp index cf706da4b..b3b92968f 100644 --- a/src/game/server/entities/plasma.cpp +++ b/src/game/server/entities/plasma.cpp @@ -122,3 +122,8 @@ void CPlasma::Snap(int SnappingClient) GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(), m_Pos, m_Pos, m_EvalTick, -1, m_Freeze ? LASERTYPE_FREEZE : LASERTYPE_RIFLE); } + +void CPlasma::SwapClients(int Client1, int Client2) +{ + m_ForClientID = m_ForClientID == Client1 ? Client2 : m_ForClientID == Client2 ? Client1 : m_ForClientID; +} diff --git a/src/game/server/entities/plasma.h b/src/game/server/entities/plasma.h index f4ca948de..b961b961e 100644 --- a/src/game/server/entities/plasma.h +++ b/src/game/server/entities/plasma.h @@ -40,6 +40,7 @@ public: void Reset() override; void Tick() override; void Snap(int SnappingClient) override; + void SwapClients(int Client1, int Client2) override; }; #endif // GAME_SERVER_ENTITIES_PLASMA_H