editoronlydefinition.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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/editoronlydefinition.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 9/19/01 3:07p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "editoronlydefinition.h"
  37. #include "simpledefinitionfactory.h"
  38. #include "definitionclassids.h"
  39. #include "definitionmgr.h"
  40. #include "persistfactory.h"
  41. #include "editorchunkids.h"
  42. #include "editoronlyobjectnode.h"
  43. //////////////////////////////////////////////////////////////////////////////////
  44. // Constants
  45. //////////////////////////////////////////////////////////////////////////////////
  46. enum
  47. {
  48. CHUNKID_VARIABLES = 0x00000100,
  49. CHUNKID_BASE_CLASS = 0x00000200,
  50. };
  51. enum
  52. {
  53. VARID_MODEL_NAME = 0x01,
  54. };
  55. //////////////////////////////////////////////////////////////////////////////////
  56. //
  57. // Static factories
  58. //
  59. //////////////////////////////////////////////////////////////////////////////////
  60. DECLARE_DEFINITION_FACTORY(EditorOnlyDefinitionClass, CLASSID_EDITOR_ONLY_OBJECTS, "Editor Only Objects") _EditorOnlyObjDefFactory;
  61. SimplePersistFactoryClass<EditorOnlyDefinitionClass, CHUNKID_EDITOR_ONLY_OBJECTS_DEF> _EditorOnlyObjDefPersistFactory;
  62. //////////////////////////////////////////////////////////////////////////////////
  63. //
  64. // EditorOnlyDefinitionClass
  65. //
  66. //////////////////////////////////////////////////////////////////////////////////
  67. EditorOnlyDefinitionClass::EditorOnlyDefinitionClass (void)
  68. : DefinitionClass ()
  69. {
  70. FILENAME_PARAM (EditorOnlyDefinitionClass, ModelName, "Westwood 3D Files", ".w3d");
  71. return ;
  72. }
  73. //////////////////////////////////////////////////////////////////////////////////
  74. //
  75. // ~EditorOnlyDefinitionClass
  76. //
  77. //////////////////////////////////////////////////////////////////////////////////
  78. EditorOnlyDefinitionClass::~EditorOnlyDefinitionClass (void)
  79. {
  80. return ;
  81. }
  82. //////////////////////////////////////////////////////////////////////////////////
  83. //
  84. // Get_Factory
  85. //
  86. //////////////////////////////////////////////////////////////////////////////////
  87. const PersistFactoryClass &
  88. EditorOnlyDefinitionClass::Get_Factory (void) const
  89. {
  90. return _EditorOnlyObjDefPersistFactory;
  91. }
  92. //////////////////////////////////////////////////////////////////////////////////
  93. //
  94. // Save
  95. //
  96. //////////////////////////////////////////////////////////////////////////////////
  97. bool
  98. EditorOnlyDefinitionClass::Save (ChunkSaveClass &csave)
  99. {
  100. bool retval = true;
  101. csave.Begin_Chunk (CHUNKID_VARIABLES);
  102. retval &= Save_Variables (csave);
  103. csave.End_Chunk ();
  104. csave.Begin_Chunk (CHUNKID_BASE_CLASS);
  105. retval &= DefinitionClass::Save (csave);
  106. csave.End_Chunk ();
  107. return retval;
  108. }
  109. //////////////////////////////////////////////////////////////////////////////////
  110. //
  111. // Load
  112. //
  113. //////////////////////////////////////////////////////////////////////////////////
  114. bool
  115. EditorOnlyDefinitionClass::Load (ChunkLoadClass &cload)
  116. {
  117. bool retval = true;
  118. while (cload.Open_Chunk ()) {
  119. switch (cload.Cur_Chunk_ID ()) {
  120. case CHUNKID_VARIABLES:
  121. retval &= Load_Variables (cload);
  122. break;
  123. case CHUNKID_BASE_CLASS:
  124. retval &= DefinitionClass::Load (cload);
  125. break;
  126. }
  127. cload.Close_Chunk ();
  128. }
  129. return retval;
  130. }
  131. //////////////////////////////////////////////////////////////////////////////////
  132. //
  133. // Save_Variables
  134. //
  135. //////////////////////////////////////////////////////////////////////////////////
  136. bool
  137. EditorOnlyDefinitionClass::Save_Variables (ChunkSaveClass &csave)
  138. {
  139. bool retval = true;
  140. WRITE_MICRO_CHUNK_WWSTRING (csave, VARID_MODEL_NAME, ModelName)
  141. return retval;
  142. }
  143. //////////////////////////////////////////////////////////////////////////////////
  144. //
  145. // Load_Variables
  146. //
  147. //////////////////////////////////////////////////////////////////////////////////
  148. bool
  149. EditorOnlyDefinitionClass::Load_Variables (ChunkLoadClass &cload)
  150. {
  151. bool retval = true;
  152. //
  153. // Loop through all the microchunks that define the variables
  154. //
  155. while (cload.Open_Micro_Chunk ()) {
  156. switch (cload.Cur_Micro_Chunk_ID ()) {
  157. READ_MICRO_CHUNK_WWSTRING (cload, VARID_MODEL_NAME, ModelName)
  158. }
  159. cload.Close_Micro_Chunk ();
  160. }
  161. return retval;
  162. }
  163. //////////////////////////////////////////////////////////////////////////////////
  164. //
  165. // Create
  166. //
  167. //////////////////////////////////////////////////////////////////////////////////
  168. PersistClass *
  169. EditorOnlyDefinitionClass::Create (void) const
  170. {
  171. return new EditorOnlyObjectNodeClass ();
  172. }