SkirmishBattleHonors.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. ///////////////////////////////////////////////////////////////////////////////////////
  24. // FILE: SkirmishBattleHonors.cpp
  25. // Author: Matthew D. Campbell, April 2002
  26. // Description: Saving/Loading of skirmish battle honors info
  27. ///////////////////////////////////////////////////////////////////////////////////////
  28. //-----------------------------------------------------------------------------
  29. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  30. //-----------------------------------------------------------------------------
  31. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  32. //-----------------------------------------------------------------------------
  33. // USER INCLUDES //////////////////////////////////////////////////////////////
  34. //-----------------------------------------------------------------------------
  35. #include "Common/UserPreferences.h"
  36. #include "Common/SkirmishBattleHonors.h"
  37. #include "Common/Player.h"
  38. #include "Common/PlayerTemplate.h"
  39. #include "Common/QuotedPrintable.h"
  40. #include "Common/MultiplayerSettings.h"
  41. #include "GameClient/MapUtil.h"
  42. //-----------------------------------------------------------------------------
  43. // DEFINES ////////////////////////////////////////////////////////////////////
  44. //-----------------------------------------------------------------------------
  45. //-----------------------------------------------------------------------------
  46. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  47. //-----------------------------------------------------------------------------
  48. //-----------------------------------------------------------------------------
  49. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  50. //-----------------------------------------------------------------------------
  51. //-----------------------------------------------------------------------------
  52. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  53. //-----------------------------------------------------------------------------
  54. //-----------------------------------------------------------------------------
  55. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  56. //-----------------------------------------------------------------------------
  57. //-----------------------------------------------------------------------------
  58. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  59. //-----------------------------------------------------------------------------
  60. //-----------------------------------------------------------------------------
  61. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  62. //-----------------------------------------------------------------------------
  63. //-----------------------------------------------------------------------------
  64. // SkirmishBattleHonors base class
  65. //-----------------------------------------------------------------------------
  66. SkirmishBattleHonors::SkirmishBattleHonors()
  67. {
  68. load("SkirmishStats.ini");
  69. }
  70. SkirmishBattleHonors::~SkirmishBattleHonors()
  71. {
  72. }
  73. void SkirmishBattleHonors::setWins(Int val)
  74. {
  75. setInt("Wins", val);
  76. }
  77. Int SkirmishBattleHonors::getWins(void) const
  78. {
  79. return getInt("Wins", 0);
  80. }
  81. void SkirmishBattleHonors::setLosses(Int val)
  82. {
  83. setInt("Losses", val);
  84. }
  85. Int SkirmishBattleHonors::getLosses(void) const
  86. {
  87. return getInt("Losses", 0);
  88. }
  89. void SkirmishBattleHonors::setWinStreak(Int val)
  90. {
  91. setInt("WinStreak", val);
  92. }
  93. Int SkirmishBattleHonors::getWinStreak(void) const
  94. {
  95. return getInt("WinStreak", 0);
  96. }
  97. void SkirmishBattleHonors::setBestWinStreak(Int val)
  98. {
  99. setInt("BestWinStreak", val);
  100. }
  101. Int SkirmishBattleHonors::getBestWinStreak(void) const
  102. {
  103. return getInt("BestWinStreak", 0);
  104. }
  105. void SkirmishBattleHonors::setChallengeMedals(Int val)
  106. {
  107. setInt("Challenge", val);
  108. }
  109. Int SkirmishBattleHonors::getChallengeMedals(void) const
  110. {
  111. return getInt("Challenge", 0);
  112. }
  113. void SkirmishBattleHonors::setBuiltSCUD(void)
  114. {
  115. setBool("SCUD", TRUE);
  116. }
  117. Bool SkirmishBattleHonors::builtSCUD(void) const
  118. {
  119. return getBool("SCUD", FALSE);
  120. }
  121. void SkirmishBattleHonors::setBuiltParticleCannon(void)
  122. {
  123. setBool("PPC", TRUE);
  124. }
  125. Bool SkirmishBattleHonors::builtParticleCannon(void) const
  126. {
  127. return getBool("PPC", FALSE);
  128. }
  129. void SkirmishBattleHonors::setBuiltNuke(void)
  130. {
  131. setBool("Nuke", TRUE);
  132. }
  133. Bool SkirmishBattleHonors::builtNuke(void) const
  134. {
  135. return getBool("Nuke", FALSE);
  136. }
  137. void SkirmishBattleHonors::setHonors(Int which)
  138. {
  139. Int honors = getInt("Honors", 0);
  140. setInt("Honors", honors | which);
  141. }
  142. Int SkirmishBattleHonors::getHonors(void) const
  143. {
  144. return getInt("Honors", 0);
  145. }
  146. void SkirmishBattleHonors::setEnduranceMedal(AsciiString mapName, Int difficulty, int numAIs)
  147. {
  148. AsciiString key;
  149. key.format("%s_%d", mapName.str(), difficulty);
  150. setInt(key, numAIs);
  151. }
  152. Int SkirmishBattleHonors::getEnduranceMedal(AsciiString mapName, Int difficulty) const
  153. {
  154. AsciiString key;
  155. key.format("%s_%d", mapName.str(), difficulty);
  156. return getInt(key, 0);
  157. }
  158. void SkirmishBattleHonors::setLastGeneral(AsciiString val)
  159. {
  160. setAsciiString("LastHouse", val);
  161. }
  162. AsciiString SkirmishBattleHonors::getLastGeneral(void) const
  163. {
  164. return getAsciiString("LastHouse", AsciiString::TheEmptyString);
  165. }
  166. void SkirmishBattleHonors::setNumGamesLoyal(Int val)
  167. {
  168. setInt("LoyalGames", val);
  169. }
  170. Int SkirmishBattleHonors::getNumGamesLoyal(void) const
  171. {
  172. return getInt("LoyalGames", 0);
  173. }
  174. void SkirmishBattleHonors::setUSACampaignComplete(GameDifficulty difficulty)
  175. {
  176. AsciiString key;
  177. key.format("USACampaign_%d", (int)difficulty);
  178. setInt(key, 1);
  179. }
  180. Bool SkirmishBattleHonors::getUSACampaignComplete(GameDifficulty difficulty) const
  181. {
  182. AsciiString key;
  183. key.format("USACampaign_%d", (int)difficulty);
  184. return (getInt(key, 0) != 0);
  185. }
  186. void SkirmishBattleHonors::setCHINACampaignComplete(GameDifficulty difficulty)
  187. {
  188. AsciiString key;
  189. key.format("CHINACampaign_%d", (int)difficulty);
  190. setInt(key, 1);
  191. }
  192. Bool SkirmishBattleHonors::getCHINACampaignComplete(GameDifficulty difficulty) const
  193. {
  194. AsciiString key;
  195. key.format("CHINACampaign_%d",(int)difficulty);
  196. return (getInt(key, 0) != 0);
  197. }
  198. void SkirmishBattleHonors::setGLACampaignComplete(GameDifficulty difficulty)
  199. {
  200. AsciiString key;
  201. key.format("GLACampaign_%d", (int)difficulty);
  202. setInt(key, 1);
  203. }
  204. Bool SkirmishBattleHonors::getGLACampaignComplete(GameDifficulty difficulty) const
  205. {
  206. AsciiString key;
  207. key.format("GLACampaign_%d", (int)difficulty);
  208. return (getInt(key, 0) != 0);
  209. }
  210. void SkirmishBattleHonors::setChallengeCampaignComplete(Int challenge, GameDifficulty difficulty)
  211. {
  212. AsciiString key;
  213. key.format("ChallengeCampaign%d_%d", challenge, (int)difficulty);
  214. setInt(key, 1);
  215. }
  216. Bool SkirmishBattleHonors::getChallengeCampaignComplete(Int challenge, GameDifficulty difficulty) const
  217. {
  218. AsciiString key;
  219. key.format("ChallengeCampaign%d_%d", challenge, (int)difficulty);
  220. return (getInt(key, 0) != 0);
  221. }