DieModule.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: DieModule.cpp ////////////////////////////////////////////////////////////////////////////
  24. // Author:
  25. // Desc:
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  28. #define DEFINE_OBJECT_STATUS_NAMES
  29. #include "Common/Xfer.h"
  30. #include "GameClient/Drawable.h"
  31. #include "GameLogic/ExperienceTracker.h"
  32. #include "GameLogic/GameLogic.h"
  33. #include "GameLogic/Module/DieModule.h"
  34. #include "GameLogic/Object.h"
  35. #ifdef _INTERNAL
  36. // for occasional debugging...
  37. //#pragma optimize("", off)
  38. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  39. #endif
  40. //-------------------------------------------------------------------------------------------------
  41. DieMuxData::DieMuxData() :
  42. m_deathTypes(DEATH_TYPE_FLAGS_ALL),
  43. m_veterancyLevels(VETERANCY_LEVEL_FLAGS_ALL)
  44. {
  45. }
  46. //-------------------------------------------------------------------------------------------------
  47. const FieldParse* DieMuxData::getFieldParse()
  48. {
  49. static const FieldParse dataFieldParse[] =
  50. {
  51. { "DeathTypes", INI::parseDeathTypeFlags, NULL, offsetof( DieMuxData, m_deathTypes ) },
  52. { "VeterancyLevels", INI::parseVeterancyLevelFlags, NULL, offsetof( DieMuxData, m_veterancyLevels ) },
  53. { "ExemptStatus", ObjectStatusMaskType::parseFromINI, NULL, offsetof( DieMuxData, m_exemptStatus ) },
  54. { "RequiredStatus", ObjectStatusMaskType::parseFromINI, NULL, offsetof( DieMuxData, m_requiredStatus ) },
  55. { 0, 0, 0, 0 }
  56. };
  57. return dataFieldParse;
  58. }
  59. //-------------------------------------------------------------------------------------------------
  60. Bool DieMuxData::isDieApplicable(const Object* obj, const DamageInfo *damageInfo) const
  61. {
  62. // wrong death type? punt
  63. if (!getDeathTypeFlag(m_deathTypes, damageInfo->in.m_deathType))
  64. return false;
  65. // wrong vet level? punt
  66. if (!getVeterancyLevelFlag(m_veterancyLevels, obj->getVeterancyLevel()))
  67. return false;
  68. // all 'exempt' bits must be clear for us to run.
  69. if( m_exemptStatus.any() && obj->getStatusBits().testForAny( m_exemptStatus ) )
  70. return false;
  71. // all 'required' bits must be set for us to run.
  72. // But only if we have a required status to check
  73. if( m_requiredStatus.any() && !obj->getStatusBits().testForAll( m_requiredStatus ) )
  74. return false;
  75. return true;
  76. }
  77. // ------------------------------------------------------------------------------------------------
  78. /** CRC */
  79. // ------------------------------------------------------------------------------------------------
  80. void DieModule::crc( Xfer *xfer )
  81. {
  82. // extend base class
  83. BehaviorModule::crc( xfer );
  84. } // end crc
  85. // ------------------------------------------------------------------------------------------------
  86. /** Xfer Method */
  87. // ------------------------------------------------------------------------------------------------
  88. void DieModule::xfer( Xfer *xfer )
  89. {
  90. // version
  91. XferVersion currentVersion = 1;
  92. XferVersion version = currentVersion;
  93. xfer->xferVersion( &version, currentVersion );
  94. // call base class
  95. BehaviorModule::xfer( xfer );
  96. } // end xfer
  97. // ------------------------------------------------------------------------------------------------
  98. /** Load post process */
  99. // ------------------------------------------------------------------------------------------------
  100. void DieModule::loadPostProcess( void )
  101. {
  102. // call base class
  103. BehaviorModule::loadPostProcess();
  104. } // end loadPostProcess