From fa0525f8262e784883742cecce6213042a8075f1 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 11 Aug 2021 13:52:08 +0200 Subject: [PATCH] Port Enable Cheats to the new config system --- Source/Core/Core/ActionReplay.cpp | 11 ++++++----- Source/Core/Core/BootManager.cpp | 5 ----- Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp | 1 + .../Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp | 1 + Source/Core/Core/ConfigManager.cpp | 2 -- Source/Core/Core/ConfigManager.h | 1 - Source/Core/Core/GeckoCode.cpp | 8 +++++--- Source/Core/Core/HLE/HLE.cpp | 4 +++- Source/Core/DolphinQt/Settings.cpp | 6 +++--- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index fa2eeb9f89..260f3fe232 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -32,13 +32,14 @@ #include "Common/BitUtils.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Core/ARDecrypt.h" #include "Core/CheatCodes.h" -#include "Core/ConfigManager.h" +#include "Core/Config/MainSettings.h" #include "Core/PowerPC/MMU.h" namespace ActionReplay @@ -112,7 +113,7 @@ struct ARAddr // AR Remote Functions void ApplyCodes(const std::vector& codes) { - if (!SConfig::GetInstance().bEnableCheats) + if (!Config::Get(Config::MAIN_ENABLE_CHEATS)) return; std::lock_guard guard(s_lock); @@ -141,7 +142,7 @@ void UpdateSyncedCodes(const std::vector& codes) std::vector ApplyAndReturnCodes(const std::vector& codes) { - if (SConfig::GetInstance().bEnableCheats) + if (Config::Get(Config::MAIN_ENABLE_CHEATS)) { std::lock_guard guard(s_lock); s_disable_logging = false; @@ -156,7 +157,7 @@ std::vector ApplyAndReturnCodes(const std::vector& codes) void AddCode(ARCode code) { - if (!SConfig::GetInstance().bEnableCheats) + if (!Config::Get(Config::MAIN_ENABLE_CHEATS)) return; if (code.enabled) @@ -972,7 +973,7 @@ static bool RunCodeLocked(const ARCode& arcode) void RunAllActive() { - if (!SConfig::GetInstance().bEnableCheats) + if (!Config::Get(Config::MAIN_ENABLE_CHEATS)) return; // If the mutex is idle then acquiring it should be cheap, fast mutexes diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index f5527ead72..585e5d62e9 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -74,7 +74,6 @@ private: bool valid; bool bCPUThread; bool bJITFollowBranch; - bool bEnableCheats; bool bSyncGPUOnSkipIdleHack; bool bFPRF; bool bAccurateNaNs; @@ -109,7 +108,6 @@ void ConfigCache::SaveConfig(const SConfig& config) bCPUThread = config.bCPUThread; bJITFollowBranch = config.bJITFollowBranch; - bEnableCheats = config.bEnableCheats; bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack; bFPRF = config.bFPRF; bAccurateNaNs = config.bAccurateNaNs; @@ -155,7 +153,6 @@ void ConfigCache::RestoreConfig(SConfig* config) config->bCPUThread = bCPUThread; config->bJITFollowBranch = bJITFollowBranch; - config->bEnableCheats = bEnableCheats; config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack; config->bFPRF = bFPRF; config->bAccurateNaNs = bAccurateNaNs; @@ -257,7 +254,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch); - core_section->Get("EnableCheats", &StartUp.bEnableCheats, StartUp.bEnableCheats); core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack, StartUp.bSyncGPUOnSkipIdleHack); core_section->Get("FPRF", &StartUp.bFPRF, StartUp.bFPRF); @@ -356,7 +352,6 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings(); Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings)); StartUp.bCPUThread = netplay_settings.m_CPUthread; - StartUp.bEnableCheats = netplay_settings.m_EnableCheats; StartUp.bDSPHLE = netplay_settings.m_DSPHLE; StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave; StartUp.cpu_core = netplay_settings.m_CPUcore; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 1f8074518d..6909e65e08 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -50,6 +50,7 @@ bool IsSettingSaveable(const Config::Location& config_location) // Main.Core &Config::MAIN_DEFAULT_ISO.GetLocation(), + &Config::MAIN_ENABLE_CHEATS.GetLocation(), &Config::MAIN_MEMCARD_A_PATH.GetLocation(), &Config::MAIN_MEMCARD_B_PATH.GetLocation(), &Config::MAIN_AUTO_DISC_CHANGE.GetLocation(), diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index da3a889521..983bf27040 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -31,6 +31,7 @@ public: { layer->Set(Config::MAIN_CPU_THREAD, m_settings.m_CPUthread); layer->Set(Config::MAIN_CPU_CORE, m_settings.m_CPUcore); + layer->Set(Config::MAIN_ENABLE_CHEATS, m_settings.m_EnableCheats); layer->Set(Config::MAIN_GC_LANGUAGE, m_settings.m_SelectedLanguage); layer->Set(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_settings.m_OverrideRegionSettings); layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE); diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 2081edd623..9eeba47706 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -215,7 +215,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("SyncGpuOverclock", fSyncGpuOverclock); core->Set("FPRF", bFPRF); core->Set("AccurateNaNs", bAccurateNaNs); - core->Set("EnableCheats", bEnableCheats); core->Set("SelectedLanguage", SelectedLanguage); core->Set("OverrideRegionSettings", bOverrideRegionSettings); core->Set("DPL2Decoder", bDPL2Decoder); @@ -473,7 +472,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("TimingVariance", &iTimingVariance, 40); core->Get("CPUThread", &bCPUThread, true); core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true); - core->Get("EnableCheats", &bEnableCheats, false); core->Get("SelectedLanguage", &SelectedLanguage, DiscIO::ToGameCubeLanguage(Config::GetDefaultLanguage())); core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 263124ba23..c6d954a398 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -118,7 +118,6 @@ struct SConfig bool bDSPHLE = true; bool bSyncGPUOnSkipIdleHack = true; bool bHLE_BS2 = true; - bool bEnableCheats = false; bool bCopyWiiSaveNetplay = true; bool bDPL2Decoder = false; diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index b867253cf9..f69eb7f9bf 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -12,8 +12,10 @@ #include "Common/ChunkFile.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" @@ -68,7 +70,7 @@ void SetActiveCodes(const std::vector& gcodes) std::lock_guard lk(s_active_codes_lock); s_active_codes.clear(); - if (SConfig::GetInstance().bEnableCheats) + if (Config::Get(Config::MAIN_ENABLE_CHEATS)) { s_active_codes.reserve(gcodes.size()); std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes), @@ -100,7 +102,7 @@ std::vector SetAndReturnActiveCodes(const std::vector& gco std::lock_guard lk(s_active_codes_lock); s_active_codes.clear(); - if (SConfig::GetInstance().bEnableCheats) + if (Config::Get(Config::MAIN_ENABLE_CHEATS)) { s_active_codes.reserve(gcodes.size()); std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes), @@ -231,7 +233,7 @@ void Shutdown() void RunCodeHandler() { - if (!SConfig::GetInstance().bEnableCheats) + if (!Config::Get(Config::MAIN_ENABLE_CHEATS)) return; // NOTE: Need to release the lock because of GUI deadlocks with PanicAlert in HostWrite_* diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 361aec45f0..6c65c445a7 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -8,7 +8,9 @@ #include #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/GeckoCode.h" #include "Core/HLE/HLE_Misc.h" @@ -85,7 +87,7 @@ void PatchFixedFunctions() // HLE jump to loader (homebrew). Disabled when Gecko is active as it interferes with the code // handler - if (!SConfig::GetInstance().bEnableCheats) + if (!Config::Get(Config::MAIN_ENABLE_CHEATS)) { Patch(0x80001800, "HBReload"); Memory::CopyToEmu(0x00001804, "STUBHAXX", 8); diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index e4173a1767..bb608e8fd6 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -415,14 +415,14 @@ void Settings::ResetNetPlayServer(NetPlay::NetPlayServer* server) bool Settings::GetCheatsEnabled() const { - return SConfig::GetInstance().bEnableCheats; + return Config::Get(Config::MAIN_ENABLE_CHEATS); } void Settings::SetCheatsEnabled(bool enabled) { - if (SConfig::GetInstance().bEnableCheats != enabled) + if (Config::Get(Config::MAIN_ENABLE_CHEATS) != enabled) { - SConfig::GetInstance().bEnableCheats = enabled; + Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, enabled); emit EnableCheatsChanged(enabled); } }