memory_patcher: Remove hardcoded repositories when loading patches (#2241)

This commit is contained in:
Ian Carpenter 2025-01-26 18:46:59 -05:00 committed by GitHub
parent 46b5437fdf
commit 7d1631f9f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@
#include <string> #include <string>
#include <pugixml.hpp> #include <pugixml.hpp>
#ifdef ENABLE_QT_GUI #ifdef ENABLE_QT_GUI
#include <QDir>
#include <QFile> #include <QFile>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
@ -189,14 +190,16 @@ void OnGameLoaded() {
// We use the QT headers for the xml and json parsing, this define is only true on QT builds // We use the QT headers for the xml and json parsing, this define is only true on QT builds
QString patchDir; QString patchDir;
Common::FS::PathToQString(patchDir, Common::FS::GetUserPath(Common::FS::PathType::PatchesDir)); Common::FS::PathToQString(patchDir, Common::FS::GetUserPath(Common::FS::PathType::PatchesDir));
QString repositories[] = {"GoldHEN", "shadPS4"}; QDir dir(patchDir);
QStringList folders = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString& repository : repositories) { for (const QString& folder : folders) {
QString filesJsonPath = patchDir + "/" + repository + "/files.json"; QString filesJsonPath = patchDir + "/" + folder + "/files.json";
QFile jsonFile(filesJsonPath); QFile jsonFile(filesJsonPath);
if (!jsonFile.open(QIODevice::ReadOnly)) { if (!jsonFile.open(QIODevice::ReadOnly)) {
LOG_ERROR(Loader, "Unable to open files.json for reading."); LOG_ERROR(Loader, "Unable to open files.json for reading in repository {}",
folder.toStdString());
continue; continue;
} }
@ -220,11 +223,12 @@ void OnGameLoaded() {
} }
if (selectedFileName.isEmpty()) { if (selectedFileName.isEmpty()) {
LOG_ERROR(Loader, "No patch file found for the current serial."); LOG_ERROR(Loader, "No patch file found for the current serial in repository {}",
folder.toStdString());
continue; continue;
} }
QString filePath = patchDir + "/" + repository + "/" + selectedFileName; QString filePath = patchDir + "/" + folder + "/" + selectedFileName;
QFile file(filePath); QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
LOG_ERROR(Loader, "Unable to open the file for reading."); LOG_ERROR(Loader, "Unable to open the file for reading.");