PathfindStartDefinition.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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/PathfindStartDefinition.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 11/14/99 4:26p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "pathfindstartdefinition.h"
  37. #include "simpledefinitionfactory.h"
  38. #include "definitionclassids.h"
  39. #include "definitionmgr.h"
  40. #include "persistfactory.h"
  41. #include "editorchunkids.h"
  42. #include "pathfindstartnode.h"
  43. //////////////////////////////////////////////////////////////////////////////////
  44. // Constants
  45. //////////////////////////////////////////////////////////////////////////////////
  46. enum
  47. {
  48. CHUNKID_VARIABLES = 0x00000100,
  49. CHUNKID_BASE_CLASS = 0x00000200,
  50. };
  51. enum
  52. {
  53. VARID_GAME_OBJ_ID = 0x01
  54. };
  55. //////////////////////////////////////////////////////////////////////////////////
  56. //
  57. // Static factories
  58. //
  59. //////////////////////////////////////////////////////////////////////////////////
  60. DECLARE_DEFINITION_FACTORY(PathfindStartDefinitionClass, CLASSID_PATHFIND_START_DEF, "Pathfind Generator") _PathfindStartDefFactory;
  61. SimplePersistFactoryClass<PathfindStartDefinitionClass, CHUNKID_PATHFIND_START_DEF> _PathfindStartPersistFactory;
  62. //////////////////////////////////////////////////////////////////////////////////
  63. //
  64. // PathfindStartDefinitionClass
  65. //
  66. //////////////////////////////////////////////////////////////////////////////////
  67. PathfindStartDefinitionClass::PathfindStartDefinitionClass (void)
  68. : m_GameObjectID (0),
  69. DefinitionClass ()
  70. {
  71. EDITABLE_PARAM( PathfindStartDefinitionClass, ParameterClass::TYPE_GAMEOBJDEFINITIONID, m_GameObjectID );
  72. return ;
  73. }
  74. //////////////////////////////////////////////////////////////////////////////////
  75. //
  76. // ~PathfindStartDefinitionClass
  77. //
  78. //////////////////////////////////////////////////////////////////////////////////
  79. PathfindStartDefinitionClass::~PathfindStartDefinitionClass (void)
  80. {
  81. return ;
  82. }
  83. //////////////////////////////////////////////////////////////////////////////////
  84. //
  85. // Get_Factory
  86. //
  87. //////////////////////////////////////////////////////////////////////////////////
  88. const PersistFactoryClass &
  89. PathfindStartDefinitionClass::Get_Factory (void) const
  90. {
  91. return _PathfindStartPersistFactory;
  92. }
  93. //////////////////////////////////////////////////////////////////////////////////
  94. //
  95. // Save
  96. //
  97. //////////////////////////////////////////////////////////////////////////////////
  98. bool
  99. PathfindStartDefinitionClass::Save (ChunkSaveClass &csave)
  100. {
  101. bool retval = true;
  102. csave.Begin_Chunk (CHUNKID_BASE_CLASS);
  103. retval &= DefinitionClass::Save (csave);
  104. csave.End_Chunk ();
  105. csave.Begin_Chunk (CHUNKID_VARIABLES);
  106. WRITE_MICRO_CHUNK (csave, VARID_GAME_OBJ_ID, m_GameObjectID);
  107. csave.End_Chunk ();
  108. return retval;
  109. }
  110. //////////////////////////////////////////////////////////////////////////////////
  111. //
  112. // Load
  113. //
  114. //////////////////////////////////////////////////////////////////////////////////
  115. bool
  116. PathfindStartDefinitionClass::Load (ChunkLoadClass &cload)
  117. {
  118. bool retval = true;
  119. while (cload.Open_Chunk ()) {
  120. switch (cload.Cur_Chunk_ID ()) {
  121. case CHUNKID_BASE_CLASS:
  122. retval &= DefinitionClass::Load (cload);
  123. break;
  124. case CHUNKID_VARIABLES:
  125. retval &= Load_Variables (cload);
  126. break;
  127. }
  128. cload.Close_Chunk ();
  129. }
  130. return retval;
  131. }
  132. ///////////////////////////////////////////////////////////////////////
  133. //
  134. // Load_Variables
  135. //
  136. ///////////////////////////////////////////////////////////////////////
  137. bool
  138. PathfindStartDefinitionClass::Load_Variables (ChunkLoadClass &cload)
  139. {
  140. //
  141. // Loop through all the microchunks that define the variables
  142. //
  143. while (cload.Open_Micro_Chunk ()) {
  144. switch (cload.Cur_Micro_Chunk_ID ()) {
  145. READ_MICRO_CHUNK (cload, VARID_GAME_OBJ_ID, m_GameObjectID);
  146. }
  147. cload.Close_Micro_Chunk ();
  148. }
  149. return true;
  150. }
  151. //////////////////////////////////////////////////////////////////////////////////
  152. //
  153. // Create
  154. //
  155. //////////////////////////////////////////////////////////////////////////////////
  156. PersistClass *
  157. PathfindStartDefinitionClass::Create (void) const
  158. {
  159. return new PathfindStartNodeClass ();
  160. }