From ef71c7545873f757db700d0cc6db0c52005e1e06 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Thu, 7 Nov 2024 21:11:58 -0500 Subject: [PATCH 1/2] Add Config Changed Callback for Hardcore Mode --- Source/Core/Core/AchievementManager.cpp | 2 ++ .../Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index c724476ad7..73ace1af34 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -16,6 +16,7 @@ #include "Common/Assert.h" #include "Common/BitUtils.h" #include "Common/CommonPaths.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/Image.h" @@ -64,6 +65,7 @@ void AchievementManager::Init() [](const char* message, const rc_client_t* client) { INFO_LOG_FMT(ACHIEVEMENTS, "{}", message); }); + Config::AddConfigChangedCallback([this] { SetHardcoreMode(); }); SetHardcoreMode(); m_queue.Reset("AchievementManagerQueue", [](const std::function& func) { func(); }); m_image_queue.Reset("AchievementManagerImageQueue", diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp index 93b9f35af3..75152c09ff 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp @@ -329,7 +329,6 @@ void AchievementSettingsWidget::ToggleProgress() void AchievementSettingsWidget::UpdateHardcoreMode() { - AchievementManager::GetInstance().SetHardcoreMode(); if (Config::Get(Config::RA_HARDCORE_ENABLED)) { Settings::Instance().SetDebugModeEnabled(false); From 9b6555c49c954be6286fd1b84cf7c4b7c922a58c Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Sat, 26 Oct 2024 23:04:53 -0400 Subject: [PATCH 2/2] Force NetPlay Clients to Host Hardcore Status If the host is in hardcore mode, all joining players will be set to hardcore mode; if not, all joining players will be set to softcore. This ensures all players have the same settings and remain synchroized. --- Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp | 4 ++++ Source/Core/Core/NetPlayClient.cpp | 1 + Source/Core/Core/NetPlayProto.h | 1 + Source/Core/Core/NetPlayServer.cpp | 3 +++ 4 files changed, 9 insertions(+) diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index 75b1bda454..5f772fd0e3 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -11,6 +11,7 @@ #include "Common/Config/Config.h" #include "Common/FileUtil.h" +#include "Core/Config/AchievementSettings.h" #include "Core/Config/GraphicsSettings.h" #include "Core/Config/MainSettings.h" #include "Core/Config/SYSCONFSettings.h" @@ -33,6 +34,9 @@ public: layer->Set(Config::MAIN_CPU_THREAD, m_settings.cpu_thread); layer->Set(Config::MAIN_CPU_CORE, m_settings.cpu_core); layer->Set(Config::MAIN_ENABLE_CHEATS, m_settings.enable_cheats); +#ifdef USE_RETRO_ACHIEVEMENTS + layer->Set(Config::RA_HARDCORE_ENABLED, m_settings.enable_hardcore); +#endif // USE_RETRO_ACHIEVEMENTS layer->Set(Config::MAIN_GC_LANGUAGE, m_settings.selected_language); layer->Set(Config::MAIN_OVERRIDE_REGION_SETTINGS, m_settings.override_region_settings); layer->Set(Config::MAIN_DSP_HLE, m_settings.dsp_hle); diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 43701c75ef..82c594dff6 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -848,6 +848,7 @@ void NetPlayClient::OnStartGame(sf::Packet& packet) packet >> m_net_settings.cpu_thread; packet >> m_net_settings.cpu_core; packet >> m_net_settings.enable_cheats; + packet >> m_net_settings.enable_hardcore; packet >> m_net_settings.selected_language; packet >> m_net_settings.override_region_settings; packet >> m_net_settings.dsp_enable_jit; diff --git a/Source/Core/Core/NetPlayProto.h b/Source/Core/Core/NetPlayProto.h index a20aee39ce..86f54d458d 100644 --- a/Source/Core/Core/NetPlayProto.h +++ b/Source/Core/Core/NetPlayProto.h @@ -35,6 +35,7 @@ struct NetSettings bool cpu_thread = false; PowerPC::CPUCore cpu_core{}; bool enable_cheats = false; + bool enable_hardcore = false; int selected_language = 0; bool override_region_settings = false; bool dsp_hle = false; diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 0044ce903e..d4a55cf83e 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -31,6 +31,7 @@ #include "Common/UPnP.h" #include "Common/Version.h" +#include "Core/AchievementManager.h" #include "Core/ActionReplay.h" #include "Core/Boot/Boot.h" #include "Core/Config/GraphicsSettings.h" @@ -1358,6 +1359,7 @@ bool NetPlayServer::SetupNetSettings() settings.cpu_thread = Config::Get(Config::MAIN_CPU_THREAD); settings.cpu_core = Config::Get(Config::MAIN_CPU_CORE); settings.enable_cheats = Config::AreCheatsEnabled(); + settings.enable_hardcore = AchievementManager::GetInstance().IsHardcoreModeActive(); 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); @@ -1586,6 +1588,7 @@ bool NetPlayServer::StartGame() spac << m_settings.cpu_thread; spac << m_settings.cpu_core; spac << m_settings.enable_cheats; + spac << m_settings.enable_hardcore; spac << m_settings.selected_language; spac << m_settings.override_region_settings; spac << m_settings.dsp_enable_jit;