ObjectHelper.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: ObjectHelper.cpp /////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, Steven Johnson, September 2002
  25. // Desc: Object helper module base class
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h"
  29. #include "Common/Xfer.h"
  30. #include "GameLogic/GameLogic.h"
  31. #include "GameLogic/Object.h"
  32. #include "GameLogic/Module/ObjectHelper.h"
  33. #ifdef _INTERNAL
  34. // for occasional debugging...
  35. //#pragma optimize("", off)
  36. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  37. #endif
  38. // ------------------------------------------------------------------------------------------------
  39. // ------------------------------------------------------------------------------------------------
  40. ObjectHelper::~ObjectHelper( void )
  41. {
  42. } // end ~ObjectHelper
  43. // ------------------------------------------------------------------------------------------------
  44. // ------------------------------------------------------------------------------------------------
  45. void ObjectHelper::sleepUntil(UnsignedInt when)
  46. {
  47. if( getObject()->getStatusBits().test( OBJECT_STATUS_DESTROYED ) )
  48. return;
  49. // note the setWakeFrame(NEVER) actually awakens immediately, since NEVER==0.
  50. // when we get NEVER in this case, we really want to sleep forever.
  51. // so just special case it.
  52. UpdateSleepTime wakeDelay = (when == NEVER || when == FOREVER) ?
  53. UPDATE_SLEEP_FOREVER :
  54. UPDATE_SLEEP(when - TheGameLogic->getFrame());
  55. setWakeFrame(getObject(), wakeDelay);
  56. }
  57. // ------------------------------------------------------------------------------------------------
  58. /** CRC */
  59. // ------------------------------------------------------------------------------------------------
  60. void ObjectHelper::crc( Xfer *xfer )
  61. {
  62. // update module crc
  63. UpdateModule::crc( xfer );
  64. } // end crc
  65. // ------------------------------------------------------------------------------------------------
  66. /* Xfer method
  67. * Version Info:
  68. * 1: Initial Version */
  69. // ------------------------------------------------------------------------------------------------
  70. void ObjectHelper::xfer( Xfer *xfer )
  71. {
  72. // version
  73. XferVersion currentVersion = 1;
  74. XferVersion version = currentVersion;
  75. xfer->xferVersion( &version, currentVersion );
  76. // update module xfer
  77. UpdateModule::xfer( xfer );
  78. } // end xfer
  79. // ------------------------------------------------------------------------------------------------
  80. /** Load post process */
  81. // ------------------------------------------------------------------------------------------------
  82. void ObjectHelper::loadPostProcess( void )
  83. {
  84. // update module post process
  85. UpdateModule::loadPostProcess();
  86. } // end loadPostProcess