From fb16700fe56c6b338ddfad653964b7adee064051 Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Sun, 21 Jul 2019 00:36:04 +0100 Subject: [PATCH 1/9] Update smdh.cpp --- src/core/loader/smdh.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index 3392739c5..e66605db9 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -52,6 +52,10 @@ SMDH::GameRegion SMDH::GetRegion() const { if (region_lockout == 0x7fffffff) { return GameRegion::RegionFree; } + + if (region_lockout == 0x00000050) { + return GameRegion::Taiwan; + } // hack to fix TWN games that support CHN consoles constexpr u32 REGION_COUNT = 7; u32 region = 0; From 17ba67c8c9aa01dcbdc54d37e737787313a6e045 Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Sun, 21 Jul 2019 10:37:29 +0100 Subject: [PATCH 2/9] Remove magic number --- src/core/loader/smdh.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index e66605db9..d2dfe7f78 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -53,10 +53,11 @@ SMDH::GameRegion SMDH::GetRegion() const { return GameRegion::RegionFree; } - if (region_lockout == 0x00000050) { + constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China); + if (region_lockout == taiwan_and_china) { return GameRegion::Taiwan; } // hack to fix TWN games that support CHN consoles - + constexpr u32 REGION_COUNT = 7; u32 region = 0; for (; region < REGION_COUNT; ++region) { From 3f49d9920c15080586cf41573273f32541c00518 Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Sun, 21 Jul 2019 10:39:20 +0100 Subject: [PATCH 3/9] Fix whitespace --- src/core/loader/smdh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index d2dfe7f78..a575d04e1 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -52,12 +52,12 @@ SMDH::GameRegion SMDH::GetRegion() const { if (region_lockout == 0x7fffffff) { return GameRegion::RegionFree; } - + constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China); if (region_lockout == taiwan_and_china) { return GameRegion::Taiwan; } // hack to fix TWN games that support CHN consoles - + constexpr u32 REGION_COUNT = 7; u32 region = 0; for (; region < REGION_COUNT; ++region) { From 834a4873885ae84b7118bac1f05837bdfb549091 Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Sun, 21 Jul 2019 10:51:59 +0100 Subject: [PATCH 4/9] Fix build issue Co-Authored-By: Ben --- src/core/loader/smdh.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index a575d04e1..a7b56360f 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -53,7 +53,8 @@ SMDH::GameRegion SMDH::GetRegion() const { return GameRegion::RegionFree; } - constexpr u32 taiwan_and_china = (1 << GameRegion::Taiwan) & (1 << GameRegion::China); + constexpr u32 taiwan_and_china = + (1 << static_cast(GameRegion::Taiwan)) & (1 << static_cast(GameRegion::China)); if (region_lockout == taiwan_and_china) { return GameRegion::Taiwan; } // hack to fix TWN games that support CHN consoles From e201d44aa9df54af0add21ab67a4521b4e045718 Mon Sep 17 00:00:00 2001 From: Jhynjhiruu Date: Sun, 21 Jul 2019 11:31:07 +0100 Subject: [PATCH 5/9] It's supposed to be OR, not AND! --- src/core/loader/smdh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index a7b56360f..ebb35675c 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -54,7 +54,7 @@ SMDH::GameRegion SMDH::GetRegion() const { } constexpr u32 taiwan_and_china = - (1 << static_cast(GameRegion::Taiwan)) & (1 << static_cast(GameRegion::China)); + (1 << static_cast(GameRegion::Taiwan)) | (1 << static_cast(GameRegion::China)); if (region_lockout == taiwan_and_china) { return GameRegion::Taiwan; } // hack to fix TWN games that support CHN consoles From 848bfaf8cbb37fac1bcdedcba8d58bb212abc341 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Sun, 11 Aug 2019 13:52:08 +0200 Subject: [PATCH 6/9] Dispaly all valid game regions --- src/citra_qt/game_list_p.h | 44 ++++++++++++++++++++------------------ src/core/loader/smdh.cpp | 18 ++++++---------- src/core/loader/smdh.h | 3 +-- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 0309ed083..def99a161 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -75,30 +75,32 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh, * @return QString region */ static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { - const Loader::SMDH::GameRegion region = smdh.GetRegion(); + using GameRegion = Loader::SMDH::GameRegion; + static const std::map regions_map = { + {GameRegion::Japan, QObject::tr("Japan")}, + {GameRegion::NorthAmerica, QObject::tr("North America")}, + {GameRegion::Europe, QObject::tr("Europe")}, + {GameRegion::Australia,QObject::tr("Australia")}, + {GameRegion::China, QObject::tr("China")}, + {GameRegion::Korea, QObject::tr("Korea")}, + {GameRegion::Taiwan, QObject::tr("Taiwan")} + }; - switch (region) { - case Loader::SMDH::GameRegion::Invalid: + std::vector regions = smdh.GetRegions(); + + if (regions.empty()) { return QObject::tr("Invalid region"); - case Loader::SMDH::GameRegion::Japan: - return QObject::tr("Japan"); - case Loader::SMDH::GameRegion::NorthAmerica: - return QObject::tr("North America"); - case Loader::SMDH::GameRegion::Europe: - return QObject::tr("Europe"); - case Loader::SMDH::GameRegion::Australia: - return QObject::tr("Australia"); - case Loader::SMDH::GameRegion::China: - return QObject::tr("China"); - case Loader::SMDH::GameRegion::Korea: - return QObject::tr("Korea"); - case Loader::SMDH::GameRegion::Taiwan: - return QObject::tr("Taiwan"); - case Loader::SMDH::GameRegion::RegionFree: - return QObject::tr("Region free"); - default: - return QObject::tr("Invalid Region"); } + + if (std::find(regions.begin(), regions.end(), GameRegion::RegionFree) != regions.end()) { + return QObject::tr("Region free"); + } + + QString result = regions_map.at(regions.front()); + for (auto region = ++regions.begin(); region != regions.end(); ++region) { + result += "\n" + regions_map.at(*region); + } + return result; } class GameListItem : public QStandardItem { diff --git a/src/core/loader/smdh.cpp b/src/core/loader/smdh.cpp index ebb35675c..417f8d074 100644 --- a/src/core/loader/smdh.cpp +++ b/src/core/loader/smdh.cpp @@ -48,26 +48,20 @@ std::array SMDH::GetShortTitle(Loader::SMDH::TitleLanguage language) return titles[static_cast(language)].short_title; } -SMDH::GameRegion SMDH::GetRegion() const { +std::vector SMDH::GetRegions() const { if (region_lockout == 0x7fffffff) { - return GameRegion::RegionFree; + return std::vector{GameRegion::RegionFree}; } - constexpr u32 taiwan_and_china = - (1 << static_cast(GameRegion::Taiwan)) | (1 << static_cast(GameRegion::China)); - if (region_lockout == taiwan_and_china) { - return GameRegion::Taiwan; - } // hack to fix TWN games that support CHN consoles - constexpr u32 REGION_COUNT = 7; - u32 region = 0; - for (; region < REGION_COUNT; ++region) { + std::vector result; + for (u32 region = 0; region < REGION_COUNT; ++region) { if (region_lockout & (1 << region)) { - return static_cast(region); + result.push_back(static_cast(region)); } } - return GameRegion::Invalid; + return result; } } // namespace Loader diff --git a/src/core/loader/smdh.h b/src/core/loader/smdh.h index 0da1cf855..adeea05a9 100644 --- a/src/core/loader/smdh.h +++ b/src/core/loader/smdh.h @@ -63,7 +63,6 @@ struct SMDH { }; enum class GameRegion { - Invalid = -1, Japan = 0, NorthAmerica = 1, Europe = 2, @@ -88,7 +87,7 @@ struct SMDH { */ std::array GetShortTitle(Loader::SMDH::TitleLanguage language) const; - GameRegion GetRegion() const; + std::vector GetRegions() const; }; static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong"); From 69b32f174c8a9aeae455357be3273a1ae97316ba Mon Sep 17 00:00:00 2001 From: B3n30 Date: Sun, 11 Aug 2019 14:44:31 +0200 Subject: [PATCH 7/9] clang-format --- src/citra_qt/game_list_p.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index def99a161..94fcaf42b 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -80,11 +80,10 @@ static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { {GameRegion::Japan, QObject::tr("Japan")}, {GameRegion::NorthAmerica, QObject::tr("North America")}, {GameRegion::Europe, QObject::tr("Europe")}, - {GameRegion::Australia,QObject::tr("Australia")}, + {GameRegion::Australia, QObject::tr("Australia")}, {GameRegion::China, QObject::tr("China")}, {GameRegion::Korea, QObject::tr("Korea")}, - {GameRegion::Taiwan, QObject::tr("Taiwan")} - }; + {GameRegion::Taiwan, QObject::tr("Taiwan")}}; std::vector regions = smdh.GetRegions(); From ec4fb81c4b8b34c28cd029d305ff088183c2b39f Mon Sep 17 00:00:00 2001 From: B3n30 Date: Sun, 11 Aug 2019 16:22:43 +0200 Subject: [PATCH 8/9] proper translation --- src/citra_qt/game_list_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 94fcaf42b..29d06f756 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -77,13 +77,13 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh, static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { using GameRegion = Loader::SMDH::GameRegion; static const std::map regions_map = { - {GameRegion::Japan, QObject::tr("Japan")}, - {GameRegion::NorthAmerica, QObject::tr("North America")}, - {GameRegion::Europe, QObject::tr("Europe")}, - {GameRegion::Australia, QObject::tr("Australia")}, - {GameRegion::China, QObject::tr("China")}, - {GameRegion::Korea, QObject::tr("Korea")}, - {GameRegion::Taiwan, QObject::tr("Taiwan")}}; + {GameRegion::Japan, QT_TR_NOOP("Japan")}, + {GameRegion::NorthAmerica, QT_TR_NOOP("North America")}, + {GameRegion::Europe, QT_TR_NOOP("Europe")}, + {GameRegion::Australia, QT_TR_NOOP("Australia")}, + {GameRegion::China, QT_TR_NOOP("China")}, + {GameRegion::Korea, QT_TR_NOOP("Korea")}, + {GameRegion::Taiwan, QT_TR_NOOP("Taiwan")}}; std::vector regions = smdh.GetRegions(); From e454f4c05b2d8184c4c0e16bfebc408cf19d0f88 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Sun, 11 Aug 2019 16:44:54 +0200 Subject: [PATCH 9/9] proper translation part2 --- src/citra_qt/game_list_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 29d06f756..96aaffa33 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -76,7 +76,7 @@ static QString GetQStringShortTitleFromSMDH(const Loader::SMDH& smdh, */ static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { using GameRegion = Loader::SMDH::GameRegion; - static const std::map regions_map = { + static const std::map regions_map = { {GameRegion::Japan, QT_TR_NOOP("Japan")}, {GameRegion::NorthAmerica, QT_TR_NOOP("North America")}, {GameRegion::Europe, QT_TR_NOOP("Europe")}, @@ -95,9 +95,9 @@ static QString GetRegionFromSMDH(const Loader::SMDH& smdh) { return QObject::tr("Region free"); } - QString result = regions_map.at(regions.front()); + QString result = QObject::tr(regions_map.at(regions.front())); for (auto region = ++regions.begin(); region != regions.end(); ++region) { - result += "\n" + regions_map.at(*region); + result += QStringLiteral("\n") + QObject::tr(regions_map.at(*region)); } return result; }