sys_stats_misc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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_MISC_H__
  21. #define __SYS_STATS_MISC_H__
  22. /*
  23. ================================================================================================
  24. Stats (for achievements, matchmaking, etc.)
  25. ================================================================================================
  26. */
  27. /*
  28. ================================================
  29. systemStats_t
  30. This is to give the framework the ability to deal with stat indexes that are
  31. completely up to each game. The system needs to deal with some stat indexes for things like
  32. the level for matchmaking, etc.
  33. ================================================
  34. */
  35. /*
  36. ================================================================================================
  37. Leader Boards
  38. ================================================================================================
  39. */
  40. const int MAX_LEADERBOARDS = 256;
  41. const int MAX_LEADERBOARD_COLUMNS = 16;
  42. enum aggregationMethod_t {
  43. AGGREGATE_MIN, // Write the new value if it is less than the existing value.
  44. AGGREGATE_MAX, // Write the new value if it is greater than the existing value.
  45. AGGREGATE_SUM, // Add the new value to the existing value and write the result.
  46. AGGREGATE_LAST, // Write the new value.
  47. };
  48. enum rankOrder_t {
  49. RANK_GREATEST_FIRST, // Rank the in descending order, greatest score is best score
  50. RANK_LEAST_FIRST, // Rank the in ascending order, lowest score is best score
  51. };
  52. enum statsColumnDisplayType_t {
  53. STATS_COLUMN_DISPLAY_NUMBER,
  54. STATS_COLUMN_DISPLAY_TIME_MILLISECONDS,
  55. STATS_COLUMN_DISPLAY_CASH,
  56. STATS_COLUMN_NEVER_DISPLAY,
  57. };
  58. struct columnDef_t {
  59. const char * locDisplayName;
  60. int bits;
  61. aggregationMethod_t aggregationMethod;
  62. statsColumnDisplayType_t displayType;
  63. };
  64. struct leaderboardDefinition_t {
  65. leaderboardDefinition_t() :
  66. id ( -1 ),
  67. numColumns( 0 ),
  68. columnDefs( NULL ),
  69. rankOrder( RANK_GREATEST_FIRST ),
  70. supportsAttachments( false ),
  71. checkAgainstCurrent( false ) {
  72. }
  73. leaderboardDefinition_t( int id_, int numColumns_, const columnDef_t * columnDefs_, rankOrder_t rankOrder_, bool supportsAttachments_, bool checkAgainstCurrent_ ) :
  74. id ( id_ ),
  75. numColumns( numColumns_ ),
  76. columnDefs( columnDefs_ ),
  77. rankOrder( rankOrder_ ),
  78. supportsAttachments( supportsAttachments_ ),
  79. checkAgainstCurrent( checkAgainstCurrent_ ) {
  80. }
  81. int32 id;
  82. int32 numColumns;
  83. const columnDef_t * columnDefs;
  84. rankOrder_t rankOrder;
  85. bool supportsAttachments;
  86. bool checkAgainstCurrent; // Compare column 0 with the currently stored leaderboard, and only submit the new leaderboard if the new column 0 is better
  87. idStr boardName; // Only used for display name within steam. If Empty, will generate. must be specifically set.
  88. };
  89. struct column_t {
  90. column_t( int64 value_ ) : value( value_ ) {}
  91. column_t() {}
  92. int64 value;
  93. };
  94. /*
  95. ================================================================================================
  96. Contains the Achievement and LeaderBoard free function declarations.
  97. ================================================================================================
  98. */
  99. typedef int32 leaderboardHandle_t;
  100. /*
  101. ================================================
  102. idLeaderBoardEntry
  103. ================================================
  104. */
  105. class idLeaderBoardEntry {
  106. public:
  107. static const int MAX_LEADERBOARD_COLUMNS = 16;
  108. idStr username; // aka gamertag
  109. int64 score;
  110. int64 columns[ MAX_LEADERBOARD_COLUMNS ];
  111. };
  112. const leaderboardDefinition_t * Sys_FindLeaderboardDef( int id );
  113. leaderboardDefinition_t * Sys_CreateLeaderboardDef( int id_, int numColumns_, const columnDef_t * columnDefs_, rankOrder_t rankOrder_, bool supportsAttachments_, bool checkAgainstCurrent_ );
  114. void Sys_DestroyLeaderboardDefs();
  115. #endif // !__SYS_STATS_MISC_H__