mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
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:
parent
0abfa94bc8
commit
3aebbbb3e7
@ -114,7 +114,7 @@ struct ARAddr
|
||||
// AR Remote Functions
|
||||
void ApplyCodes(std::span<const ARCode> codes)
|
||||
{
|
||||
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (!Config::AreCheatsEnabled())
|
||||
return;
|
||||
|
||||
std::lock_guard guard(s_lock);
|
||||
@ -143,7 +143,7 @@ void UpdateSyncedCodes(std::span<const ARCode> codes)
|
||||
|
||||
std::vector<ARCode> ApplyAndReturnCodes(std::span<const ARCode> codes)
|
||||
{
|
||||
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (Config::AreCheatsEnabled())
|
||||
{
|
||||
std::lock_guard guard(s_lock);
|
||||
s_disable_logging = false;
|
||||
@ -158,7 +158,7 @@ std::vector<ARCode> ApplyAndReturnCodes(std::span<const ARCode> codes)
|
||||
|
||||
void AddCode(ARCode code)
|
||||
{
|
||||
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (!Config::AreCheatsEnabled())
|
||||
return;
|
||||
|
||||
if (code.enabled)
|
||||
@ -990,7 +990,7 @@ static bool RunCodeLocked(const Core::CPUThreadGuard& guard, const ARCode& arcod
|
||||
|
||||
void RunAllActive(const Core::CPUThreadGuard& cpu_guard)
|
||||
{
|
||||
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (!Config::AreCheatsEnabled())
|
||||
return;
|
||||
|
||||
// If the mutex is idle then acquiring it should be cheap, fast mutexes
|
||||
|
@ -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)
|
||||
|
@ -99,6 +99,11 @@ enum class SearchErrorCode
|
||||
// This is returned if PowerPC::RequestedAddressSpace::Virtual is given but the MSR.DR flag is
|
||||
// currently off in the emulated game.
|
||||
VirtualAddressesCurrentlyNotAccessible,
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
// Cheats and memory reading are disabled in RetroAchievements hardcore mode.
|
||||
DisabledInHardcoreMode,
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
};
|
||||
|
||||
// Returns the corresponding DataType enum for the value currently held by the given SearchValue.
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Core/Config/AchievementSettings.h"
|
||||
#include "Core/Config/DefaultLocale.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
@ -739,6 +740,15 @@ bool IsDefaultGCIFolderPathConfigured(ExpansionInterface::Slot slot)
|
||||
return Config::Get(GetInfoForGCIPath(slot)).empty();
|
||||
}
|
||||
|
||||
bool AreCheatsEnabled()
|
||||
{
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
return Config::Get(::Config::MAIN_ENABLE_CHEATS) && !::Config::Get(::Config::RA_HARDCORE_ENABLED);
|
||||
#else // USE_RETRO_ACHIEVEMENTS
|
||||
return Config::Get(::Config::MAIN_ENABLE_CHEATS);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
}
|
||||
|
||||
bool IsDebuggingEnabled()
|
||||
{
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
|
@ -378,5 +378,6 @@ std::string GetGCIFolderPath(ExpansionInterface::Slot slot, std::optional<DiscIO
|
||||
std::string GetGCIFolderPath(std::string configured_folder, ExpansionInterface::Slot slot,
|
||||
std::optional<DiscIO::Region> region);
|
||||
bool IsDefaultGCIFolderPathConfigured(ExpansionInterface::Slot slot);
|
||||
bool AreCheatsEnabled();
|
||||
bool IsDebuggingEnabled();
|
||||
} // namespace Config
|
||||
|
@ -71,7 +71,7 @@ void SetActiveCodes(std::span<const GeckoCode> gcodes)
|
||||
std::lock_guard lk(s_active_codes_lock);
|
||||
|
||||
s_active_codes.clear();
|
||||
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (Config::AreCheatsEnabled())
|
||||
{
|
||||
s_active_codes.reserve(gcodes.size());
|
||||
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
||||
@ -103,7 +103,7 @@ std::vector<GeckoCode> SetAndReturnActiveCodes(std::span<const GeckoCode> gcodes
|
||||
std::lock_guard lk(s_active_codes_lock);
|
||||
|
||||
s_active_codes.clear();
|
||||
if (Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (Config::AreCheatsEnabled())
|
||||
{
|
||||
s_active_codes.reserve(gcodes.size());
|
||||
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
||||
@ -238,7 +238,7 @@ void Shutdown()
|
||||
|
||||
void RunCodeHandler(const Core::CPUThreadGuard& guard)
|
||||
{
|
||||
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (!Config::AreCheatsEnabled())
|
||||
return;
|
||||
|
||||
// NOTE: Need to release the lock because of GUI deadlocks with PanicAlert in HostWrite_*
|
||||
|
@ -90,7 +90,7 @@ void PatchFixedFunctions(Core::System& system)
|
||||
|
||||
// HLE jump to loader (homebrew). Disabled when Gecko is active as it interferes with the code
|
||||
// handler
|
||||
if (!Config::Get(Config::MAIN_ENABLE_CHEATS))
|
||||
if (!Config::AreCheatsEnabled())
|
||||
{
|
||||
Patch(system, 0x80001800, "HBReload");
|
||||
auto& memory = system.GetMemory();
|
||||
|
@ -1356,7 +1356,7 @@ bool NetPlayServer::SetupNetSettings()
|
||||
// Copy all relevant settings
|
||||
settings.cpu_thread = Config::Get(Config::MAIN_CPU_THREAD);
|
||||
settings.cpu_core = Config::Get(Config::MAIN_CPU_CORE);
|
||||
settings.enable_cheats = Config::Get(Config::MAIN_ENABLE_CHEATS);
|
||||
settings.enable_cheats = Config::AreCheatsEnabled();
|
||||
settings.selected_language = Config::Get(Config::MAIN_GC_LANGUAGE);
|
||||
settings.override_region_settings = Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS);
|
||||
settings.dsp_hle = Config::Get(Config::MAIN_DSP_HLE);
|
||||
|
@ -143,6 +143,12 @@ void CheatsManager::RefreshCodeTabs(Core::State state, bool force)
|
||||
connect(m_ar_code, &ARCodeWidget::OpenGeneralSettings, this, &CheatsManager::OpenGeneralSettings);
|
||||
connect(m_gecko_code, &GeckoCodeWidget::OpenGeneralSettings, this,
|
||||
&CheatsManager::OpenGeneralSettings);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(m_ar_code, &ARCodeWidget::OpenAchievementSettings, this,
|
||||
&CheatsManager::OpenAchievementSettings);
|
||||
connect(m_gecko_code, &GeckoCodeWidget::OpenAchievementSettings, this,
|
||||
&CheatsManager::OpenAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
}
|
||||
|
||||
void CheatsManager::CreateWidgets()
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
|
||||
signals:
|
||||
void OpenGeneralSettings();
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
void OpenAchievementSettings();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
void ShowMemory(u32 address);
|
||||
void RequestWatch(QString name, u32 address);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "DolphinQt/Config/CheatCodeEditor.h"
|
||||
#include "DolphinQt/Config/CheatWarningWidget.h"
|
||||
#include "DolphinQt/Config/HardcoreWarningWidget.h"
|
||||
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
|
||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||
|
||||
@ -55,6 +56,9 @@ ARCodeWidget::~ARCodeWidget() = default;
|
||||
void ARCodeWidget::CreateWidgets()
|
||||
{
|
||||
m_warning = new CheatWarningWidget(m_game_id, m_restart_required, this);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
m_hc_warning = new HardcoreWarningWidget(this);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
m_code_list = new QListWidget;
|
||||
m_code_add = new NonDefaultQPushButton(tr("&Add New Code..."));
|
||||
m_code_edit = new NonDefaultQPushButton(tr("&Edit Code..."));
|
||||
@ -76,6 +80,9 @@ void ARCodeWidget::CreateWidgets()
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
|
||||
layout->addWidget(m_warning);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
layout->addWidget(m_hc_warning);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
layout->addWidget(m_code_list);
|
||||
layout->addLayout(button_layout);
|
||||
|
||||
@ -86,6 +93,10 @@ void ARCodeWidget::ConnectWidgets()
|
||||
{
|
||||
connect(m_warning, &CheatWarningWidget::OpenCheatEnableSettings, this,
|
||||
&ARCodeWidget::OpenGeneralSettings);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(m_hc_warning, &HardcoreWarningWidget::OpenAchievementSettings, this,
|
||||
&ARCodeWidget::OpenAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
connect(m_code_list, &QListWidget::itemChanged, this, &ARCodeWidget::OnItemChanged);
|
||||
connect(m_code_list, &QListWidget::itemSelectionChanged, this, &ARCodeWidget::OnSelectionChanged);
|
||||
|
@ -16,6 +16,9 @@ struct ARCode;
|
||||
}
|
||||
|
||||
class CheatWarningWidget;
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
class HardcoreWarningWidget;
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
@ -32,6 +35,9 @@ public:
|
||||
|
||||
signals:
|
||||
void OpenGeneralSettings();
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
void OpenAchievementSettings();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
private:
|
||||
void OnSelectionChanged();
|
||||
@ -56,6 +62,9 @@ private:
|
||||
u16 m_game_revision;
|
||||
|
||||
CheatWarningWidget* m_warning;
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
HardcoreWarningWidget* m_hc_warning;
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
QListWidget* m_code_list;
|
||||
QPushButton* m_code_add;
|
||||
QPushButton* m_code_edit;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "DolphinQt/Config/CheatCodeEditor.h"
|
||||
#include "DolphinQt/Config/CheatWarningWidget.h"
|
||||
#include "DolphinQt/Config/HardcoreWarningWidget.h"
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
|
||||
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||
@ -61,6 +62,9 @@ GeckoCodeWidget::~GeckoCodeWidget() = default;
|
||||
void GeckoCodeWidget::CreateWidgets()
|
||||
{
|
||||
m_warning = new CheatWarningWidget(m_game_id, m_restart_required, this);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
m_hc_warning = new HardcoreWarningWidget(this);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
m_code_list = new QListWidget;
|
||||
m_name_label = new QLabel;
|
||||
m_creator_label = new QLabel;
|
||||
@ -102,6 +106,9 @@ void GeckoCodeWidget::CreateWidgets()
|
||||
auto* layout = new QVBoxLayout;
|
||||
|
||||
layout->addWidget(m_warning);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
layout->addWidget(m_hc_warning);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
layout->addWidget(m_code_list);
|
||||
|
||||
auto* info_layout = new QFormLayout;
|
||||
@ -150,6 +157,10 @@ void GeckoCodeWidget::ConnectWidgets()
|
||||
connect(m_download_codes, &QPushButton::clicked, this, &GeckoCodeWidget::DownloadCodes);
|
||||
connect(m_warning, &CheatWarningWidget::OpenCheatEnableSettings, this,
|
||||
&GeckoCodeWidget::OpenGeneralSettings);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(m_hc_warning, &HardcoreWarningWidget::OpenAchievementSettings, this,
|
||||
&GeckoCodeWidget::OpenAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
}
|
||||
|
||||
void GeckoCodeWidget::OnSelectionChanged()
|
||||
|
@ -11,6 +11,9 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
class CheatWarningWidget;
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
class HardcoreWarningWidget;
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
@ -32,6 +35,9 @@ public:
|
||||
|
||||
signals:
|
||||
void OpenGeneralSettings();
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
void OpenAchievementSettings();
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
private:
|
||||
void OnSelectionChanged();
|
||||
@ -56,6 +62,9 @@ private:
|
||||
u16 m_game_revision;
|
||||
|
||||
CheatWarningWidget* m_warning;
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
HardcoreWarningWidget* m_hc_warning;
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
QListWidget* m_code_list;
|
||||
QLabel* m_name_label;
|
||||
QLabel* m_creator_label;
|
||||
|
@ -52,6 +52,10 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
|
||||
|
||||
connect(ar, &ARCodeWidget::OpenGeneralSettings, this, &PropertiesDialog::OpenGeneralSettings);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(ar, &ARCodeWidget::OpenAchievementSettings, this,
|
||||
&PropertiesDialog::OpenAchievementSettings);
|
||||
connect(gecko, &GeckoCodeWidget::OpenAchievementSettings, this,
|
||||
&PropertiesDialog::OpenAchievementSettings);
|
||||
connect(patches, &PatchesWidget::OpenAchievementSettings, this,
|
||||
&PropertiesDialog::OpenAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
@ -247,6 +247,8 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
|
||||
&MainWindow::ShowGeneralWindow);
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(m_cheats_manager, &CheatsManager::OpenAchievementSettings, this,
|
||||
&MainWindow::ShowAchievementSettings);
|
||||
connect(m_game_list, &GameList::OpenAchievementSettings, this,
|
||||
&MainWindow::ShowAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
@ -2027,6 +2029,12 @@ void MainWindow::ShowRiivolutionBootWidget(const UICommon::GameFile& game)
|
||||
RiivolutionBootWidget w(disc.volume->GetGameID(), disc.volume->GetRevision(),
|
||||
disc.volume->GetDiscNumber(), game.GetFilePath(), this);
|
||||
SetQWidgetWindowDecorations(&w);
|
||||
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
connect(&w, &RiivolutionBootWidget::OpenAchievementSettings, this,
|
||||
&MainWindow::ShowAchievementSettings);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
|
||||
w.exec();
|
||||
if (!w.ShouldBoot())
|
||||
return;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "Core/Config/AchievementSettings.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Config/UISettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
@ -84,7 +85,12 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
|
||||
const bool running = state != Core::State::Uninitialized;
|
||||
|
||||
m_checkbox_dualcore->setEnabled(!running);
|
||||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
bool hardcore = Config::Get(Config::RA_HARDCORE_ENABLED);
|
||||
m_checkbox_cheats->setEnabled(!running && !hardcore);
|
||||
#else // USE_RETRO_ACHIEVEMENTS
|
||||
m_checkbox_cheats->setEnabled(!running);
|
||||
#endif // USE_RETRO_ACHIEVEMENTS
|
||||
m_checkbox_override_region_settings->setEnabled(!running);
|
||||
#ifdef USE_DISCORD_PRESENCE
|
||||
m_checkbox_discord_presence->setEnabled(!running);
|
||||
|
Loading…
Reference in New Issue
Block a user