Merge pull request #14481 from JosJuice/retroachievements-change-disc

RetroAchievements: Block loading discs that don't match current title
This commit is contained in:
OatmealDome 2026-03-17 17:57:09 -04:00 committed by GitHub
commit a8c5f6ddfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "Core/Config/FreeLookSettings.h" #include "Core/Config/FreeLookSettings.h"
#include "Core/Config/MainSettings.h" #include "Core/Config/MainSettings.h"
#include "Core/ConfigLoaders/GameConfigLoader.h" #include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/GeckoCode.h" #include "Core/GeckoCode.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
@ -215,6 +216,25 @@ void AchievementManager::LoadGame(const DiscIO::Volume* volume)
} }
} }
void AchievementManager::ChangeDisc(const DiscIO::Volume* volume)
{
if (volume == nullptr)
{
INFO_LOG_FMT(ACHIEVEMENTS, "Ejecting disc.");
LoadGame(nullptr);
}
else if (volume->GetGameID() != SConfig::GetInstance().GetGameID())
{
INFO_LOG_FMT(ACHIEVEMENTS, "Inserting disc that doesn't belong to the running game.");
LoadGame(nullptr);
}
else
{
INFO_LOG_FMT(ACHIEVEMENTS, "Inserting disc.");
LoadGame(volume);
}
}
bool AchievementManager::IsGameLoaded() const bool AchievementManager::IsGameLoaded() const
{ {
auto* game_info = rc_client_get_game_info(m_client); auto* game_info = rc_client_get_game_info(m_client);

View File

@ -121,6 +121,7 @@ public:
void Login(const std::string& password); void Login(const std::string& password);
bool HasAPIToken() const; bool HasAPIToken() const;
void LoadGame(const DiscIO::Volume* volume); void LoadGame(const DiscIO::Volume* volume);
void ChangeDisc(const DiscIO::Volume* volume);
bool IsGameLoaded() const; bool IsGameLoaded() const;
void SetBackgroundExecutionAllowed(bool allowed); void SetBackgroundExecutionAllowed(bool allowed);
@ -333,6 +334,8 @@ public:
constexpr void LoadGame(const DiscIO::Volume*) {} constexpr void LoadGame(const DiscIO::Volume*) {}
constexpr void ChangeDisc(const DiscIO::Volume*) {}
constexpr void SetBackgroundExecutionAllowed(bool allowed) {} constexpr void SetBackgroundExecutionAllowed(bool allowed) {}
constexpr void DoFrame() {} constexpr void DoFrame() {}

View File

@ -442,7 +442,7 @@ void DVDInterface::AutoChangeDiscCallback(Core::System& system, u64 userdata, s6
void DVDInterface::EjectDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate) void DVDInterface::EjectDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate)
{ {
AchievementManager::GetInstance().LoadGame(nullptr); AchievementManager::GetInstance().ChangeDisc(nullptr);
system.GetDVDInterface().SetDisc(nullptr, {}); system.GetDVDInterface().SetDisc(nullptr, {});
} }
@ -454,7 +454,7 @@ void DVDInterface::InsertDiscCallback(Core::System& system, u64 userdata, s64 cy
if (new_disc) if (new_disc)
{ {
AchievementManager::GetInstance().LoadGame(new_disc.get()); AchievementManager::GetInstance().ChangeDisc(new_disc.get());
di.SetDisc(std::move(new_disc), {}); di.SetDisc(std::move(new_disc), {});
} }
else else