From 05d49962b69f6597116246776828c2bbc8a98582 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 19 Sep 2018 18:55:33 -0400 Subject: [PATCH 1/2] control_metadata: Move language name array definition to the cpp file This was used in two different translation units (deconstructed_rom_directory and patch_manager). This means we'd be pointlessly duplicating the whole array twice due to it being defined within the header. --- src/core/file_sys/control_metadata.cpp | 8 ++++++++ src/core/file_sys/control_metadata.h | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index e76bf77bf0..b47c95d11f 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp @@ -8,6 +8,14 @@ namespace FileSys { +const std::array LANGUAGE_NAMES = { + "AmericanEnglish", "BritishEnglish", "Japanese", + "French", "German", "LatinAmericanSpanish", + "Spanish", "Italian", "Dutch", + "CanadianFrench", "Portugese", "Russian", + "Korean", "Taiwanese", "Chinese", +}; + std::string LanguageEntry::GetApplicationName() const { return Common::StringFromFixedZeroTerminatedBuffer(application_name.data(), 0x200); } diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 8a510bf468..319bae8218 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -66,12 +66,7 @@ enum class Language : u8 { Default = 255, }; -static constexpr std::array LANGUAGE_NAMES = { - "AmericanEnglish", "BritishEnglish", "Japanese", - "French", "German", "LatinAmericanSpanish", - "Spanish", "Italian", "Dutch", - "CanadianFrench", "Portugese", "Russian", - "Korean", "Taiwanese", "Chinese"}; +extern const std::array LANGUAGE_NAMES; // A class representing the format used by NX metadata files, typically named Control.nacp. // These store application name, dev name, title id, and other miscellaneous data. From 3146502a12125a2511cfda1cd08924d71d378e10 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 19 Sep 2018 19:02:04 -0400 Subject: [PATCH 2/2] control_metadata: Remove unnecessary else within GetLanguageEntry() There's no need to indent the code here, given the if case contains a return statement at the end of it. --- src/core/file_sys/control_metadata.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index b47c95d11f..f11b91399c 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp @@ -31,15 +31,15 @@ NACP::NACP(VirtualFile file) : raw(std::make_unique()) { const LanguageEntry& NACP::GetLanguageEntry(Language language) const { if (language != Language::Default) { return raw->language_entries.at(static_cast(language)); - } else { - for (const auto& language_entry : raw->language_entries) { - if (!language_entry.GetApplicationName().empty()) - return language_entry; - } - - // Fallback to English - return GetLanguageEntry(Language::AmericanEnglish); } + + for (const auto& language_entry : raw->language_entries) { + if (!language_entry.GetApplicationName().empty()) + return language_entry; + } + + // Fallback to English + return GetLanguageEntry(Language::AmericanEnglish); } std::string NACP::GetApplicationName(Language language) const {