From 532ea85aebc9dc2ce6d87fe484766bf37ab40970 Mon Sep 17 00:00:00 2001 From: Choupom Date: Mon, 6 Sep 2010 12:29:28 +0200 Subject: separated CFlag from ctf --- src/game/server/entities/flag.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/game/server/entities/flag.h | 25 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/game/server/entities/flag.cpp create mode 100644 src/game/server/entities/flag.h (limited to 'src/game/server/entities') diff --git a/src/game/server/entities/flag.cpp b/src/game/server/entities/flag.cpp new file mode 100644 index 00000000..4d2e1612 --- /dev/null +++ b/src/game/server/entities/flag.cpp @@ -0,0 +1,36 @@ +#include +#include "flag.h" + +CFlag::CFlag(CGameWorld *pGameWorld, int Team) +: CEntity(pGameWorld, NETOBJTYPE_FLAG) +{ + m_Team = Team; + m_ProximityRadius = ms_PhysSize; + m_pCarryingCharacter = NULL; + m_GrabTick = 0; + + Reset(); +} + +void CFlag::Reset() +{ + m_pCarryingCharacter = NULL; + m_AtStand = 1; + m_Pos = m_StandPos; + m_Vel = vec2(0,0); + m_GrabTick = 0; +} + +void CFlag::Snap(int SnappingClient) +{ + CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Team, sizeof(CNetObj_Flag)); + pFlag->m_X = (int)m_Pos.x; + pFlag->m_Y = (int)m_Pos.y; + pFlag->m_Team = m_Team; + pFlag->m_CarriedBy = -1; + + if(m_AtStand) + pFlag->m_CarriedBy = -2; + else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer()) + pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID(); +} diff --git a/src/game/server/entities/flag.h b/src/game/server/entities/flag.h new file mode 100644 index 00000000..1406d982 --- /dev/null +++ b/src/game/server/entities/flag.h @@ -0,0 +1,25 @@ +#ifndef GAME_SERVER_ENTITIES_FLAG_H +#define GAME_SERVER_ENTITIES_FLAG_H + +#include + +class CFlag : public CEntity +{ +public: + static const int ms_PhysSize = 14; + CCharacter *m_pCarryingCharacter; + vec2 m_Vel; + vec2 m_StandPos; + + int m_Team; + int m_AtStand; + int m_DropTick; + int m_GrabTick; + + CFlag(CGameWorld *pGameWorld, int Team); + + virtual void Reset(); + virtual void Snap(int SnappingClient); +}; + +#endif -- cgit 1.4.1