Swap projectile owners when using /swap

Thanks to Soapy Sandwich for responsibly disclosing this issue.

/swap is currently disabled until this is merged.
This commit is contained in:
def 2021-12-11 23:14:19 +01:00
parent d862207a73
commit 84b1b6f92e
2 changed files with 8 additions and 0 deletions

View file

@ -7,6 +7,8 @@
class CProjectile : public CEntity
{
friend class CGameTeams;
public:
CProjectile(
CGameWorld *pGameWorld,

View file

@ -5,6 +5,7 @@
#include <engine/shared/config.h>
#include "entities/character.h"
#include "entities/projectile.h"
#include "player.h"
CGameTeams::CGameTeams(CGameContext *pGameContext) :
@ -889,6 +890,11 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in
swap(m_TeeStarted[pPlayer->GetCID()], m_TeeStarted[pTargetPlayer->GetCID()]);
swap(m_TeeFinished[pPlayer->GetCID()], m_TeeFinished[pTargetPlayer->GetCID()]);
for(CProjectile *pProj = (CProjectile *)GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_PROJECTILE); pProj; pProj = (CProjectile *)pProj->TypeNext())
{
pProj->m_Owner = pProj->m_Owner == pPlayer->GetCID() ? pTargetPlayer->GetCID() : pProj->m_Owner == pTargetPlayer->GetCID() ? pPlayer->GetCID() : pProj->m_Owner;
}
str_format(aBuf, sizeof(aBuf),
"%s has swapped with %s.",
Server()->ClientName(pPlayer->GetCID()), Server()->ClientName(pTargetPlayer->GetCID()));