Disable cheats in hardcore mode

RetroAchievements does not allow cheats such as Action Replay or Gecko in hardcore mode, for fairness.
This commit is contained in:
LillyJadeKatrin 2023-06-07 21:53:38 -04:00
commit 3aebbbb3e7
17 changed files with 105 additions and 9 deletions

View file

@ -16,6 +16,7 @@
#include "Common/BitUtils.h"
#include "Common/StringUtil.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Core.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/MMU.h"
@ -206,6 +207,10 @@ Cheats::NewSearch(const Core::CPUThreadGuard& guard,
PowerPC::RequestedAddressSpace address_space, bool aligned,
const std::function<bool(const T& value)>& validator)
{
#ifdef USE_RETRO_ACHIEVEMENTS
if (Config::Get(Config::RA_HARDCORE_ENABLED))
return Cheats::SearchErrorCode::DisabledInHardcoreMode;
#endif // USE_RETRO_ACHIEVEMENTS
const u32 data_size = sizeof(T);
std::vector<Cheats::SearchResult<T>> results;
Cheats::SearchErrorCode error_code = Cheats::SearchErrorCode::Success;
@ -269,6 +274,10 @@ Cheats::NextSearch(const Core::CPUThreadGuard& guard,
PowerPC::RequestedAddressSpace address_space,
const std::function<bool(const T& new_value, const T& old_value)>& validator)
{
#ifdef USE_RETRO_ACHIEVEMENTS
if (Config::Get(Config::RA_HARDCORE_ENABLED))
return Cheats::SearchErrorCode::DisabledInHardcoreMode;
#endif // USE_RETRO_ACHIEVEMENTS
std::vector<Cheats::SearchResult<T>> results;
Cheats::SearchErrorCode error_code = Cheats::SearchErrorCode::Success;
Core::RunAsCPUThread([&] {
@ -444,6 +453,10 @@ MakeCompareFunctionForLastValue(Cheats::CompareType op)
template <typename T>
Cheats::SearchErrorCode Cheats::CheatSearchSession<T>::RunSearch(const Core::CPUThreadGuard& guard)
{
#ifdef USE_RETRO_ACHIEVEMENTS
if (Config::Get(Config::RA_HARDCORE_ENABLED))
return Cheats::SearchErrorCode::DisabledInHardcoreMode;
#endif // USE_RETRO_ACHIEVEMENTS
Common::Result<SearchErrorCode, std::vector<SearchResult<T>>> result =
Cheats::SearchErrorCode::InvalidParameters;
if (m_filter_type == FilterType::CompareAgainstSpecificValue)