NodeMgr.H 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/NodeMgr.H $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 5/11/01 9:41a $*
  29. * *
  30. * $Revision:: 32 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __NODEMGR_H
  39. #define __NODEMGR_H
  40. #include "saveloadsubsystem.h"
  41. #include "vector.h"
  42. #include "bittype.h"
  43. #include "nodetypes.h"
  44. #include "listtypes.h"
  45. //////////////////////////////////////////////////////////////////////////
  46. // Forward declarations
  47. //////////////////////////////////////////////////////////////////////////
  48. class NodeClass;
  49. class PresetClass;
  50. class ChunkLoadClass;
  51. class ChunkSaveClass;
  52. //////////////////////////////////////////////////////////////////////////
  53. // Singleton instance
  54. //////////////////////////////////////////////////////////////////////////
  55. extern class NodeMgrClass _TheNodeMgr;
  56. //////////////////////////////////////////////////////////////////////////
  57. //
  58. // NodeMgrClass
  59. //
  60. //////////////////////////////////////////////////////////////////////////
  61. class NodeMgrClass : public SaveLoadSubSystemClass
  62. {
  63. public:
  64. //////////////////////////////////////////////////////////////
  65. // Public constructors/destructors
  66. //////////////////////////////////////////////////////////////
  67. NodeMgrClass (void) { }
  68. virtual ~NodeMgrClass (void);
  69. //////////////////////////////////////////////////////////////
  70. // Public methods
  71. //////////////////////////////////////////////////////////////
  72. // From SaveLoadSubSystemClass
  73. virtual uint32 Chunk_ID (void) const;
  74. virtual void On_Post_Load (void);
  75. virtual const char * Name (void) const { return "NodeMgrClass"; }
  76. // List management
  77. static NodeClass * Create_Node (PresetClass *preset, uint32 id);
  78. static void Add_Node (NodeClass *node);
  79. static void Remove_Node (NodeClass *node);
  80. static void Free_Nodes (void);
  81. static void Reload_Nodes (void);
  82. static void Reload_Nodes (PresetClass *preset);
  83. // Enumeration
  84. static NodeClass * Find_Node (uint32 id);
  85. static NodeClass * Find_Node (const char *name);
  86. static NodeClass * Get_First (void);
  87. static NodeClass * Get_First (NODE_TYPE type);
  88. static NodeClass * Get_First (PresetClass *preset);
  89. static NodeClass * Find_First (uint32 class_id);
  90. static NodeClass * Get_Next (NodeClass *current);
  91. static NodeClass * Get_Next (NodeClass *current, NODE_TYPE type);
  92. static NodeClass * Get_Next (NodeClass *current, PresetClass *preset);
  93. static NodeClass * Find_Next (NodeClass *current, uint32 class_id);
  94. // Identification
  95. static void Reset_New_ID (void);
  96. static uint32 Get_Node_ID (NODE_TYPE type);
  97. static uint32 Get_Max_Used_ID (void);
  98. static void Setup_Node_Identity (NodeClass &node);
  99. static bool Verify_Unique_ID(uint32 id);
  100. static void Build_ID_Collision_List (NODE_LIST &node_list);
  101. static void Build_Unimportant_ID_Collision_List (NODE_LIST &node_list);
  102. static void Get_ID_Range (NODE_TYPE type, uint32 *min_id, uint32 *max_id);
  103. static uint32 Find_Max_Used_ID (NODE_TYPE type);
  104. static void Put_Objects_Back (const NODE_LIST &dynamic_obj_list);
  105. static void Remove_Dynamic_Objects (NODE_LIST &dynamic_obj_list);
  106. static void Remove_Static_Objects (NODE_LIST &dynamic_obj_list);
  107. // StaticAnimPhys control
  108. static void Make_Static_Anim_Phys_Collideable (bool onoff);
  109. // Complete node access
  110. static void Build_Full_Node_List (DynamicVectorClass<NodeClass *> &node_list);
  111. static void Add_Nodes_To_List (DynamicVectorClass<NodeClass *> &node_list, NodeClass *node);
  112. //
  113. // Save/load support
  114. //
  115. static bool Save_Node_List (ChunkSaveClass &csave, NODE_LIST &node_list);
  116. static bool Load_Node_List (ChunkLoadClass &cload, NODE_LIST &node_list);
  117. //
  118. // Embedded node support
  119. //
  120. static void Create_All_Embedded_Nodes (void);
  121. protected:
  122. //////////////////////////////////////////////////////////////
  123. // Protected methods
  124. //////////////////////////////////////////////////////////////
  125. virtual bool Contains_Data(void) const;
  126. virtual bool Save (ChunkSaveClass &csave);
  127. virtual bool Load (ChunkLoadClass &cload);
  128. bool Save_Nodes (ChunkSaveClass &csave);
  129. bool Load_Nodes (ChunkLoadClass &cload);
  130. bool Load_Variables (ChunkLoadClass &cload);
  131. private:
  132. /////////////////////////////////////////////////////////////////////
  133. // Private methods
  134. /////////////////////////////////////////////////////////////////////
  135. static void Link_Node (NodeClass *node);
  136. static void Unlink_Node (NodeClass *node);
  137. /////////////////////////////////////////////////////////////////////
  138. // Static member data
  139. /////////////////////////////////////////////////////////////////////
  140. static NodeClass * _NodeListHead;
  141. static uint32 _NextObjectNodeID;
  142. static uint32 _NextStaticNodeID;
  143. static uint32 _NextLightNodeID;
  144. static uint32 _NextMiscNodeID;
  145. };
  146. /////////////////////////////////////////////////////////////////////
  147. // Get_First
  148. /////////////////////////////////////////////////////////////////////
  149. inline NodeClass *
  150. NodeMgrClass::Get_First (void)
  151. {
  152. return _NodeListHead;
  153. }
  154. #endif //__NODEMGR_H