From c35da0085f119d057710c86e43ba987fc07da64d Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 9 Apr 2022 13:13:08 +0300 Subject: [PATCH] PARAM.SFO loader improvement --- rpcs3/Emu/Cell/Modules/cellGame.cpp | 4 ++-- rpcs3/Loader/PSF.cpp | 17 +++++++++++------ rpcs3/Loader/PSF.h | 16 +++++++++++----- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 9249df0f8c..c8fa7bbd1f 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -189,7 +189,7 @@ error_code cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName if (!new_data) { const auto cat = psf::get_string(sfo, "CATEGORY", ""); - if (cat != "HG"sv && cat != "AM"sv && cat != "AP"sv && cat != "AT"sv && cat != "AV"sv && cat != "BV"sv && cat != "WT"sv) + if (!psf::is_cat_hdd(cat)) { return { CELL_GAMEDATA_ERROR_BROKEN, fmt::format("CATEGORY='%s'", cat) }; } @@ -594,7 +594,7 @@ error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr>*>(stream.release().get())->obj); } - std::string_view get_string(const registry& psf, const std::string& key, std::string_view def) + std::string_view get_string(const registry& psf, std::string_view key, std::string_view def) { const auto found = psf.find(key); @@ -351,7 +356,7 @@ namespace psf return found->second.as_string(); } - u32 get_integer(const registry& psf, const std::string& key, u32 def) + u32 get_integer(const registry& psf, std::string_view key, u32 def) { const auto found = psf.find(key); diff --git a/rpcs3/Loader/PSF.h b/rpcs3/Loader/PSF.h index 581bd75d87..707d6f7e34 100644 --- a/rpcs3/Loader/PSF.h +++ b/rpcs3/Loader/PSF.h @@ -41,7 +41,7 @@ namespace psf // Construct integer entry, assign the value entry(u32 value); - ~entry(); + ~entry() = default; const std::string& as_string() const; u32 as_integer() const; @@ -55,7 +55,7 @@ namespace psf }; // Define PSF registry as a sorted map of entries: - using registry = std::map; + using registry = std::map>; struct load_result_t { @@ -77,13 +77,13 @@ namespace psf std::vector save_object(const registry&, std::vector&& init = std::vector{}); // Get string value or default value - std::string_view get_string(const registry& psf, const std::string& key, std::string_view def = ""sv); + std::string_view get_string(const registry& psf, std::string_view key, std::string_view def = ""sv); // Get integer value or default value - u32 get_integer(const registry& psf, const std::string& key, u32 def = 0); + u32 get_integer(const registry& psf, std::string_view key, u32 def = 0); // Assign new entry - inline void assign(registry& psf, const std::string& key, entry&& _entry) + inline void assign(registry& psf, std::string_view key, entry&& _entry) { const auto found = psf.find(key); @@ -108,4 +108,10 @@ namespace psf { return {format::array, max_size, value}; } + + // Checks if of HDD catgeory (assumes a valid category is being passed) + constexpr bool is_cat_hdd(std::string_view cat) + { + return cat.size() == 2u && cat[1] != 'D' && cat != "DG"sv && cat != "MS"sv; + } }