about summary refs log tree commit diff
path: root/src/game/server/entities/flag.cpp
diff options
context:
space:
mode:
authorChoupom <andycootlapin@hotmail.fr>2010-09-06 12:29:28 +0200
committeroy <Tom_Adams@web.de>2010-09-07 20:02:46 +0200
commit532ea85aebc9dc2ce6d87fe484766bf37ab40970 (patch)
treed7820215260874cbaa01d9ed15fcdc46c52043b2 /src/game/server/entities/flag.cpp
parent6299f6518aa8576fa06f62101aa466c3da528fb1 (diff)
downloadzcatch-532ea85aebc9dc2ce6d87fe484766bf37ab40970.tar.gz
zcatch-532ea85aebc9dc2ce6d87fe484766bf37ab40970.zip
separated CFlag from ctf
Diffstat (limited to 'src/game/server/entities/flag.cpp')
-rw-r--r--src/game/server/entities/flag.cpp36
1 files changed, 36 insertions, 0 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();
+}