From 2e16fd3bcc0f550b285c25d6578408ed4f59be35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 22 Jan 2024 23:46:28 +0100 Subject: [PATCH] Fix fake game ID generation to work with scoped storage --- Core/ELF/ParamSFO.cpp | 12 ++++++------ Core/ELF/ParamSFO.h | 4 +++- Core/PSPLoaders.cpp | 2 +- Core/SaveState.cpp | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 3 +++ UI/CwCheatScreen.cpp | 2 +- UI/GameInfoCache.cpp | 4 ++-- UI/GameScreen.cpp | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Core/ELF/ParamSFO.cpp b/Core/ELF/ParamSFO.cpp index 3aeb92b7bf..bbd14ca454 100644 --- a/Core/ELF/ParamSFO.cpp +++ b/Core/ELF/ParamSFO.cpp @@ -96,7 +96,7 @@ std::vector ParamSFOData::GetKeys() const { std::string ParamSFOData::GetDiscID() { const std::string discID = GetValueString("DISC_ID"); if (discID.empty()) { - std::string fakeID = GenerateFakeID(); + std::string fakeID = GenerateFakeID(Path()); WARN_LOG(LOADER, "No DiscID found - generating a fake one: '%s' (from %s)", fakeID.c_str(), PSP_CoreParameter().fileToStart.c_str()); ValueData data; data.type = VT_UTF8; @@ -320,15 +320,15 @@ void ParamSFOData::ValueData::SetData(const u8* data, int size) { u_size = size; } -std::string ParamSFOData::GenerateFakeID(const std::string &filename) const { +std::string ParamSFOData::GenerateFakeID(const Path &filename) const { // Generates fake gameID for homebrew based on it's folder name. // Should probably not be a part of ParamSFO, but it'll be called in same places. - std::string file = PSP_CoreParameter().fileToStart.ToString(); + // FileToStart here is actually a directory name, not a file, so taking GetFilename on it gets what we want. + Path path = PSP_CoreParameter().fileToStart; if (!filename.empty()) - file = filename; + path = filename; - std::size_t lslash = file.find_last_of("/"); - file = file.substr(lslash + 1); + std::string file = path.GetFilename(); int sumOfAllLetters = 0; for (char &c : file) { diff --git a/Core/ELF/ParamSFO.h b/Core/ELF/ParamSFO.h index f132e1c5f7..23af2f0c3f 100644 --- a/Core/ELF/ParamSFO.h +++ b/Core/ELF/ParamSFO.h @@ -24,6 +24,8 @@ #include "Common/CommonTypes.h" #include "Common/Log.h" +class Path; + class ParamSFOData { public: @@ -36,7 +38,7 @@ public: const u8 *GetValueData(const std::string &key, unsigned int *size) const; std::vector GetKeys() const; - std::string GenerateFakeID(const std::string &filename = "") const; + std::string GenerateFakeID(const Path &filename) const; std::string GetDiscID(); diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 8d11538045..b3dac49194 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -449,7 +449,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { homebrewTitle = homebrewName; std::string discID = g_paramSFO.GetDiscID(); std::string discVersion = g_paramSFO.GetValueString("DISC_VERSION"); - std::string madeUpID = g_paramSFO.GenerateFakeID(); + std::string madeUpID = g_paramSFO.GenerateFakeID(Path()); std::string title = StringFromFormat("%s : %s", discID.c_str(), homebrewTitle.c_str()); INFO_LOG(LOADER, "%s", title.c_str()); diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index cfb71737da..a4152f4f4b 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -524,7 +524,7 @@ namespace SaveState std::string discId = g_paramSFO.GetValueString("DISC_ID"); std::string discVer = g_paramSFO.GetValueString("DISC_VERSION"); if (discId.empty()) { - discId = g_paramSFO.GenerateFakeID(); + discId = g_paramSFO.GenerateFakeID(Path()); discVer = "1.00"; } return StringFromFormat("%s_%s", discId.c_str(), discVer.c_str()); diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 5325c1e18a..faa1eabdf0 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -496,6 +496,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } if (plan.saveTexture) { + INFO_LOG(G3D, "About to save texture"); actualFmt = VULKAN_8888_FORMAT; } @@ -647,6 +648,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } // Format might be wrong in lowMemoryMode_, so don't save. if (plan.saveTexture && !lowMemoryMode_) { + INFO_LOG(G3D, "Calling NotifyTextureDecoded %08x", entry->addr); + // When hardware texture scaling is enabled, this saves the original. int w = dataScaled ? mipWidth : mipUnscaledWidth; int h = dataScaled ? mipHeight : mipUnscaledHeight; diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 0da51d756f..2ce78f44cc 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -57,7 +57,7 @@ bool CwCheatScreen::TryLoadCheatInfo() { } if ((info->id.empty() || !info->disc_total) && gamePath_.FilePathContainsNoCase("PSP/GAME/")) { - gameID = g_paramSFO.GenerateFakeID(gamePath_.ToString()); + gameID = g_paramSFO.GenerateFakeID(gamePath_); } if (!engine_ || gameID != gameID_) { diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 80beb1d5e4..45a745fbc9 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -472,7 +472,7 @@ public: if ((info_->id.empty() || !info_->disc_total) && gamePath_.FilePathContainsNoCase("PSP/GAME/") && info_->fileType == IdentifiedFileType::PSP_PBP_DIRECTORY) { - info_->id = g_paramSFO.GenerateFakeID(gamePath_.ToString()); + info_->id = g_paramSFO.GenerateFakeID(gamePath_); info_->id_version = info_->id + "_1.00"; info_->region = GAMEREGION_MAX + 1; // Homebrew } @@ -529,7 +529,7 @@ handleELF: // An elf on its own has no usable information, no icons, no nothing. { std::lock_guard lock(info_->lock); - info_->id = g_paramSFO.GenerateFakeID(gamePath_.ToString()); + info_->id = g_paramSFO.GenerateFakeID(gamePath_); info_->id_version = info_->id + "_1.00"; info_->region = GAMEREGION_MAX + 1; // Homebrew diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index dd30045715..9ee83b9fe4 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -452,7 +452,7 @@ UI::EventReturn GameScreen::OnGameSettings(UI::EventParams &e) { if (info && info->paramSFOLoaded) { std::string discID = info->paramSFO.GetValueString("DISC_ID"); if ((discID.empty() || !info->disc_total) && gamePath_.FilePathContainsNoCase("PSP/GAME/")) - discID = g_paramSFO.GenerateFakeID(gamePath_.ToString()); + discID = g_paramSFO.GenerateFakeID(gamePath_); screenManager()->push(new GameSettingsScreen(gamePath_, discID, true)); } return UI::EVENT_DONE;