summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_wardata.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/shared/tf/tf_wardata.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/shared/tf/tf_wardata.h')
-rw-r--r--game/shared/tf/tf_wardata.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/game/shared/tf/tf_wardata.h b/game/shared/tf/tf_wardata.h
new file mode 100644
index 0000000..bd78825
--- /dev/null
+++ b/game/shared/tf/tf_wardata.h
@@ -0,0 +1,130 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Holds WarData
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef TFWARDATA_H
+#define TFWARDATA_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "gcsdk/protobufsharedobject.h"
+#include "tf_gcmessages.h"
+#if defined (CLIENT_DLL) || defined (GAME_DLL)
+ #include "gc_clientsystem.h"
+#endif
+
+#ifdef GC
+ #include "tf_gc.h"
+#endif
+
+//---------------------------------------------------------------------------------
+// Purpose: The shared object that contains a user's stats for a war
+//---------------------------------------------------------------------------------
+class CWarData : public GCSDK::CProtoBufSharedObject< CSOWarData, k_EEConTypeWarData >
+{
+public:
+ CWarData();
+#ifdef GC
+ DECLARE_CLASS_MEMPOOL( CWarData );
+ CWarData( uint32 unAccountID, war_definition_index_t eWarID, war_side_t eSide );
+
+ virtual bool BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess );
+ virtual bool BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields );
+ virtual bool BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess );
+
+ void WriteToRecord( CSchWarData *pWarData ) const;
+ void ReadFromRecord( const CSchWarData & warData );
+#endif // GC
+};
+
+
+#if defined( CLIENT_DLL ) || defined( GC )
+//---------------------------------------------------------------------------------
+// Purpose: Holds the global stats for a war
+//
+// On the GC, the global stats are tabulated at load-time from all current
+// SQL records and is then modified in-memory.
+//
+// On the client, the global stats are requested whenever they are queried
+// but we limit how often we request.
+//---------------------------------------------------------------------------------
+class CTFWarGlobalDataHelper
+{
+public:
+#ifdef CLIENT_DLL
+ struct LeaderBoardEntries_t
+ {
+ LeaderBoardEntries_t() : m_bInitialized( false ) {}
+
+ bool m_bInitialized;
+ CUtlVector< LeaderboardEntry_t* > m_vecEntries;
+ };
+#endif // CLIENT_DLL
+
+ CTFWarGlobalDataHelper();
+ void Init();
+ bool BIsInitialized() const { return m_bInitialized; }
+
+ void AddToSideScore( war_definition_index_t nWar, war_side_t nSide, uint32 nValue );
+ uint64 GetGlobalSideScore( war_definition_index_t nWar, war_side_t nSide );
+
+ CGCMsgGC_War_GlobalStatsResponse* FindOrCreateWarData( war_definition_index_t nWarDef, bool bCreateIfDoesntExist );
+ CGCMsgGC_War_GlobalStatsResponse_SideScore* FindOrCreateWarDataSide( war_side_t nWarSide, war_definition_index_t nWarDef, bool bCreateIfDoesntExist );
+
+ void SetGlobalStats( const CGCMsgGC_War_GlobalStatsResponse& newData );
+
+#ifdef CLIENT_DLL
+ const LeaderBoardEntries_t& GetGlobalLeaderboardScores() const { return downloadedLeaderboardScoresGlobal; }
+ const LeaderBoardEntries_t& GetFriendsLeaderboardScores() const { return downloadedLeaderboardScoresFriends; }
+#endif // CLIENT_DLL
+
+private:
+
+#ifdef CLIENT_DLL
+ void RequestUpdateGlobalStats();
+ void CheckGlobalStatsStaleness();
+
+ // Leaderboard functions
+ void RequestLeaderboard();
+ void OnFindLeaderboard( LeaderboardFindResult_t *pResult, bool bIOFailure );
+ void DownloadLeaderboard();
+ void OnLeaderboardScoresDownloaded_Global( LeaderboardScoresDownloaded_t *pResult, bool bIOFailure );
+ void OnLeaderboardScoresDownloaded_Friends( LeaderboardScoresDownloaded_t *pResult, bool bIOFailure );
+#endif // CLIENT_DLL
+
+ bool m_bInitialized;
+
+ typedef CUtlMap< war_definition_index_t, CGCMsgGC_War_GlobalStatsResponse > WarStatsMap_t;
+ WarStatsMap_t m_mapWarStats;
+
+#ifdef CLIENT_DLL
+ float m_flLastUpdateRequest;
+ float m_flLastUpdated;
+ LeaderboardFindResult_t m_findLeaderboardResults;
+
+ CCallResult< CTFWarGlobalDataHelper, LeaderboardFindResult_t > m_findLeaderboardCallback;
+ LeaderBoardEntries_t downloadedLeaderboardScoresGlobal;
+ LeaderBoardEntries_t downloadedLeaderboardScoresFriends;
+
+ CCallResult< CTFWarGlobalDataHelper, LeaderboardScoresDownloaded_t > downloadLeaderboardCallbackGlobal;
+ CCallResult< CTFWarGlobalDataHelper, LeaderboardScoresDownloaded_t > downloadLeaderboardCallbackFriends;
+#endif // CLIENT_DLL
+};
+
+CTFWarGlobalDataHelper& GetWarData();
+#endif // CLIENT_DLL || GC
+
+CWarData* GetPlayerWarData( const CSteamID& steamID, war_definition_index_t warDefIndex, bool bLoadEvenIfWarInactive
+#ifdef GC_DLL
+ , bool bLoadSOCacheIfNeeded
+#endif
+ );
+#ifdef CLIENT_DLL
+CWarData* GetLocalPlayerWarData( war_definition_index_t warDefIndex );
+#endif
+
+#endif // TFWARDATA_H