CleanupAreaPower.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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: CleanupAreaPower.cpp /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Created: September 2002
  34. //
  35. // Author: Kris Morness
  36. //
  37. // Makes use of the cleanup hazard update by augmenting the cleanup range
  38. // until there is nothing left to cleanup at which time it goes idle.
  39. //-----------------------------------------------------------------------------
  40. ///////////////////////////////////////////////////////////////////////////////
  41. //-----------------------------------------------------------------------------
  42. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  43. #include "Common/Player.h"
  44. #include "Common/ThingTemplate.h"
  45. #include "Common/Xfer.h"
  46. #include "GameLogic/Module/CleanupAreaPower.h"
  47. #include "GameLogic/Module/CleanupHazardUpdate.h"
  48. #include "GameLogic/Object.h"
  49. //-------------------------------------------------------------------------------------------------
  50. CleanupAreaPowerModuleData::CleanupAreaPowerModuleData()
  51. {
  52. m_cleanupMoveRange = 0.0;
  53. }
  54. //-------------------------------------------------------------------------------------------------
  55. void CleanupAreaPowerModuleData::buildFieldParse(MultiIniFieldParse& p)
  56. {
  57. SpecialPowerModuleData::buildFieldParse( p );
  58. static const FieldParse dataFieldParse[] =
  59. {
  60. { "MaxMoveDistanceFromLocation", INI::parseReal, NULL, offsetof( CleanupAreaPowerModuleData, m_cleanupMoveRange ) },
  61. { 0, 0, 0, 0 }
  62. };
  63. p.add(dataFieldParse);
  64. } // end buildFieldParse
  65. //-------------------------------------------------------------------------------------------------
  66. CleanupAreaPower::CleanupAreaPower( Thing *thing, const ModuleData* moduleData ) : SpecialPowerModule( thing, moduleData )
  67. {
  68. }
  69. //-------------------------------------------------------------------------------------------------
  70. CleanupAreaPower::~CleanupAreaPower()
  71. {
  72. }
  73. //-------------------------------------------------------------------------------------------------
  74. void CleanupAreaPower::doSpecialPowerAtLocation( const Coord3D *loc, UnsignedInt commandOptions )
  75. {
  76. if (getObject()->isDisabled())
  77. return;
  78. Object *obj = getObject();
  79. const CleanupAreaPowerModuleData *data = getCleanupAreaPowerModuleData();
  80. static NameKeyType key_CleanupHazardUpdate = NAMEKEY( "CleanupHazardUpdate" );
  81. CleanupHazardUpdate *update = (CleanupHazardUpdate*)obj->findUpdateModule( key_CleanupHazardUpdate );
  82. if( update )
  83. {
  84. update->setCleanupAreaParameters( loc, data->m_cleanupMoveRange );
  85. }
  86. else
  87. {
  88. //This case will only happen should the ambulance not have a cleanuphazard update module.
  89. DEBUG_CRASH( ("%s is attempting to use CleanupAreaPower, but requires a CleanupHazardUpdate module to work!", obj->getTemplate()->getName().str() ) );
  90. }
  91. }
  92. //-------------------------------------------------------------------------------------------------
  93. void CleanupAreaPower::crc( Xfer *xfer )
  94. {
  95. // extend base class
  96. SpecialPowerModule::crc( xfer );
  97. } // end crc
  98. //-------------------------------------------------------------------------------------------------
  99. // Xfer method
  100. // Version Info:
  101. // 1: Initial version
  102. //-------------------------------------------------------------------------------------------------
  103. void CleanupAreaPower::xfer( Xfer *xfer )
  104. {
  105. // version
  106. XferVersion currentVersion = 1;
  107. XferVersion version = currentVersion;
  108. xfer->xferVersion( &version, currentVersion );
  109. // extend base class
  110. SpecialPowerModule::xfer( xfer );
  111. } // end xfer
  112. //-------------------------------------------------------------------------------------------------
  113. void CleanupAreaPower::loadPostProcess( void )
  114. {
  115. // extend base class
  116. SpecialPowerModule::loadPostProcess();
  117. } // end loadPostProcess