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.
This commit is contained in:
Robert Müller 2023-04-04 15:50:12 +02:00
parent 89eb7e6633
commit aa08cfabc2
4 changed files with 12 additions and 0 deletions

View file

@ -123,3 +123,8 @@ void CDraggerBeam::Snap(int SnappingClient)
GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(), GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(),
m_Pos, TargetPos, StartTick, -1, LASERTYPE_DOOR); 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;
}

View file

@ -38,6 +38,7 @@ public:
void Reset() override; void Reset() override;
void Tick() override; void Tick() override;
void Snap(int SnappingClient) override; void Snap(int SnappingClient) override;
void SwapClients(int Client1, int Client2) override;
}; };
#endif // GAME_SERVER_ENTITIES_DRAGGER_BEAM_H #endif // GAME_SERVER_ENTITIES_DRAGGER_BEAM_H

View file

@ -122,3 +122,8 @@ void CPlasma::Snap(int SnappingClient)
GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(), GameServer()->SnapLaserObject(CSnapContext(SnappingClientVersion), GetID(),
m_Pos, m_Pos, m_EvalTick, -1, m_Freeze ? LASERTYPE_FREEZE : LASERTYPE_RIFLE); 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;
}

View file

@ -40,6 +40,7 @@ public:
void Reset() override; void Reset() override;
void Tick() override; void Tick() override;
void Snap(int SnappingClient) override; void Snap(int SnappingClient) override;
void SwapClients(int Client1, int Client2) override;
}; };
#endif // GAME_SERVER_ENTITIES_PLASMA_H #endif // GAME_SERVER_ENTITIES_PLASMA_H