physstaticsavesystem.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/physstaticsavesystem.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 11/29/00 3:58p $*
  29. * *
  30. * $Revision:: 9 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "physstaticsavesystem.h"
  36. #include "wwphysids.h"
  37. #include "pscene.h"
  38. #include "pathfind.h"
  39. #include "chunkio.h"
  40. #include "wwmemlog.h"
  41. #include "saveload.h"
  42. #include "rendobj.h"
  43. #include "phys.h"
  44. /*
  45. ** Instantiate the Physics Static-Data-Save-Systems
  46. */
  47. PhysStaticDataSaveSystemClass _PhysStaticDataSaveSystem;
  48. PhysStaticObjectsSaveSystemClass _PhysStaticObjectsSaveSystem;
  49. /**************************************************************************************
  50. **
  51. ** PhysStaticDataSaveSystemClass Implementation
  52. **
  53. **************************************************************************************/
  54. uint32 PhysStaticDataSaveSystemClass::Chunk_ID(void) const
  55. {
  56. return PHYSICS_CHUNKID_STATIC_DATA_SUBSYSTEM;
  57. }
  58. bool PhysStaticDataSaveSystemClass::Save(ChunkSaveClass &csave)
  59. {
  60. WWMEMLOG(MEM_GAMEDATA);
  61. csave.Begin_Chunk(PSDSSC_CHUNKID_SCENE);
  62. PhysicsSceneClass::Get_Instance()->Save_Level_Static_Data(csave);
  63. csave.End_Chunk();
  64. csave.Begin_Chunk(PSDSSC_CHUNKID_PATHFIND);
  65. PathfindClass::Get_Instance()->Save(csave);
  66. csave.End_Chunk();
  67. return true;
  68. }
  69. bool PhysStaticDataSaveSystemClass::Load(ChunkLoadClass &cload)
  70. {
  71. WWMEMLOG(MEM_GAMEDATA);
  72. while (cload.Open_Chunk()) {
  73. switch (cload.Cur_Chunk_ID())
  74. {
  75. case PSDSSC_CHUNKID_SCENE:
  76. PhysicsSceneClass::Get_Instance()->Load_Level_Static_Data(cload);
  77. break;
  78. case PSDSSC_CHUNKID_PATHFIND:
  79. PathfindClass::Get_Instance()->Load(cload);
  80. break;
  81. }
  82. cload.Close_Chunk();
  83. }
  84. SaveLoadSystemClass::Register_Post_Load_Callback(this);
  85. return true;
  86. }
  87. void PhysStaticDataSaveSystemClass::On_Post_Load(void)
  88. {
  89. PhysicsSceneClass::Get_Instance()->Post_Load_Level_Static_Data();
  90. //PathfindClass::Get_Instance()->On_Post_Load();
  91. }
  92. /**************************************************************************************
  93. **
  94. ** PhysStaticObjectsSaveSystemClass Implementation
  95. **
  96. **************************************************************************************/
  97. uint32 PhysStaticObjectsSaveSystemClass::Chunk_ID(void) const
  98. {
  99. return PHYSICS_CHUNKID_STATIC_OBJECTS_SUBSYSTEM;
  100. }
  101. bool PhysStaticObjectsSaveSystemClass::Save(ChunkSaveClass &csave)
  102. {
  103. csave.Begin_Chunk(PSOSSC_CHUNKID_SCENE);
  104. PhysicsSceneClass::Get_Instance()->Save_Level_Static_Objects(csave);
  105. csave.End_Chunk();
  106. return true;
  107. }
  108. bool PhysStaticObjectsSaveSystemClass::Load(ChunkLoadClass &cload)
  109. {
  110. while (cload.Open_Chunk()) {
  111. switch (cload.Cur_Chunk_ID())
  112. {
  113. case PSOSSC_CHUNKID_SCENE:
  114. PhysicsSceneClass::Get_Instance()->Load_Level_Static_Objects(cload);
  115. break;
  116. }
  117. cload.Close_Chunk();
  118. }
  119. return true;
  120. }
  121. void PhysStaticObjectsSaveSystemClass::On_Post_Load(void)
  122. {
  123. PhysicsSceneClass::Get_Instance()->Post_Load_Level_Static_Objects();
  124. }