networkobjectmgr.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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/wwnet/networkobjectmgr.h $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 11/24/01 10:47a $*
  29. * *
  30. * $Revision:: 14 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __NETWORKOBJECTMGR_H
  39. #define __NETWORKOBJECTMGR_H
  40. #include "vector.h"
  41. ////////////////////////////////////////////////////////////////
  42. // Forward declarations
  43. ////////////////////////////////////////////////////////////////
  44. class NetworkObjectClass;
  45. ////////////////////////////////////////////////////////////////
  46. // ID Ranges
  47. ////////////////////////////////////////////////////////////////
  48. enum
  49. {
  50. NETID_DYNAMIC_OBJECT_MIN = 1500000000, // 600M dynamic
  51. NETID_DYNAMIC_OBJECT_MAX = 2100000000,
  52. NETID_STATIC_OBJECT_MIN = 2100000001, // 10M static
  53. NETID_STATIC_OBJECT_MAX = 2110000000,
  54. NETID_CLIENT_OBJECT_MIN = 2110000001, // 100K per client, 128 clients
  55. //NETID_CLIENT_OBJECT_MAX = 2113100000,
  56. NETID_CLIENT_OBJECT_MAX = 2122800001,
  57. //
  58. // Note: INT_MAX = 2147483647
  59. //
  60. };
  61. ////////////////////////////////////////////////////////////////
  62. //
  63. // NetworkObjectMgrClass
  64. //
  65. // Container for network objects. Used for sending and receiving
  66. // object state updates.
  67. //
  68. ////////////////////////////////////////////////////////////////
  69. class NetworkObjectMgrClass
  70. {
  71. public:
  72. ////////////////////////////////////////////////////////////////
  73. // Public methods
  74. ////////////////////////////////////////////////////////////////
  75. //
  76. // Object registration
  77. //
  78. static void Register_Object (NetworkObjectClass *object);
  79. static void Unregister_Object (NetworkObjectClass *object);
  80. //
  81. // Delete registration support
  82. //
  83. static void Register_Object_For_Deletion (NetworkObjectClass *object);
  84. static void Set_Is_Level_Loading (bool onoff) { _IsLevelLoading = onoff; }
  85. //
  86. // Timestep
  87. //
  88. static void Think (void);
  89. //
  90. // Deletion support
  91. //
  92. static void Set_All_Delete_Pending (void);//TSS092301
  93. static void Delete_Pending (void);
  94. static void Delete_Client_Objects (int client_id);
  95. static void Restore_Dirty_Bits (int client_id);
  96. //
  97. // Object enumeration
  98. //
  99. static int Get_Object_Count (void) { return _ObjectList.Count (); }
  100. static NetworkObjectClass * Get_Object (int index) { return _ObjectList[index]; }
  101. static int Get_Pending_Object_Count (void) { return _DeletePendingList.Count (); }
  102. //
  103. // Object lookup
  104. //
  105. static NetworkObjectClass * Find_Object (int object_id);
  106. //
  107. // ID access
  108. //
  109. static int Get_New_Dynamic_ID (void);
  110. static int Get_Current_Dynamic_ID (void);
  111. static void Set_New_Dynamic_ID (int id);
  112. static void Init_New_Client_ID (int client_id);
  113. static int Get_New_Client_ID (void);
  114. static void Reset_Import_State_Counts(void);
  115. private:
  116. ////////////////////////////////////////////////////////////////
  117. // Private methods
  118. ////////////////////////////////////////////////////////////////
  119. static bool Find_Object (int id_to_find, int *index);
  120. ////////////////////////////////////////////////////////////////
  121. // Private tyepdefs
  122. ////////////////////////////////////////////////////////////////
  123. typedef DynamicVectorClass<NetworkObjectClass *> OBJECT_LIST;
  124. ////////////////////////////////////////////////////////////////
  125. // Private member data
  126. ////////////////////////////////////////////////////////////////
  127. static OBJECT_LIST _ObjectList;
  128. static OBJECT_LIST _DeletePendingList;
  129. static int _NewDynamicID;
  130. static int _NewClientID;
  131. static bool _IsLevelLoading;
  132. };
  133. #endif // __NETWORKOBJECTMGR_H