mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
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:
parent
d862207a73
commit
84b1b6f92e
|
@ -7,6 +7,8 @@
|
|||
|
||||
class CProjectile : public CEntity
|
||||
{
|
||||
friend class CGameTeams;
|
||||
|
||||
public:
|
||||
CProjectile(
|
||||
CGameWorld *pGameWorld,
|
||||
|
|
|
@ -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()));
|
||||
|
|
Loading…
Reference in a new issue