Damage.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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: Damage.cpp ///////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, September 2002
  25. // Desc: Basic structures for the damage process
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h"
  29. #include "Common/Xfer.h"
  30. #include "GameLogic/Damage.h"
  31. ///////////////////////////////////////////////////////////////////////////////////////////////////
  32. ///////////////////////////////////////////////////////////////////////////////////////////////////
  33. ///////////////////////////////////////////////////////////////////////////////////////////////////
  34. // ------------------------------------------------------------------------------------------------
  35. /** Xfer method
  36. * Version Info:
  37. * 1: Initial version */
  38. // ------------------------------------------------------------------------------------------------
  39. void DamageInfo::xfer( Xfer *xfer )
  40. {
  41. // version
  42. XferVersion currentVersion = 1;
  43. XferVersion version = currentVersion;
  44. xfer->xferVersion( &version, currentVersion );
  45. // xfer input
  46. xfer->xferSnapshot( &in );
  47. // xfer output
  48. xfer->xferSnapshot( &out );
  49. } // end xfer
  50. // ------------------------------------------------------------------------------------------------
  51. /** Xfer method
  52. * Version Info:
  53. * 1: Initial version */
  54. // ------------------------------------------------------------------------------------------------
  55. void DamageInfoInput::xfer( Xfer *xfer )
  56. {
  57. // version
  58. XferVersion currentVersion = 1;
  59. XferVersion version = currentVersion;
  60. xfer->xferVersion( &version, currentVersion );
  61. // source id
  62. xfer->xferObjectID( &m_sourceID );
  63. // source player mask
  64. xfer->xferUser( &m_sourcePlayerMask, sizeof( PlayerMaskType ) );
  65. // damage type
  66. xfer->xferUser( &m_damageType, sizeof( DamageType ) );
  67. // death type
  68. xfer->xferUser( &m_deathType, sizeof( DeathType ) );
  69. // amount
  70. xfer->xferReal( &m_amount );
  71. } // end xfer
  72. // ------------------------------------------------------------------------------------------------
  73. /** Xfer method
  74. * Version Info:
  75. * 1: Initial version */
  76. // ------------------------------------------------------------------------------------------------
  77. void DamageInfoOutput::xfer( Xfer *xfer )
  78. {
  79. // version
  80. XferVersion currentVersion = 1;
  81. XferVersion version = currentVersion;
  82. xfer->xferVersion( &version, currentVersion );
  83. // actual damage
  84. xfer->xferReal( &m_actualDamageDealt );
  85. // damage clipped
  86. xfer->xferReal( &m_actualDamageClipped );
  87. // no effect
  88. xfer->xferBool( &m_noEffect );
  89. } // end xfer