AutoDepositUpdate.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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: AutoDepositUpdate.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Aug 2002
  34. //
  35. // Filename: AutoDepositUpdate.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: Auto Deposit Update Module
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __AUTO_DEPOSIT_UPDATE_H_
  45. #define __AUTO_DEPOSIT_UPDATE_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. #include "GameLogic/Module/UpdateModule.h"
  53. //-----------------------------------------------------------------------------
  54. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  55. //-----------------------------------------------------------------------------
  56. class Player;
  57. class Thing;
  58. void parseUpgradePair( INI *ini, void *instance, void *store, const void *userData );
  59. struct upgradePair
  60. {
  61. std::string type;
  62. Int amount;
  63. };
  64. //-----------------------------------------------------------------------------
  65. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  66. //-----------------------------------------------------------------------------
  67. class AutoDepositUpdateModuleData : public UpdateModuleData
  68. {
  69. public:
  70. UnsignedInt m_depositFrame;
  71. Int m_depositAmount;
  72. Int m_initialCaptureBonus;
  73. Bool m_isActualMoney;
  74. std::list<upgradePair> m_upgradeBoost;
  75. AutoDepositUpdateModuleData()
  76. {
  77. m_depositFrame = 0;
  78. m_depositAmount = 0;
  79. m_initialCaptureBonus = 0;
  80. m_isActualMoney = TRUE;
  81. m_upgradeBoost.clear();
  82. }
  83. static void buildFieldParse(MultiIniFieldParse& p)
  84. {
  85. UpdateModuleData::buildFieldParse(p);
  86. static const FieldParse dataFieldParse[] =
  87. {
  88. { "DepositTiming", INI::parseDurationUnsignedInt, NULL, offsetof( AutoDepositUpdateModuleData, m_depositFrame ) },
  89. { "DepositAmount", INI::parseInt, NULL, offsetof( AutoDepositUpdateModuleData, m_depositAmount ) },
  90. { "InitialCaptureBonus", INI::parseInt, NULL, offsetof( AutoDepositUpdateModuleData, m_initialCaptureBonus ) },
  91. { "ActualMoney", INI::parseBool, NULL, offsetof( AutoDepositUpdateModuleData, m_isActualMoney ) },
  92. { "UpgradedBoost", parseUpgradePair, NULL, offsetof( AutoDepositUpdateModuleData, m_upgradeBoost ) },
  93. { 0, 0, 0, 0 }
  94. };
  95. p.add(dataFieldParse);
  96. }
  97. };
  98. //-------------------------------------------------------------------------------------------------
  99. class AutoDepositUpdate : public UpdateModule
  100. {
  101. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( AutoDepositUpdate, "AutoDepositUpdate" )
  102. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( AutoDepositUpdate, AutoDepositUpdateModuleData )
  103. public:
  104. AutoDepositUpdate( Thing *thing, const ModuleData* moduleData );
  105. // virtual destructor prototype provided by memory pool declaration
  106. void awardInitialCaptureBonus( Player *player ); // Test and award the initial capture bonus
  107. virtual UpdateSleepTime update( void );
  108. protected:
  109. Int getUpgradedSupplyBoost() const;
  110. UnsignedInt m_depositOnFrame;
  111. Bool m_awardInitialCaptureBonus;
  112. Bool m_initialized;
  113. };
  114. //-----------------------------------------------------------------------------
  115. // INLINING ///////////////////////////////////////////////////////////////////
  116. //-----------------------------------------------------------------------------
  117. //-----------------------------------------------------------------------------
  118. // EXTERNALS //////////////////////////////////////////////////////////////////
  119. //-----------------------------------------------------------------------------
  120. #endif // __AUTO_DEPOSIT_UPDATE_H_