diff options
| author | Choupom <andycootlapin@hotmail.fr> | 2010-09-06 12:29:28 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-09-07 20:02:46 +0200 |
| commit | 532ea85aebc9dc2ce6d87fe484766bf37ab40970 (patch) | |
| tree | d7820215260874cbaa01d9ed15fcdc46c52043b2 | |
| parent | 6299f6518aa8576fa06f62101aa466c3da528fb1 (diff) | |
| download | zcatch-532ea85aebc9dc2ce6d87fe484766bf37ab40970.tar.gz zcatch-532ea85aebc9dc2ce6d87fe484766bf37ab40970.zip | |
separated CFlag from ctf
| -rw-r--r-- | src/game/server/entities/flag.cpp | 36 | ||||
| -rw-r--r-- | src/game/server/entities/flag.h | 25 | ||||
| -rw-r--r-- | src/game/server/gamemodes/ctf.cpp | 37 | ||||
| -rw-r--r-- | src/game/server/gamemodes/ctf.h | 19 |
4 files changed, 62 insertions, 55 deletions
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 <game/server/gamecontext.h> +#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 <game/server/entity.h> + +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 diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index b28191af..353376e2 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -1,6 +1,7 @@ // copyright (c) 2007 magnus auvinen, see licence.txt for more info #include <game/mapitems.h> #include <game/server/entities/character.h> +#include <game/server/entities/flag.h> #include <game/server/player.h> #include <game/server/gamecontext.h> #include "ctf.h" @@ -210,39 +211,3 @@ void CGameControllerCTF::Tick() } } } - -// Flag -CFlag::CFlag(CGameWorld *pGameWorld, int Team) -: CEntity(pGameWorld, NETOBJTYPE_FLAG) -{ - m_Team = Team; - m_ProximityRadius = ms_PhysSize; - m_pCarryingCharacter = 0x0; - m_GrabTick = 0; - - Reset(); -} - -void CFlag::Reset() -{ - m_pCarryingCharacter = 0x0; - 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/gamemodes/ctf.h b/src/game/server/gamemodes/ctf.h index 16c6097a..f50509be 100644 --- a/src/game/server/gamemodes/ctf.h +++ b/src/game/server/gamemodes/ctf.h @@ -16,24 +16,5 @@ public: virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon); }; -// TODO: move to seperate file -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 |