Merge pull request #10019 from JosJuice/port-enable-cheats

Port Enable Cheats to the new config system
This commit is contained in:
Léo Lam 2021-08-11 21:20:10 +02:00 committed by GitHub
commit bfbbed8308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 20 deletions

View File

@ -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<ARCode>& 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<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);
s_disable_logging = false;
@ -156,7 +157,7 @@ std::vector<ARCode> ApplyAndReturnCodes(const std::vector<ARCode>& 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

View File

@ -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<BootParameters> 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<BootParameters> 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;

View File

@ -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(),

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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<GeckoCode>& 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<GeckoCode> SetAndReturnActiveCodes(const std::vector<GeckoCode>& 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_*

View File

@ -8,7 +8,9 @@
#include <map>
#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);

View File

@ -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);
}
}