RetroAchievements: Block loading discs that don't match current title

This commit is contained in:
JosJuice 2026-03-17 19:58:28 +01:00 committed by OatmealDome
parent 5c9e4f8e47
commit 8b5a50da8f
No known key found for this signature in database
GPG Key ID: A4BFAB0C67513B91
3 changed files with 25 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "Core/Config/FreeLookSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/GeckoCode.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
{
auto* game_info = rc_client_get_game_info(m_client);

View File

@ -121,6 +121,7 @@ public:
void Login(const std::string& password);
bool HasAPIToken() const;
void LoadGame(const DiscIO::Volume* volume);
void ChangeDisc(const DiscIO::Volume* volume);
bool IsGameLoaded() const;
void SetBackgroundExecutionAllowed(bool allowed);
@ -333,6 +334,8 @@ public:
constexpr void LoadGame(const DiscIO::Volume*) {}
constexpr void ChangeDisc(const DiscIO::Volume*) {}
constexpr void SetBackgroundExecutionAllowed(bool allowed) {}
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)
{
AchievementManager::GetInstance().LoadGame(nullptr);
AchievementManager::GetInstance().ChangeDisc(nullptr);
system.GetDVDInterface().SetDisc(nullptr, {});
}
@ -454,7 +454,7 @@ void DVDInterface::InsertDiscCallback(Core::System& system, u64 userdata, s64 cy
if (new_disc)
{
AchievementManager::GetInstance().LoadGame(new_disc.get());
AchievementManager::GetInstance().ChangeDisc(new_disc.get());
di.SetDisc(std::move(new_disc), {});
}
else