score.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // Score.h
  19. // Project: Postal
  20. //
  21. // History:
  22. //
  23. // 06/11/97 BRH Started this module
  24. //
  25. // 06/16/97 BRH Added a scoreboard reset function to reset the scores
  26. // and display time.
  27. //
  28. // 06/17/97 BRH Increased max number of players to make sure there are
  29. // enough entries for 16 or more players.
  30. //
  31. // 07/04/97 BRH Added two more scoring modes.
  32. //
  33. // 07/07/97 JMI Now ScoreUpdateDisplay() returns true if it drew into
  34. // the passed in buffer and false otherwise.
  35. //
  36. // 07/22/97 BRH Added ScoreDisplayHighScores.
  37. //
  38. // 07/26/97 BRH Added ScoreGetName to get the name of the player when
  39. // they better one of the high scores.
  40. //
  41. // 08/10/97 JRD Added a hood to the score status to allow graphical
  42. // backdrops behind the scoring status.
  43. //
  44. // 09/07/97 JMI Now requires a pclient for MP scores.
  45. //
  46. //////////////////////////////////////////////////////////////////////////////
  47. #ifndef SCORE_H
  48. #define SCORE_H
  49. #include "RSPiX.h"
  50. #include "game.h"
  51. #include "realm.h"
  52. #include "net.h"
  53. #include "netclient.h"
  54. class CScoreboard
  55. {
  56. //---------------------------------------------------------------------------
  57. // typedefs
  58. //---------------------------------------------------------------------------
  59. public:
  60. typedef enum
  61. {
  62. SinglePlayer,
  63. MultiPlayer,
  64. Timed,
  65. Goal,
  66. CaptureFlag,
  67. TimeBonus
  68. } ScoringMode;
  69. //---------------------------------------------------------------------------
  70. // Variables
  71. //---------------------------------------------------------------------------
  72. public:
  73. short m_asScores[Net::MaxNumIDs+1]; // Score for each player
  74. // U16 m_au16PlayerIDs[Net::MaxNumIDs+1]; // ID of each player
  75. long m_lLastScoreDrawTime; // Time since last update
  76. long m_lLastStatusDrawTime; // Time since last update
  77. protected:
  78. ScoringMode m_ScoringMode; // Mode of scoring
  79. //---------------------------------------------------------------------------
  80. // Constructor(s) / destructor
  81. //---------------------------------------------------------------------------
  82. public:
  83. CScoreboard()
  84. {
  85. short i;
  86. for (i = 0; i <= Net::MaxNumIDs; i++)
  87. {
  88. m_asScores[i] = 0;
  89. // m_au16PlayerIDs[i] = 0;
  90. }
  91. }
  92. ~CScoreboard()
  93. {
  94. }
  95. //---------------------------------------------------------------------------
  96. // Functions
  97. //---------------------------------------------------------------------------
  98. public:
  99. // Return the indes of the player or -1 if not found
  100. // short GetPlayerIndex(U16 uInstanceID)
  101. // {
  102. // short sPlayerIndex = Net::MaxNumIDs;
  103. //
  104. // CThing* pShooter = GetItemById(uInstanceID)
  105. // if (pShooter && pShooter->m_id == CThing::CDudeID)
  106. // {
  107. // sPlayerIndex = MIN(((CDude*) pShooter)->m_sDudeNum, Net::MaxNumIDs);
  108. // }
  109. // }
  110. void Reset(void)
  111. {
  112. short i;
  113. for (i = 0; i < Net::MaxNumIDs; i++)
  114. m_asScores[i] = 0;
  115. m_lLastStatusDrawTime = 0;
  116. m_lLastScoreDrawTime = 0;
  117. }
  118. // Subtract one from the score of the indicated guy
  119. void SubtractOne(short sPlayerIndex)
  120. {
  121. // If it is beyond the number of players, set it to the
  122. // overflow bin.
  123. if (sPlayerIndex > Net::MaxNumIDs)
  124. sPlayerIndex = Net::MaxNumIDs;
  125. m_asScores[sPlayerIndex]--;
  126. }
  127. // Add one to the score of the indicated guy
  128. void AddOne(short sPlayerIndex)
  129. {
  130. // If it is beyond the number of players, set it to the
  131. // overflow bin.
  132. if (sPlayerIndex > Net::MaxNumIDs)
  133. sPlayerIndex = Net::MaxNumIDs;
  134. m_asScores[sPlayerIndex]++;
  135. }
  136. void SetScoringMode(ScoringMode Mode)
  137. {m_ScoringMode = Mode;};
  138. short GetScoringMode(void)
  139. {return m_ScoringMode;};
  140. };
  141. // Set up the RPrint for the score
  142. void ScoreInit(void);
  143. // Reset the display time and the multiplayer scores
  144. void ScoreReset(void);
  145. // Reset the display time - required before each realm
  146. void ScoreResetDisplay(void);
  147. // Function called by Characters when they die
  148. void ScoreRegisterKill(CRealm* pRealm, U16 u16DeadGuy, U16 u16Killer);
  149. // Function called by play to update the score display
  150. // Returns true, if pImage was updated; false otherwise.
  151. bool ScoreUpdateDisplay(RImage* pImage, RRect* pRect, CRealm* pRealm,
  152. CNetClient* pclient, short sDstX, short sDstY, CHood* pHood);
  153. // Function to set the scoring mode (ie multiplayer, single, timed etc)
  154. void ScoreSetMode(CScoreboard::ScoringMode Mode);
  155. // Call this function to show the status line or mission goal for a few
  156. // seconds. This can be called when the "show mission" key is pressed.
  157. void ScoreDisplayStatus(CRealm* pRealm);
  158. // Call this function at the end of the level and if it is a challenge level,
  159. // it will display the high scores for that level and give the user a chance
  160. // to enter their name if they beat one of the top scores.
  161. void ScoreDisplayHighScores( // Returns nothing.
  162. CRealm* pRealm, // In: Realm won.
  163. CNetClient* pclient = NULL, // In: Client ptr for MP mode, or NULL in SP mode.
  164. long lMaxTimeOut = -1); // In: Max time on score screen (quits after this
  165. // duration, if not -1).
  166. // Get the name for a new high score
  167. short ScoreGetName(char* pszName);
  168. // Returns the highest multiplayer score.
  169. short ScoreHighestKills(CRealm* pRealm);
  170. #endif //SCORE_H
  171. //////////////////////////////////////////////////////////////////////////////
  172. // EOF
  173. //////////////////////////////////////////////////////////////////////////////