renegadecheatmgr.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. ** Command & Conquer Renegade(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. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : commando *
  23. * *
  24. * $Archive:: /Commando/Code/commando/renegadecheatmgr.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 12/06/01 11:06a $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "renegadecheatmgr.h"
  36. #include "player.h"
  37. #include "playermanager.h"
  38. #include "combat.h"
  39. #include "cnetwork.h"
  40. #include "registry.h"
  41. #include "_globals.h"
  42. //////////////////////////////////////////////////////////////////////
  43. // Global instance
  44. //////////////////////////////////////////////////////////////////////
  45. static RenegadeCheatMgrClass _TheCheatMgr;
  46. //////////////////////////////////////////////////////////////////////
  47. // Constants
  48. //////////////////////////////////////////////////////////////////////
  49. //static const char *KEY_NAME_SETTINGS = "Software\\Westwood\\Renegade\\Options";
  50. static const char *VALUE_NAME_CHEATS = "Cheats";
  51. //////////////////////////////////////////////////////////////////////
  52. //
  53. // RenegadeCheatMgrClass
  54. //
  55. //////////////////////////////////////////////////////////////////////
  56. RenegadeCheatMgrClass::RenegadeCheatMgrClass (void)
  57. {
  58. //
  59. // Attempt to open the registry key
  60. //
  61. RegistryClass registry (APPLICATION_SUB_KEY_NAME_OPTIONS);
  62. if (registry.Is_Valid ()) {
  63. //
  64. // Read the values from the registry
  65. //
  66. //Flags = registry.Get_Int (VALUE_NAME_CHEATS, 0);
  67. }
  68. return ;
  69. }
  70. //////////////////////////////////////////////////////////////////////
  71. //
  72. // ~RenegadeCheatMgrClass
  73. //
  74. //////////////////////////////////////////////////////////////////////
  75. RenegadeCheatMgrClass::~RenegadeCheatMgrClass (void)
  76. {
  77. return ;
  78. }
  79. //////////////////////////////////////////////////////////////////////
  80. //
  81. // Enable_Cheat
  82. //
  83. //////////////////////////////////////////////////////////////////////
  84. void
  85. RenegadeCheatMgrClass::Enable_Cheat (int cheat, bool onoff)
  86. {
  87. #if 0
  88. CheatMgrClass::Enable_Cheat (cheat, onoff);
  89. //
  90. // Save the values to the registry
  91. //
  92. RegistryClass registry (APPLICATION_SUB_KEY_NAME_OPTIONS);
  93. if (registry.Is_Valid ()) {
  94. registry.Set_Int (VALUE_NAME_CHEATS, Flags);
  95. }
  96. if (cheat == CHEAT_INVULNERABILITY) {
  97. //
  98. // This may seem strange, but we only want to allow cheating in single
  99. // player and we need to be a client (which means we are a player).
  100. //
  101. if (IS_SOLOPLAY && CombatManager::I_Am_Client ()) {
  102. //
  103. // Make the current player invulnerable or not
  104. //
  105. cPlayer *player = cPlayerManager::Find_Player (cNetwork::Get_My_Id ());
  106. if (player != NULL) {
  107. player->Invulnerable.Set (onoff);
  108. player->Mark_As_Modified();
  109. }
  110. }
  111. } else if (cheat == CHEAT_ALL_WEAPONS) {
  112. //
  113. // Grant all weapons to the player
  114. //
  115. if (onoff && IS_SOLOPLAY && COMBAT_STAR != NULL) {
  116. COMBAT_STAR->Give_All_Weapons ();
  117. }
  118. }
  119. #endif //0
  120. return ;
  121. }
  122. //////////////////////////////////////////////////////////////////////
  123. //
  124. // Apply_Cheats
  125. //
  126. //////////////////////////////////////////////////////////////////////
  127. void
  128. RenegadeCheatMgrClass::Apply_Cheats (void)
  129. {
  130. #if 0
  131. CheatMgrClass::Apply_Cheats ();
  132. //
  133. // Just force the options to be re-enabled
  134. //
  135. Enable_Cheat (CHEAT_INVULNERABILITY, Is_Cheat_Set (CHEAT_INVULNERABILITY));
  136. Enable_Cheat (CHEAT_INFINITE_AMMO, Is_Cheat_Set (CHEAT_INFINITE_AMMO));
  137. Enable_Cheat (CHEAT_ALL_WEAPONS, Is_Cheat_Set (CHEAT_ALL_WEAPONS));
  138. #endif //0
  139. return ;
  140. }