sys_stats.h (4339B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #ifndef __SYS_STATS_H__ 29 #define __SYS_STATS_H__ 30 31 //------------------------ 32 // leaderboardError_t 33 //------------------------ 34 enum leaderboardError_t { 35 LEADERBOARD_ERROR_NONE, 36 LEADERBOARD_ERROR_FAILED, // General error occurred 37 LEADERBOARD_ERROR_NOT_ONLINE, // Not online to request leaderboards 38 LEADERBOARD_ERROR_BUSY, // Unable to download leaderboards right now (download already in progress) 39 LEADERBOARD_ERROR_INVALID_USER, // Unable to request leaderboards as the given user 40 LEADERBOARD_ERROR_INVALID_REQUEST, // The leaderboard request was invalid 41 LEADERBOARD_ERROR_DOWNLOAD, // An error occurred while downloading the leaderboard 42 LEADERBOARD_ERROR_MAX 43 }; 44 45 /* 46 ================================================ 47 idLeaderboardCallback 48 ================================================ 49 */ 50 class idLeaderboardCallback : public idCallback { 51 public: 52 struct row_t { 53 bool hasAttachment; 54 int64 attachmentID; 55 idStr name; 56 int64 rank; 57 idArray< int64, MAX_LEADERBOARD_COLUMNS > columns; 58 }; 59 60 idLeaderboardCallback() : def( NULL ), startIndex( -1 ), localIndex( -1 ), numRowsInLeaderboard( -1 ), errorCode( LEADERBOARD_ERROR_NONE ) { } 61 virtual idLeaderboardCallback * Clone() const = 0; 62 63 // Used by the platform handlers to set data 64 void ResetRows() { rows.Clear(); } 65 void AddRow( const row_t & row ) { rows.Append( row ); } 66 void SetNumRowsInLeaderboard( int32 i ) { numRowsInLeaderboard = i; } 67 void SetDef( const leaderboardDefinition_t * def_ ) { def = def_; } 68 void SetStartIndex( int startIndex_ ) { startIndex = startIndex_; } 69 void SetLocalIndex( int localIndex_ ) { localIndex = localIndex_; } 70 void SetErrorCode( leaderboardError_t errorCode ) { this->errorCode = errorCode; } 71 72 // Used in user callback for information retrieval 73 const leaderboardDefinition_t * GetDef() const { return def; } 74 int GetStartIndex() const { return startIndex; } 75 const idList< row_t > & GetRows() const { return rows; } 76 int GetNumRowsInLeaderboard() const { return numRowsInLeaderboard; } 77 int GetLocalIndex() const { return localIndex; } 78 leaderboardError_t GetErrorCode() const { return this->errorCode; } 79 80 protected: 81 const leaderboardDefinition_t * def; // leaderboard def 82 int startIndex; // where the first row starts in the online leaderboard 83 int localIndex; // if player is in the rows, this is the offset of him within the returned rows 84 idList< row_t > rows; // leaderboard entries for the request 85 int numRowsInLeaderboard; // total number of rows in the online leaderboard 86 leaderboardError_t errorCode; // error, if any, that occurred during last operation 87 }; 88 89 90 91 #endif // !__SYS_STATS_H__