DieModule.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. ** Command & Conquer Generals(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. m_exemptStatus(OBJECT_STATUS_NONE),
  45. m_requiredStatus(OBJECT_STATUS_NONE)
  46. {
  47. }
  48. //-------------------------------------------------------------------------------------------------
  49. const FieldParse* DieMuxData::getFieldParse()
  50. {
  51. static const FieldParse dataFieldParse[] =
  52. {
  53. { "DeathTypes", INI::parseDeathTypeFlags, NULL, offsetof( DieMuxData, m_deathTypes ) },
  54. { "VeterancyLevels", INI::parseVeterancyLevelFlags, NULL, offsetof( DieMuxData, m_veterancyLevels ) },
  55. { "ExemptStatus", INI::parseBitString32, TheObjectStatusBitNames, offsetof( DieMuxData, m_exemptStatus ) },
  56. { "RequiredStatus", INI::parseBitString32, TheObjectStatusBitNames, offsetof( DieMuxData, m_requiredStatus ) },
  57. { 0, 0, 0, 0 }
  58. };
  59. return dataFieldParse;
  60. }
  61. //-------------------------------------------------------------------------------------------------
  62. Bool DieMuxData::isDieApplicable(const Object* obj, const DamageInfo *damageInfo) const
  63. {
  64. // wrong death type? punt
  65. if (!getDeathTypeFlag(m_deathTypes, damageInfo->in.m_deathType))
  66. return false;
  67. // wrong vet level? punt
  68. if (!getVeterancyLevelFlag(m_veterancyLevels, obj->getVeterancyLevel()))
  69. return false;
  70. // all 'exempt' bits must be clear for us to run.
  71. if ((obj->getStatusBits() & m_exemptStatus) != 0)
  72. return false;
  73. // all 'required' bits must be set for us to run.
  74. if ((obj->getStatusBits() & m_requiredStatus) != m_requiredStatus)
  75. return false;
  76. return true;
  77. }
  78. // ------------------------------------------------------------------------------------------------
  79. /** CRC */
  80. // ------------------------------------------------------------------------------------------------
  81. void DieModule::crc( Xfer *xfer )
  82. {
  83. // extend base class
  84. BehaviorModule::crc( xfer );
  85. } // end crc
  86. // ------------------------------------------------------------------------------------------------
  87. /** Xfer Method */
  88. // ------------------------------------------------------------------------------------------------
  89. void DieModule::xfer( Xfer *xfer )
  90. {
  91. // version
  92. XferVersion currentVersion = 1;
  93. XferVersion version = currentVersion;
  94. xfer->xferVersion( &version, currentVersion );
  95. // call base class
  96. BehaviorModule::xfer( xfer );
  97. } // end xfer
  98. // ------------------------------------------------------------------------------------------------
  99. /** Load post process */
  100. // ------------------------------------------------------------------------------------------------
  101. void DieModule::loadPostProcess( void )
  102. {
  103. // call base class
  104. BehaviorModule::loadPostProcess();
  105. } // end loadPostProcess