mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-27 17:39:34 -06:00
Remove filename option from achievement manager load
The only option that was currently using this was a pass-by-executable that wouldn't hash correctly anyways.
This commit is contained in:
@ -161,13 +161,13 @@ bool AchievementManager::HasAPIToken() const
|
||||
return !Config::Get(Config::RA_API_TOKEN).empty();
|
||||
}
|
||||
|
||||
void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Volume* volume)
|
||||
void AchievementManager::LoadGame(const DiscIO::Volume* volume)
|
||||
{
|
||||
if (!Config::Get(Config::RA_ENABLED) || !HasAPIToken())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (file_path.empty() && volume == nullptr)
|
||||
if (volume == nullptr)
|
||||
{
|
||||
WARN_LOG_FMT(ACHIEVEMENTS, "Called Load Game without a game.");
|
||||
return;
|
||||
@ -184,7 +184,13 @@ void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Vo
|
||||
{
|
||||
std::lock_guard lg{m_lock};
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
SplitPath(file_path, nullptr, &m_title_estimate, nullptr);
|
||||
const auto& names = volume->GetLongNames();
|
||||
if (names.contains(DiscIO::Language::English))
|
||||
m_title_estimate = names.at(DiscIO::Language::English);
|
||||
else if (!names.empty())
|
||||
m_title_estimate = names.begin()->second;
|
||||
else
|
||||
m_title_estimate = "";
|
||||
#endif // RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
if (volume)
|
||||
{
|
||||
@ -196,8 +202,7 @@ void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Vo
|
||||
}
|
||||
std::lock_guard lg{m_filereader_lock};
|
||||
rc_hash_filereader volume_reader{
|
||||
.open = (volume) ? &AchievementManager::FilereaderOpenByVolume :
|
||||
&AchievementManager::FilereaderOpenByFilepath,
|
||||
.open = &AchievementManager::FilereaderOpen,
|
||||
.seek = &AchievementManager::FilereaderSeek,
|
||||
.tell = &AchievementManager::FilereaderTell,
|
||||
.read = &AchievementManager::FilereaderRead,
|
||||
@ -206,12 +211,12 @@ void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Vo
|
||||
rc_hash_init_custom_filereader(&volume_reader);
|
||||
if (rc_client_get_game_info(m_client))
|
||||
{
|
||||
rc_client_begin_change_media(m_client, file_path.c_str(), NULL, 0, ChangeMediaCallback, NULL);
|
||||
rc_client_begin_change_media(m_client, "", NULL, 0, ChangeMediaCallback, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_client_set_read_memory_function(m_client, MemoryVerifier);
|
||||
rc_client_begin_identify_and_load_game(m_client, RC_CONSOLE_GAMECUBE, file_path.c_str(), NULL,
|
||||
rc_client_begin_identify_and_load_game(m_client, RC_CONSOLE_GAMECUBE, "", NULL,
|
||||
0, LoadGameCallback, NULL);
|
||||
}
|
||||
}
|
||||
@ -237,8 +242,9 @@ void AchievementManager::SetBackgroundExecutionAllowed(bool allowed)
|
||||
std::string AchievementManager::CalculateHash(const std::string& file_path)
|
||||
{
|
||||
char hash_result[33] = "0";
|
||||
GetInstance().m_loading_volume = std::move(DiscIO::CreateVolume(file_path));
|
||||
rc_hash_filereader volume_reader{
|
||||
.open = &AchievementManager::FilereaderOpenByFilepath,
|
||||
.open = &AchievementManager::FilereaderOpen,
|
||||
.seek = &AchievementManager::FilereaderSeek,
|
||||
.tell = &AchievementManager::FilereaderTell,
|
||||
.read = &AchievementManager::FilereaderRead,
|
||||
@ -774,16 +780,7 @@ void AchievementManager::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
void* AchievementManager::FilereaderOpenByFilepath(const char* path_utf8)
|
||||
{
|
||||
auto state = std::make_unique<FilereaderState>();
|
||||
state->volume = DiscIO::CreateVolume(path_utf8);
|
||||
if (!state->volume)
|
||||
return nullptr;
|
||||
return state.release();
|
||||
}
|
||||
|
||||
void* AchievementManager::FilereaderOpenByVolume(const char* path_utf8)
|
||||
void* AchievementManager::FilereaderOpen(const char* path_utf8)
|
||||
{
|
||||
auto state = std::make_unique<FilereaderState>();
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
void SetUpdateCallback(UpdateCallback callback);
|
||||
void Login(const std::string& password);
|
||||
bool HasAPIToken() const;
|
||||
void LoadGame(const std::string& file_path, const DiscIO::Volume* volume);
|
||||
void LoadGame(const DiscIO::Volume* volume);
|
||||
bool IsGameLoaded() const;
|
||||
void SetBackgroundExecutionAllowed(bool allowed);
|
||||
|
||||
@ -193,8 +193,7 @@ private:
|
||||
|
||||
static picojson::value LoadApprovedList();
|
||||
|
||||
static void* FilereaderOpenByFilepath(const char* path_utf8);
|
||||
static void* FilereaderOpenByVolume(const char* path_utf8);
|
||||
static void* FilereaderOpen(const char* path_utf8);
|
||||
static void FilereaderSeek(void* file_handle, int64_t offset, int origin);
|
||||
static int64_t FilereaderTell(void* file_handle);
|
||||
static size_t FilereaderRead(void* file_handle, void* buffer, size_t requested_bytes);
|
||||
|
@ -597,8 +597,6 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
SetupGCMemory(system, guard);
|
||||
}
|
||||
|
||||
AchievementManager::GetInstance().LoadGame(executable.path, nullptr);
|
||||
|
||||
if (!executable.reader->LoadIntoMemory(system))
|
||||
{
|
||||
PanicAlertFmtT("Failed to load the executable to memory.");
|
||||
|
@ -398,7 +398,7 @@ void DVDInterface::SetDisc(std::unique_ptr<DiscIO::VolumeDisc> disc,
|
||||
m_auto_disc_change_index = 0;
|
||||
}
|
||||
|
||||
AchievementManager::GetInstance().LoadGame("", disc.get());
|
||||
AchievementManager::GetInstance().LoadGame(disc.get());
|
||||
|
||||
// Assume that inserting a disc requires having an empty disc before
|
||||
if (had_disc != has_disc)
|
||||
|
Reference in New Issue
Block a user