player.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/player.h $*
  25. * *
  26. * $Author:: Bhayes $*
  27. * *
  28. * $Modtime:: 3/08/02 6:41p $*
  29. * *
  30. * $Revision:: 87 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSV_VER)
  36. #pragma once
  37. #endif
  38. #ifndef PLAYER_H
  39. #define PLAYER_H
  40. #include "always.h"
  41. #include "playerdata.h"
  42. #include "bittype.h"
  43. #include "boolean.h"
  44. #include "netinterface.h"
  45. #include "networkobject.h"
  46. #include "netclassids.h"
  47. #include "wwstring.h"
  48. #include "gamespyauthmgr.h"
  49. #include "gamespybanlist.h"
  50. class Vector3;
  51. class ChunkSaveClass;
  52. class ChunkLoadClass;
  53. //------------------------------------------------------------------------------------
  54. //
  55. // Holds data about a player
  56. //
  57. class cPlayer : public PlayerDataClass, public NetworkObjectClass {
  58. public:
  59. friend class cPlayerManager; // so that only cPlayerManager can call ~cPlayer
  60. virtual uint32 Get_Network_Class_ID(void) const {return NETCLASSID_PLAYER;}
  61. virtual void Delete(void);
  62. void Init(void);
  63. void Mark_As_Modified(void);
  64. //
  65. // Client or server
  66. //
  67. cPlayer(void);
  68. bool Save(ChunkSaveClass & csave);
  69. bool Load(ChunkLoadClass & cload);
  70. int Get_Id(void) const {return Id;}
  71. void Set_Id(int id);
  72. void Set_Name(const WideStringClass & name);
  73. const WideStringClass & Get_Name(void) const {return Name;}
  74. virtual void Set_Score(float score);
  75. virtual void Increment_Score(float add);
  76. virtual void Set_Money(float money);
  77. virtual void Increment_Money(float add);
  78. int Get_Ladder_Points(void) const {return (int)LadderPoints;}
  79. void Set_Ladder_Points(int points);
  80. int Get_Kills(void) const {return (int)Kills;}
  81. void Increment_Kills(void);
  82. void Set_Kills(int new_kills);
  83. int Get_Deaths(void) const {return (int)Deaths;}
  84. void Increment_Deaths(void);
  85. void Set_Deaths(int new_deaths);
  86. int Get_Player_Type(void) const {return (int)PlayerType;}
  87. void Set_Player_Type(int type);
  88. bool Is_Team_Player(void);
  89. Vector3 Get_Color(void) const;
  90. float Get_Kill_To_Death_Ratio(void) const;
  91. void Get_Player_String(int rank, WideStringClass & string, bool force_verbose = false);
  92. unsigned long Get_WOL_ClanID(void) const {return ClanID;}
  93. void Set_WOL_ClanID(unsigned long id) {ClanID = id;}
  94. int Get_Wol_Rank(void) const {return (int)WolRank;}
  95. void Set_Wol_Rank(int wol_rank);
  96. unsigned short Get_WOL_Points(void) const
  97. {return WOLPoints;}
  98. void Set_WOL_Points(unsigned short points)
  99. {WOLPoints = points;}
  100. int Get_Rung(void) const {return (int)Rung;}
  101. void Set_Rung(int rung);
  102. int Get_Damage_Scale_Factor(void) const {return DamageScaleFactor;}
  103. void Set_Damage_Scale_Factor(int factor);
  104. void Set_Ping(int ping) {Ping = ping;}
  105. //int Get_Ping(void) {return Ping;}
  106. int Get_Ping(void);
  107. DWORD Get_Join_Time(void) const {return JoinTimeMs;}
  108. void Reset_Join_Time(void);
  109. DWORD Get_Total_Time(void) const {return TotalTimeMs;}
  110. void Increment_Total_Time(void);
  111. void Reset_Total_Time(void);
  112. ULONG Get_Ip_Address(void) const {return IpAddress;}
  113. void Set_Ip_Address(ULONG ip_address);
  114. int Get_Fps(void) const {return Fps;}
  115. void Set_Fps(int fps);
  116. //int Get_Avg_Ping(void) const;
  117. DWORD Get_Last_Update_Time_Ms(void) const {return LastUpdateTimeMs;}
  118. void Set_Last_Update_Time_Ms(DWORD time_ms);
  119. bool Is_Human(void) const {return Id >= 0;}
  120. virtual void Reset_Player(void);
  121. void Set_Is_In_Game(bool state);
  122. cBoolean & Get_Is_In_Game(void) {return IsInGame;}
  123. void Set_Is_Waiting_For_Intermission(bool state);
  124. cBoolean & Get_Is_Waiting_For_Intermission(void) {return IsWaitingForIntermission;}
  125. void Set_Is_Active(bool flag);
  126. cBoolean & Get_Is_Active(void) {return IsActive;}
  127. bool Is_Active(void) {return IsActive.Is_True();}
  128. bool Is_Alive_And_Kicking(void) const;
  129. //
  130. // Fast, in-game sorting support
  131. //
  132. void Set_Fast_Sort_Key(int key) { FastSortKey = key; }
  133. int Get_Fast_Sort_Key(void) { return FastSortKey; }
  134. //
  135. // Server-to-client data importing/exporting
  136. //
  137. virtual void Import_Creation(BitStreamClass &packet);
  138. virtual void Import_Rare(BitStreamClass &packet);
  139. virtual void Import_Occasional(BitStreamClass &packet);
  140. virtual void Export_Creation(BitStreamClass &packet);
  141. virtual void Export_Rare(BitStreamClass &packet);
  142. virtual void Export_Occasional(BitStreamClass &packet);
  143. enum {NUM_NEWBIE_GAMES = 5};
  144. void Set_Num_Wol_Games(int num_games);
  145. int Get_Num_Wol_Games(void) { return NumWolGames; }
  146. //
  147. // GameSpy support
  148. //
  149. void Set_GameSpy_Auth_State(GAMESPY_AUTH_STATE_ENUM state);
  150. GAMESPY_AUTH_STATE_ENUM Get_GameSpy_Auth_State(void) const {return GameSpyAuthState;}
  151. void Set_GameSpy_Auth_State_Entry_Time_Ms(DWORD time_ms);
  152. DWORD Get_GameSpy_Auth_State_Entry_Time_Ms(void) const {return GameSpyAuthStateEntryTimeMs;}
  153. void Set_GameSpy_Challenge_String(StringClass & challenge_string);
  154. void Set_GameSpy_Hash_Id(StringClass & hash_id);
  155. StringClass & Get_GameSpy_Challenge_String(void) {return GameSpyChallengeString;}
  156. StringClass & Get_GameSpy_Hash_Id(void) {return GameSpyHashId;}
  157. void Set_GameSpy_Kick_State(GAMESPY_KICK_STATE_ENUM state);
  158. GAMESPY_KICK_STATE_ENUM Get_GameSpy_Kick_State(void) const {return GameSpyKickState;}
  159. void Set_GameSpy_Kick_State_Entry_Time_Ms(DWORD time_ms);
  160. DWORD Get_GameSpy_Kick_State_Entry_Time_Ms(void) const {return GameSpyKickStateEntryTimeMs;}
  161. //
  162. // N.B. If you change the state of any of these on the server then you
  163. // need to call Mark_As_Modified.
  164. //
  165. cBoolean Invulnerable;
  166. static const int INVALID_ID;
  167. private:
  168. ~cPlayer(void); // only the cPlayerManager can destroy...
  169. void On_Create(void);
  170. void On_Destroy(void);
  171. WideStringClass Name;
  172. int Id;
  173. safe_int LadderPoints;
  174. safe_int Kills;
  175. safe_int Deaths;
  176. safe_int PlayerType;
  177. safe_int Rung;
  178. safe_int WolRank;
  179. unsigned short WOLPoints;
  180. int DamageScaleFactor;
  181. int Ping;
  182. DWORD JoinTimeMs;
  183. DWORD TotalTimeMs;
  184. ULONG IpAddress;
  185. int Fps;
  186. DWORD LastUpdateTimeMs;
  187. int FastSortKey;
  188. int NumWolGames;
  189. cBoolean IsWaitingForIntermission;
  190. //
  191. // GameSpy support
  192. //
  193. GAMESPY_AUTH_STATE_ENUM GameSpyAuthState;
  194. DWORD GameSpyAuthStateEntryTimeMs;
  195. StringClass GameSpyChallengeString;
  196. StringClass GameSpyHashId;
  197. GAMESPY_KICK_STATE_ENUM GameSpyKickState;
  198. DWORD GameSpyKickStateEntryTimeMs;
  199. //
  200. // N.B. If you change the state of any of these on the server then you
  201. // need to call Mark_As_Modified.
  202. //
  203. cBoolean IsInGame;
  204. cBoolean IsActive;
  205. unsigned long ClanID;
  206. };
  207. //-----------------------------------------------------------------------------
  208. #endif // PLAYER_H
  209. //virtual void On_Kill(int victim_id);
  210. //virtual void On_Kill(int victim_id, int victim_team);