PrisonDockUpdate.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: PrisonDockUpdate.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, August 2002
  25. // Desc: Dock update for prison structures
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/ThingTemplate.h"
  30. #include "Common/Xfer.h"
  31. #include "GameLogic/Object.h"
  32. #include "GameLogic/Module/ContainModule.h"
  33. #include "GameLogic/Module/POWTruckAIUpdate.h"
  34. #include "GameLogic/Module/PrisonDockUpdate.h"
  35. #ifdef ALLOW_SURRENDER
  36. // ------------------------------------------------------------------------------------------------
  37. // ------------------------------------------------------------------------------------------------
  38. PrisonDockUpdate::PrisonDockUpdate( Thing *thing, const ModuleData* moduleData )
  39. : DockUpdate( thing, moduleData )
  40. {
  41. } // end PrisonDockUpdate
  42. // ------------------------------------------------------------------------------------------------
  43. // ------------------------------------------------------------------------------------------------
  44. PrisonDockUpdate::~PrisonDockUpdate( void )
  45. {
  46. } // end ~PrisonDockUpdate
  47. // ------------------------------------------------------------------------------------------------
  48. /** Do the action while docked
  49. * Return TRUE to continue the docking process
  50. * Return FALSE to complete the dockin process */
  51. // ------------------------------------------------------------------------------------------------
  52. Bool PrisonDockUpdate::action( Object *docker, Object *drone )
  53. {
  54. // sanity
  55. if( docker == NULL )
  56. return FALSE;
  57. // if docker has no contents, do nothing and stop the dock process
  58. ContainModuleInterface *contain = docker->getContain();
  59. if( contain && contain->getContainCount() == 0 )
  60. return FALSE;
  61. // unload the prisoners from the docker into us
  62. AIUpdateInterface *ai = docker->getAIUpdateInterface();
  63. DEBUG_ASSERTCRASH( ai, ("'%s' docking with prison has no AI\n",
  64. docker->getTemplate()->getName().str()) );
  65. POWTruckAIUpdateInterface *powAI = ai->getPOWTruckAIUpdateInterface();
  66. DEBUG_ASSERTCRASH( powAI, ("'s' docking with prison has no POW Truck AI\n",
  67. docker->getTemplate()->getName().str()) );
  68. powAI->unloadPrisonersToPrison( getObject() );
  69. // end docking
  70. return FALSE;
  71. } // end action
  72. // ------------------------------------------------------------------------------------------------
  73. /** CRC */
  74. // ------------------------------------------------------------------------------------------------
  75. void PrisonDockUpdate::crc( Xfer *xfer )
  76. {
  77. // extend base class
  78. DockUpdate::crc( xfer );
  79. } // end crc
  80. // ------------------------------------------------------------------------------------------------
  81. /** Xfer method
  82. * Version Info:
  83. * 1: Initial version */
  84. // ------------------------------------------------------------------------------------------------
  85. void PrisonDockUpdate::xfer( Xfer *xfer )
  86. {
  87. // version
  88. XferVersion currentVersion = 1;
  89. XferVersion version = currentVersion;
  90. xfer->xferVersion( &version, currentVersion );
  91. // extend base class
  92. DockUpdate::xfer( xfer );
  93. } // end xfer
  94. // ------------------------------------------------------------------------------------------------
  95. /** Load post process */
  96. // ------------------------------------------------------------------------------------------------
  97. void PrisonDockUpdate::loadPostProcess( void )
  98. {
  99. // extend base class
  100. DockUpdate::loadPostProcess();
  101. } // end loadPostProcess
  102. #endif