gameobjobserver.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/gameobjobserver.cpp $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 9/18/00 3:10p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "gameobjobserver.h"
  36. #include "simplevec.h"
  37. #include "chunkio.h"
  38. #include "debug.h"
  39. SimpleDynVecClass<GameObjObserverClass *> PendingDeleteList;
  40. int GameObjObserverManager::NextID = 8000000;
  41. void GameObjObserverManager::Delete_Register( GameObjObserverClass * observer )
  42. {
  43. PendingDeleteList.Add( observer );
  44. }
  45. void GameObjObserverManager::Delete_Pending( void )
  46. {
  47. while ( PendingDeleteList.Count() ) {
  48. delete PendingDeleteList[0];
  49. PendingDeleteList.Delete( 0 );
  50. }
  51. }
  52. /*
  53. **
  54. */
  55. enum {
  56. CHUNKID_VARIABLES = 918001455,
  57. MICROCHUNKID_NEXT_ID = 1,
  58. };
  59. bool GameObjObserverManager::Save( ChunkSaveClass & csave )
  60. {
  61. csave.Begin_Chunk( CHUNKID_VARIABLES );
  62. WRITE_MICRO_CHUNK( csave, MICROCHUNKID_NEXT_ID, NextID );
  63. csave.End_Chunk();
  64. return true;
  65. }
  66. bool GameObjObserverManager::Load( ChunkLoadClass & cload )
  67. {
  68. while (cload.Open_Chunk()) {
  69. switch(cload.Cur_Chunk_ID()) {
  70. case CHUNKID_VARIABLES:
  71. while (cload.Open_Micro_Chunk()) {
  72. switch(cload.Cur_Micro_Chunk_ID()) {
  73. READ_MICRO_CHUNK( cload, MICROCHUNKID_NEXT_ID, NextID );
  74. default:
  75. Debug_Say(("Unhandled Variable Chunk:%d File:%s Line:%d\r\n",cload.Cur_Chunk_ID(),__FILE__,__LINE__));
  76. break;
  77. }
  78. cload.Close_Micro_Chunk();
  79. }
  80. break;
  81. default:
  82. Debug_Say(("Unhandled Chunk:%d File:%s Line:%d\r\n",cload.Cur_Chunk_ID(),__FILE__,__LINE__));
  83. break;
  84. }
  85. cload.Close_Chunk();
  86. }
  87. return true;
  88. }