sys_stats.h 4.2 KB

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