TileDefinition.cpp 6.3 KB

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