Merge pull request #10019 from JosJuice/port-enable-cheats
Port Enable Cheats to the new config system
This commit is contained in:
commit
bfbbed8308
|
@ -32,13 +32,14 @@
|
||||||
|
|
||||||
#include "Common/BitUtils.h"
|
#include "Common/BitUtils.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/Config/Config.h"
|
||||||
#include "Common/IniFile.h"
|
#include "Common/IniFile.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
|
|
||||||
#include "Core/ARDecrypt.h"
|
#include "Core/ARDecrypt.h"
|
||||||
#include "Core/CheatCodes.h"
|
#include "Core/CheatCodes.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/PowerPC/MMU.h"
|
#include "Core/PowerPC/MMU.h"
|
||||||
|
|
||||||
namespace ActionReplay
|
namespace ActionReplay
|
||||||
|
@ -112,7 +113,7 @@ struct ARAddr
|
||||||
// AR Remote Functions
|
// AR Remote Functions
|
||||||
void ApplyCodes(const std::vector<ARCode>& codes)
|
void ApplyCodes(const std::vector<ARCode>& codes)
|
||||||
{
|
{
|
||||||
if (!SConfig::GetInstance().bEnableCheats)
|
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::lock_guard guard(s_lock);
|
std::lock_guard guard(s_lock);
|
||||||
|
@ -141,7 +142,7 @@ void UpdateSyncedCodes(const std::vector<ARCode>& codes)
|
||||||
|
|
||||||
std::vector<ARCode> ApplyAndReturnCodes(const std::vector<ARCode>& codes)
|
std::vector<ARCode> ApplyAndReturnCodes(const std::vector<ARCode>& codes)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().bEnableCheats)
|
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
{
|
{
|
||||||
std::lock_guard guard(s_lock);
|
std::lock_guard guard(s_lock);
|
||||||
s_disable_logging = false;
|
s_disable_logging = false;
|
||||||
|
@ -156,7 +157,7 @@ std::vector<ARCode> ApplyAndReturnCodes(const std::vector<ARCode>& codes)
|
||||||
|
|
||||||
void AddCode(ARCode code)
|
void AddCode(ARCode code)
|
||||||
{
|
{
|
||||||
if (!SConfig::GetInstance().bEnableCheats)
|
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (code.enabled)
|
if (code.enabled)
|
||||||
|
@ -972,7 +973,7 @@ static bool RunCodeLocked(const ARCode& arcode)
|
||||||
|
|
||||||
void RunAllActive()
|
void RunAllActive()
|
||||||
{
|
{
|
||||||
if (!SConfig::GetInstance().bEnableCheats)
|
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If the mutex is idle then acquiring it should be cheap, fast mutexes
|
// If the mutex is idle then acquiring it should be cheap, fast mutexes
|
||||||
|
|
|
@ -74,7 +74,6 @@ private:
|
||||||
bool valid;
|
bool valid;
|
||||||
bool bCPUThread;
|
bool bCPUThread;
|
||||||
bool bJITFollowBranch;
|
bool bJITFollowBranch;
|
||||||
bool bEnableCheats;
|
|
||||||
bool bSyncGPUOnSkipIdleHack;
|
bool bSyncGPUOnSkipIdleHack;
|
||||||
bool bFPRF;
|
bool bFPRF;
|
||||||
bool bAccurateNaNs;
|
bool bAccurateNaNs;
|
||||||
|
@ -109,7 +108,6 @@ void ConfigCache::SaveConfig(const SConfig& config)
|
||||||
|
|
||||||
bCPUThread = config.bCPUThread;
|
bCPUThread = config.bCPUThread;
|
||||||
bJITFollowBranch = config.bJITFollowBranch;
|
bJITFollowBranch = config.bJITFollowBranch;
|
||||||
bEnableCheats = config.bEnableCheats;
|
|
||||||
bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack;
|
bSyncGPUOnSkipIdleHack = config.bSyncGPUOnSkipIdleHack;
|
||||||
bFPRF = config.bFPRF;
|
bFPRF = config.bFPRF;
|
||||||
bAccurateNaNs = config.bAccurateNaNs;
|
bAccurateNaNs = config.bAccurateNaNs;
|
||||||
|
@ -155,7 +153,6 @@ void ConfigCache::RestoreConfig(SConfig* config)
|
||||||
|
|
||||||
config->bCPUThread = bCPUThread;
|
config->bCPUThread = bCPUThread;
|
||||||
config->bJITFollowBranch = bJITFollowBranch;
|
config->bJITFollowBranch = bJITFollowBranch;
|
||||||
config->bEnableCheats = bEnableCheats;
|
|
||||||
config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack;
|
config->bSyncGPUOnSkipIdleHack = bSyncGPUOnSkipIdleHack;
|
||||||
config->bFPRF = bFPRF;
|
config->bFPRF = bFPRF;
|
||||||
config->bAccurateNaNs = bAccurateNaNs;
|
config->bAccurateNaNs = bAccurateNaNs;
|
||||||
|
@ -257,7 +254,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
||||||
|
|
||||||
core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread);
|
||||||
core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch);
|
core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch);
|
||||||
core_section->Get("EnableCheats", &StartUp.bEnableCheats, StartUp.bEnableCheats);
|
|
||||||
core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack,
|
core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack,
|
||||||
StartUp.bSyncGPUOnSkipIdleHack);
|
StartUp.bSyncGPUOnSkipIdleHack);
|
||||||
core_section->Get("FPRF", &StartUp.bFPRF, StartUp.bFPRF);
|
core_section->Get("FPRF", &StartUp.bFPRF, StartUp.bFPRF);
|
||||||
|
@ -356,7 +352,6 @@ bool BootCore(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
|
||||||
const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings();
|
const NetPlay::NetSettings& netplay_settings = NetPlay::GetNetSettings();
|
||||||
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
|
Config::AddLayer(ConfigLoaders::GenerateNetPlayConfigLoader(netplay_settings));
|
||||||
StartUp.bCPUThread = netplay_settings.m_CPUthread;
|
StartUp.bCPUThread = netplay_settings.m_CPUthread;
|
||||||
StartUp.bEnableCheats = netplay_settings.m_EnableCheats;
|
|
||||||
StartUp.bDSPHLE = netplay_settings.m_DSPHLE;
|
StartUp.bDSPHLE = netplay_settings.m_DSPHLE;
|
||||||
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
|
StartUp.bCopyWiiSaveNetplay = netplay_settings.m_CopyWiiSave;
|
||||||
StartUp.cpu_core = netplay_settings.m_CPUcore;
|
StartUp.cpu_core = netplay_settings.m_CPUcore;
|
||||||
|
|
|
@ -50,6 +50,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
||||||
// Main.Core
|
// Main.Core
|
||||||
|
|
||||||
&Config::MAIN_DEFAULT_ISO.GetLocation(),
|
&Config::MAIN_DEFAULT_ISO.GetLocation(),
|
||||||
|
&Config::MAIN_ENABLE_CHEATS.GetLocation(),
|
||||||
&Config::MAIN_MEMCARD_A_PATH.GetLocation(),
|
&Config::MAIN_MEMCARD_A_PATH.GetLocation(),
|
||||||
&Config::MAIN_MEMCARD_B_PATH.GetLocation(),
|
&Config::MAIN_MEMCARD_B_PATH.GetLocation(),
|
||||||
&Config::MAIN_AUTO_DISC_CHANGE.GetLocation(),
|
&Config::MAIN_AUTO_DISC_CHANGE.GetLocation(),
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
{
|
{
|
||||||
layer->Set(Config::MAIN_CPU_THREAD, m_settings.m_CPUthread);
|
layer->Set(Config::MAIN_CPU_THREAD, m_settings.m_CPUthread);
|
||||||
layer->Set(Config::MAIN_CPU_CORE, m_settings.m_CPUcore);
|
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_GC_LANGUAGE, m_settings.m_SelectedLanguage);
|
||||||
layer->Set(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_settings.m_OverrideRegionSettings);
|
layer->Set(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_settings.m_OverrideRegionSettings);
|
||||||
layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE);
|
layer->Set(Config::MAIN_DSP_HLE, m_settings.m_DSPHLE);
|
||||||
|
|
|
@ -215,7 +215,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
|
||||||
core->Set("SyncGpuOverclock", fSyncGpuOverclock);
|
core->Set("SyncGpuOverclock", fSyncGpuOverclock);
|
||||||
core->Set("FPRF", bFPRF);
|
core->Set("FPRF", bFPRF);
|
||||||
core->Set("AccurateNaNs", bAccurateNaNs);
|
core->Set("AccurateNaNs", bAccurateNaNs);
|
||||||
core->Set("EnableCheats", bEnableCheats);
|
|
||||||
core->Set("SelectedLanguage", SelectedLanguage);
|
core->Set("SelectedLanguage", SelectedLanguage);
|
||||||
core->Set("OverrideRegionSettings", bOverrideRegionSettings);
|
core->Set("OverrideRegionSettings", bOverrideRegionSettings);
|
||||||
core->Set("DPL2Decoder", bDPL2Decoder);
|
core->Set("DPL2Decoder", bDPL2Decoder);
|
||||||
|
@ -473,7 +472,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
|
||||||
core->Get("TimingVariance", &iTimingVariance, 40);
|
core->Get("TimingVariance", &iTimingVariance, 40);
|
||||||
core->Get("CPUThread", &bCPUThread, true);
|
core->Get("CPUThread", &bCPUThread, true);
|
||||||
core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true);
|
core->Get("SyncOnSkipIdle", &bSyncGPUOnSkipIdleHack, true);
|
||||||
core->Get("EnableCheats", &bEnableCheats, false);
|
|
||||||
core->Get("SelectedLanguage", &SelectedLanguage,
|
core->Get("SelectedLanguage", &SelectedLanguage,
|
||||||
DiscIO::ToGameCubeLanguage(Config::GetDefaultLanguage()));
|
DiscIO::ToGameCubeLanguage(Config::GetDefaultLanguage()));
|
||||||
core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false);
|
core->Get("OverrideRegionSettings", &bOverrideRegionSettings, false);
|
||||||
|
|
|
@ -118,7 +118,6 @@ struct SConfig
|
||||||
bool bDSPHLE = true;
|
bool bDSPHLE = true;
|
||||||
bool bSyncGPUOnSkipIdleHack = true;
|
bool bSyncGPUOnSkipIdleHack = true;
|
||||||
bool bHLE_BS2 = true;
|
bool bHLE_BS2 = true;
|
||||||
bool bEnableCheats = false;
|
|
||||||
bool bCopyWiiSaveNetplay = true;
|
bool bCopyWiiSaveNetplay = true;
|
||||||
|
|
||||||
bool bDPL2Decoder = false;
|
bool bDPL2Decoder = false;
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
#include "Common/CommonPaths.h"
|
#include "Common/CommonPaths.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/Config/Config.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
|
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/PowerPC/MMU.h"
|
#include "Core/PowerPC/MMU.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
@ -68,7 +70,7 @@ void SetActiveCodes(const std::vector<GeckoCode>& gcodes)
|
||||||
std::lock_guard lk(s_active_codes_lock);
|
std::lock_guard lk(s_active_codes_lock);
|
||||||
|
|
||||||
s_active_codes.clear();
|
s_active_codes.clear();
|
||||||
if (SConfig::GetInstance().bEnableCheats)
|
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
{
|
{
|
||||||
s_active_codes.reserve(gcodes.size());
|
s_active_codes.reserve(gcodes.size());
|
||||||
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
||||||
|
@ -100,7 +102,7 @@ std::vector<GeckoCode> SetAndReturnActiveCodes(const std::vector<GeckoCode>& gco
|
||||||
std::lock_guard lk(s_active_codes_lock);
|
std::lock_guard lk(s_active_codes_lock);
|
||||||
|
|
||||||
s_active_codes.clear();
|
s_active_codes.clear();
|
||||||
if (SConfig::GetInstance().bEnableCheats)
|
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
{
|
{
|
||||||
s_active_codes.reserve(gcodes.size());
|
s_active_codes.reserve(gcodes.size());
|
||||||
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
||||||
|
@ -231,7 +233,7 @@ void Shutdown()
|
||||||
|
|
||||||
void RunCodeHandler()
|
void RunCodeHandler()
|
||||||
{
|
{
|
||||||
if (!SConfig::GetInstance().bEnableCheats)
|
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: Need to release the lock because of GUI deadlocks with PanicAlert in HostWrite_*
|
// NOTE: Need to release the lock because of GUI deadlocks with PanicAlert in HostWrite_*
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/Config/Config.h"
|
||||||
|
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/GeckoCode.h"
|
#include "Core/GeckoCode.h"
|
||||||
#include "Core/HLE/HLE_Misc.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
|
// HLE jump to loader (homebrew). Disabled when Gecko is active as it interferes with the code
|
||||||
// handler
|
// handler
|
||||||
if (!SConfig::GetInstance().bEnableCheats)
|
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||||
{
|
{
|
||||||
Patch(0x80001800, "HBReload");
|
Patch(0x80001800, "HBReload");
|
||||||
Memory::CopyToEmu(0x00001804, "STUBHAXX", 8);
|
Memory::CopyToEmu(0x00001804, "STUBHAXX", 8);
|
||||||
|
|
|
@ -415,14 +415,14 @@ void Settings::ResetNetPlayServer(NetPlay::NetPlayServer* server)
|
||||||
|
|
||||||
bool Settings::GetCheatsEnabled() const
|
bool Settings::GetCheatsEnabled() const
|
||||||
{
|
{
|
||||||
return SConfig::GetInstance().bEnableCheats;
|
return Config::Get(Config::MAIN_ENABLE_CHEATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::SetCheatsEnabled(bool enabled)
|
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);
|
emit EnableCheatsChanged(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue