PowerPlantUpdate.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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: PowerPlantUpdate.cpp //////////////////////////////////////////////////////////////////////////
  24. // Author: Amit Kumar, August 2002
  25. // Desc: Updating the power plant
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/ModelState.h"
  30. #include "Common/Xfer.h"
  31. #include "GameClient/Drawable.h"
  32. #include "GameClient/InGameUI.h"
  33. #include "GameLogic/GameLogic.h"
  34. #include "GameLogic/Object.h"
  35. #include "GameLogic/Module/PowerPlantUpdate.h"
  36. #ifdef _INTERNAL
  37. // for occasional debugging...
  38. //#pragma optimize("", off)
  39. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  40. #endif
  41. //-------------------------------------------------------------------------------------------------
  42. //-------------------------------------------------------------------------------------------------
  43. PowerPlantUpdateModuleData::PowerPlantUpdateModuleData( void )
  44. {
  45. m_rodsExtendTime = 0;
  46. } // end PowerPlantUpdateModuleData
  47. ///////////////////////////////////////////////////////////////////////////////////////////////////
  48. ///////////////////////////////////////////////////////////////////////////////////////////////////
  49. ///////////////////////////////////////////////////////////////////////////////////////////////////
  50. //-------------------------------------------------------------------------------------------------
  51. //-------------------------------------------------------------------------------------------------
  52. PowerPlantUpdate::PowerPlantUpdate( Thing *thing, const ModuleData *moduleData )
  53. : UpdateModule( thing, moduleData )
  54. {
  55. m_extended = FALSE;
  56. setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
  57. } // end PowerPlantUpdate
  58. //-------------------------------------------------------------------------------------------------
  59. //-------------------------------------------------------------------------------------------------
  60. PowerPlantUpdate::~PowerPlantUpdate( void )
  61. {
  62. } // end PowerPlantUpdate
  63. //-------------------------------------------------------------------------------------------------
  64. //-------------------------------------------------------------------------------------------------
  65. void PowerPlantUpdate::extendRods( Bool extend )
  66. {
  67. if (extend)
  68. {
  69. if (!m_extended)
  70. {
  71. const PowerPlantUpdateModuleData *modData = getPowerPlantUpdateModuleData();
  72. // set the model condition for radar extension
  73. Drawable *draw = getObject()->getDrawable();
  74. if( draw )
  75. draw->setModelConditionState( MODELCONDITION_POWER_PLANT_UPGRADING );
  76. m_extended = TRUE;
  77. setWakeFrame(getObject(), UPDATE_SLEEP(modData->m_rodsExtendTime));
  78. }
  79. }
  80. else
  81. {
  82. // they de-extend instantly.
  83. Drawable *draw = getObject()->getDrawable();
  84. if( draw )
  85. draw->clearModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_POWER_PLANT_UPGRADING,
  86. MODELCONDITION_POWER_PLANT_UPGRADED) );
  87. m_extended = FALSE;
  88. setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
  89. }
  90. } // end PowerPlantUpdate
  91. //-------------------------------------------------------------------------------------------------
  92. //-------------------------------------------------------------------------------------------------
  93. UpdateSleepTime PowerPlantUpdate::update( void )
  94. {
  95. // remove the extending condition and set the extened condition
  96. Drawable *draw = getObject()->getDrawable();
  97. if( draw )
  98. draw->clearAndSetModelConditionState( MODELCONDITION_POWER_PLANT_UPGRADING,
  99. MODELCONDITION_POWER_PLANT_UPGRADED );
  100. m_extended = TRUE;
  101. return UPDATE_SLEEP_FOREVER;
  102. } // end update
  103. // ------------------------------------------------------------------------------------------------
  104. /** CRC */
  105. // ------------------------------------------------------------------------------------------------
  106. void PowerPlantUpdate::crc( Xfer *xfer )
  107. {
  108. // extend base class
  109. UpdateModule::crc( xfer );
  110. } // end crc
  111. // ------------------------------------------------------------------------------------------------
  112. /** Xfer method
  113. * Version Info:
  114. * 1: Initial version */
  115. // ------------------------------------------------------------------------------------------------
  116. void PowerPlantUpdate::xfer( Xfer *xfer )
  117. {
  118. // version
  119. XferVersion currentVersion = 1;
  120. XferVersion version = currentVersion;
  121. xfer->xferVersion( &version, currentVersion );
  122. // extend base class
  123. UpdateModule::xfer( xfer );
  124. // extend complete
  125. xfer->xferBool( &m_extended );
  126. } // end xfer
  127. // ------------------------------------------------------------------------------------------------
  128. /** Load post process */
  129. // ------------------------------------------------------------------------------------------------
  130. void PowerPlantUpdate::loadPostProcess( void )
  131. {
  132. // extend base class
  133. UpdateModule::loadPostProcess();
  134. } // end loadPostProcess