playermanager.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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/playermanager.h $*
  25. * *
  26. * $Author:: Denzil_l $*
  27. * *
  28. * $Modtime:: 2/27/02 5:51p $*
  29. * *
  30. * $Revision:: 46 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSV_VER)
  36. #pragma once
  37. #endif
  38. #ifndef PLAYERMANAGER_H
  39. #define PLAYERMANAGER_H
  40. #include "vector3.h"
  41. #include "bittype.h"
  42. #include "slist.h"
  43. #include "player.h"
  44. #include "wwstring.h"
  45. #include "widestring.h"
  46. #include <WWLib\Notify.h>
  47. static const int PLAYER_ID_UNKNOWN = -99999;
  48. static const int MAX_PLAYERS = 255;
  49. class ChunkSaveClass;
  50. class ChunkLoadClass;
  51. class Render2DTextClass;
  52. class Font3DInstanceClass;
  53. typedef enum {PLAYER_ADDED, PLAYER_REMOVED, PLAYER_DEACTIVATED, PLAYER_ACTIVATED} PLAYERMGR_ACTION;
  54. typedef TypedActionPtr<PLAYERMGR_ACTION, cPlayer> PlayerMgrEvent;
  55. //-----------------------------------------------------------------------------
  56. class cPlayerManager {
  57. public:
  58. static void Onetime_Init(void);
  59. static void Onetime_Shutdown(void);
  60. static void Think(void);
  61. static void Render(void);
  62. static bool Save(ChunkSaveClass & csave);
  63. static bool Load(ChunkLoadClass & cload);
  64. static void Reset_Players(void);
  65. static void Remove_All(void); // N.B. destructive
  66. static int Tally_Team_Size(int type);
  67. static bool Is_Kill_Treasonous(cPlayer * p_killer, cPlayer * p_victim);
  68. static void Sort_Players(bool fast_sort);
  69. //static int Get_Leaders_Id(void);
  70. static cPlayer * Find_Player(int id);
  71. static cPlayer * Find_Player(const WideStringClass & name);
  72. static cPlayer * Find_Inactive_Player(const WideStringClass & name);
  73. static cPlayer * Find_Team_Player(int team_number);
  74. static cPlayer * Find_Random_Team_Player(int team_number);
  75. static cPlayer * Find_Team_Mate(cPlayer * p_player);
  76. static cPlayer* Find_Clan_Mate(cPlayer* player);
  77. static bool Is_Player_Present(int id);
  78. static bool Is_Player_Present(WideStringClass & name);
  79. static const WideStringClass &Get_Player_Name(int id);
  80. static SList<cPlayer> * Get_Player_Object_List(void) {return &PlayerList;}
  81. static void Add(cPlayer * p_player);
  82. static void Remove(cPlayer * p_player); // N.B. destructive
  83. static int Count(void);
  84. static void Deactivated(cPlayer* p_player);
  85. static void Activated(cPlayer* p_player);
  86. static void Compute_Ladder_Points(int winner_id);
  87. static WideStringClass Determine_Mvp_Name(void);
  88. static void Increment_Player_Times(void);
  89. static int Compute_Full_Player_List_Height(void);
  90. static int Get_Average_Ladder_Points(void);
  91. static unsigned short Get_Average_WOL_Points(void);
  92. static int Get_Average_Games_Played(void);
  93. static int Get_Average_Ping(void);
  94. static int Get_Average_FPS(void);
  95. static void Log_Player_List(void);
  96. static void Add_Event_Observer(Observer<PlayerMgrEvent>& observer)
  97. {mNotifier.AddObserver(observer);}
  98. private:
  99. static void Render_Player_List(void);
  100. static int Player_Compare(const void * elem1, const void * elem2);
  101. static int Fast_Player_Compare(const void * elem1, const void * elem2);
  102. static void List_Print(WideStringClass & text, Vector3 color);
  103. static void Line(float x, float length, int line_color);
  104. static void Construct_Heading(WideStringClass & heading, bool force_verbose = false);
  105. //static int Get_Ranked_Id(int rank);
  106. static void Remove_Inactive(void);
  107. static int Compute_Fast_Sort_Key(cPlayer * player);
  108. static SList<cPlayer> PlayerList;
  109. static cPlayer * Player_Array[MAX_PLAYERS];
  110. static Render2DTextClass * PTextRenderer;
  111. static Font3DInstanceClass * PFont;
  112. static const float Y_INCREMENT_FACTOR;
  113. static int XPos;
  114. static int YPos;
  115. static Notifier<PlayerMgrEvent> mNotifier;
  116. };
  117. //-----------------------------------------------------------------------------
  118. #endif // PLAYERMANAGER_H