SupplyCenterCreate.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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: SupplyCenterCreate.cpp ///////////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood Feb 2002
  25. // Desc: When a Supply Center is created, it needs to update all the Resource brains in all players
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/Player.h"
  30. #include "Common/PlayerList.h"
  31. #include "Common/ResourceGatheringManager.h"
  32. #include "Common/Xfer.h"
  33. #include "GameLogic/Module/SupplyCenterCreate.h"
  34. //-------------------------------------------------------------------------------------------------
  35. //-------------------------------------------------------------------------------------------------
  36. SupplyCenterCreate::SupplyCenterCreate( Thing *thing, const ModuleData* moduleData ) : CreateModule( thing, moduleData )
  37. {
  38. }
  39. //-------------------------------------------------------------------------------------------------
  40. //-------------------------------------------------------------------------------------------------
  41. SupplyCenterCreate::~SupplyCenterCreate( void )
  42. {
  43. }
  44. //-------------------------------------------------------------------------------------------------
  45. void SupplyCenterCreate::onCreate( void )
  46. {
  47. }
  48. //-------------------------------------------------------------------------------------------------
  49. void SupplyCenterCreate::onBuildComplete( void )
  50. {
  51. if( ! shouldDoOnBuildComplete() )
  52. return;
  53. CreateModule::onBuildComplete(); // extend
  54. if( ThePlayerList == NULL )
  55. return;
  56. for( Int playerIndex = ThePlayerList->getPlayerCount() - 1; playerIndex >= 0; playerIndex-- )
  57. {
  58. Player *currentPlayer = ThePlayerList->getNthPlayer( playerIndex );
  59. if( currentPlayer == NULL )
  60. continue;
  61. ResourceGatheringManager *manager = currentPlayer->getResourceGatheringManager();
  62. if( manager == NULL )
  63. continue;
  64. manager->addSupplyCenter( getObject() );
  65. }
  66. }
  67. // ------------------------------------------------------------------------------------------------
  68. /** CRC */
  69. // ------------------------------------------------------------------------------------------------
  70. void SupplyCenterCreate::crc( Xfer *xfer )
  71. {
  72. // extend base class
  73. CreateModule::crc( xfer );
  74. } // end crc
  75. // ------------------------------------------------------------------------------------------------
  76. /** Xfer method
  77. * Version Info:
  78. * 1: Initial version */
  79. // ------------------------------------------------------------------------------------------------
  80. void SupplyCenterCreate::xfer( Xfer *xfer )
  81. {
  82. // version
  83. XferVersion currentVersion = 1;
  84. XferVersion version = currentVersion;
  85. xfer->xferVersion( &version, currentVersion );
  86. // extend base class
  87. CreateModule::xfer( xfer );
  88. } // end xfer
  89. // ------------------------------------------------------------------------------------------------
  90. /** Load post process */
  91. // ------------------------------------------------------------------------------------------------
  92. void SupplyCenterCreate::loadPostProcess( void )
  93. {
  94. // extend base class
  95. CreateModule::loadPostProcess();
  96. } // end loadPostProcess