summaryrefslogtreecommitdiff
path: root/game/server/tf/tf_wartracker.h
blob: 5ea67ab7a888b280d32ad267e663bfa42fd52b70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Tracker for War Data on a player
//
// $NoKeywords: $
//=============================================================================//

#ifndef TF_SPYENGY_WARTRACKER_H
#define TF_SPYENGY_WARTRACKER_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_wardata.h"
#include "shared_object_tracker.h"

class CTFplayer;

//---------------------------------------------------------------------
// Purpose: Tracks kills between Team Engineer and Team Spy in the 2014
//			war.  Players are considered Team Engineer if they are wearing
//			the special Engy Hat or are unallied and playing as Engy.
//			Visa versa, players are considered to be on Team Spy if they
//			are wearing the special Spy Hat or are unallied and playing 
//			as Spy.
//---------------------------------------------------------------------
class CTFWarTracker : public CBaseSOTracker, public CGameEventListener
{
	DECLARE_CLASS( CTFWarTracker, CBaseSOTracker )
public:
	CTFWarTracker( const CSharedObject* pItem, CSteamID SteamIDOwner, CSOTrackerManager* pManager );

	virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;

	virtual void CommitChangesToDB() OVERRIDE;
	virtual	void OnUpdate() OVERRIDE {}
	virtual void OnRemove() OVERRIDE {}
private:

	static const int m_kPointsPerKill = 5;
	static const int m_kBonusPointsPerKill = 2;
	CGCMsgGC_War_IndividualUpdate m_ProtoData;
};

//---------------------------------------------------------------------
// Purpose: Contains all the trackers for wars for each player.  Tells 
//			individual trackers to update the GC every m_kflThinkInterval
//			seconds, defined below.
//---------------------------------------------------------------------
class CTFWarTrackerManager : public CSOTrackerManager
{
	DECLARE_CLASS( CTFWarTrackerManager, CSOTrackerManager )
public:
	CTFWarTrackerManager();

	virtual SOTrackerMap_t::KeyType_t GetKeyForObjectTracker( const CSharedObject* pItem, CSteamID steamIDOwner ) OVERRIDE;

private:
#ifdef GAME_DLL
	void SendMessageForCommit( const ::google::protobuf::Message* pProtoMessage ) const;
#endif
	virtual int GetType() const OVERRIDE { return CWarData::k_nTypeID; }
	virtual const char* GetName() const { return "WarTrackerManager"; }
	virtual CFmtStr GetDebugObjectDescription( const CSharedObject* pItem ) const;
	virtual CBaseSOTracker* AllocateNewTracker( const CSharedObject* pItem, CSteamID steamIDOwner, CSOTrackerManager* pManager ) const OVERRIDE;
	virtual ::google::protobuf::Message* AllocateNewProtoMessage() const OVERRIDE;
	virtual void OnCommitRecieved( const ::google::protobuf::Message* pProtoMsg ) OVERRIDE;
	virtual bool ShouldTrackObject( const CSteamID & steamIDOwner, const CSharedObject *pObject ) const OVERRIDE;
	virtual int CompareRecords( const ::google::protobuf::Message* pNewProtoMsg, const ::google::protobuf::Message* pExistingProtoMsg ) const OVERRIDE;

};

CTFWarTrackerManager* GetWarTrackerManager();

#endif	// TF_SPYENGY_WARTRACKER_H