From b8b97066dde9b44cf50d7d1b27f8e6ebb51f174d Mon Sep 17 00:00:00 2001 From: jakcron Date: Tue, 31 Jul 2018 13:23:51 +0800 Subject: [PATCH] [nx] Fix behaviour in NACP processing, supported langs don't indicate what title strings are set. --- .../nx/ApplicationControlPropertyBinary.h | 4 +++ .../ApplicationControlPropertyBinary.cpp | 26 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/libnx/include/nx/ApplicationControlPropertyBinary.h b/lib/libnx/include/nx/ApplicationControlPropertyBinary.h index 3dcc41a..ae28816 100644 --- a/lib/libnx/include/nx/ApplicationControlPropertyBinary.h +++ b/lib/libnx/include/nx/ApplicationControlPropertyBinary.h @@ -116,6 +116,9 @@ namespace nx nacp::AttributeFlag getAttributeFlag() const; void setAttributeFlag(nacp::AttributeFlag var); + const fnd::List& getSupportedLanguages() const; + void setSupportedLanguages(const fnd::List& var); + nacp::ParentalControlFlag getParentalControlFlag() const; void setParentalControlFlag(nacp::ParentalControlFlag var); @@ -226,6 +229,7 @@ namespace nx nacp::TouchScreenUsageMode mTouchScreenUsageMode; nacp::AocRegistrationType mAocRegistrationType; nacp::AttributeFlag mAttributeFlag; + fnd::List mSupportedLanguages; nacp::ParentalControlFlag mParentalControlFlag; nacp::ScreenshotMode mScreenshotMode; nacp::VideoCaptureMode mVideoCaptureMode; diff --git a/lib/libnx/source/ApplicationControlPropertyBinary.cpp b/lib/libnx/source/ApplicationControlPropertyBinary.cpp index 73932e6..a6ca675 100644 --- a/lib/libnx/source/ApplicationControlPropertyBinary.cpp +++ b/lib/libnx/source/ApplicationControlPropertyBinary.cpp @@ -19,6 +19,7 @@ void nx::ApplicationControlPropertyBinary::operator=(const ApplicationControlPro mTouchScreenUsageMode = other.mTouchScreenUsageMode; mAocRegistrationType = other.mAocRegistrationType; mAttributeFlag = other.mAttributeFlag; + mSupportedLanguages = other.mSupportedLanguages; mParentalControlFlag = other.mParentalControlFlag; mScreenshotMode = other.mScreenshotMode; mVideoCaptureMode = other.mVideoCaptureMode; @@ -61,6 +62,7 @@ bool nx::ApplicationControlPropertyBinary::operator==(const ApplicationControlPr && (mTouchScreenUsageMode == other.mTouchScreenUsageMode) \ && (mAocRegistrationType == other.mAocRegistrationType) \ && (mAttributeFlag == other.mAttributeFlag) \ + && (mSupportedLanguages == other.mSupportedLanguages) \ && (mParentalControlFlag == other.mParentalControlFlag) \ && (mScreenshotMode == other.mScreenshotMode) \ && (mVideoCaptureMode == other.mVideoCaptureMode) \ @@ -107,13 +109,17 @@ void nx::ApplicationControlPropertyBinary::toBytes() sApplicationControlProperty* data = (sApplicationControlProperty*)mRawBinary.data(); // strings - uint32_t supported_langs = 0; for (size_t i = 0; i < mTitle.size(); i++) { - supported_langs = _BIT(mTitle[i].language); strncpy(data->title[mTitle[i].language].name, mTitle[i].name.c_str(), nacp::kNameLength); strncpy(data->title[mTitle[i].language].publisher, mTitle[i].publisher.c_str(), nacp::kPublisherLength); } + + uint32_t supported_langs = 0; + for (size_t i = 0; i < mSupportedLanguages.size(); i++) + { + supported_langs |= _BIT(mSupportedLanguages[i]); + } data->supported_language_flag = supported_langs; strncpy(data->isbn, mIsbn.c_str(), nacp::kIsbnLength); @@ -194,10 +200,15 @@ void nx::ApplicationControlPropertyBinary::fromBytes(const byte_t* bytes, size_t for (size_t i = 0; i < nacp::kMaxLanguageCount; i++) { if (_HAS_BIT(data->supported_language_flag.get(), i)) + { + mSupportedLanguages.addElement((nacp::Language)i); + } + if (data->title[i].name[0] != '\0' && data->title[i].publisher[0] != '\0') { mTitle.addElement({ (nacp::Language)i, std::string(data->title[i].name, _MIN(strlen(data->title[i].name), nacp::kNameLength)), std::string(data->title[i].publisher, _MIN(strlen(data->title[i].publisher), nacp::kPublisherLength)) }); } } + if (data->isbn[0] != 0) mIsbn = std::string(data->isbn, _MIN(strlen(data->isbn), nacp::kIsbnLength)); if (data->display_version[0] != 0) @@ -278,6 +289,7 @@ void nx::ApplicationControlPropertyBinary::clear() mTouchScreenUsageMode = nacp::TOUCH_None; mAocRegistrationType = nacp::AOC_AllOnLaunch; mAttributeFlag = nacp::ATTR_None; + mSupportedLanguages.clear(); mParentalControlFlag = nacp::PC_None; mScreenshotMode = nacp::SCRN_Allow; mVideoCaptureMode = nacp::VCAP_Disable; @@ -372,6 +384,16 @@ void nx::ApplicationControlPropertyBinary::setAttributeFlag(nacp::AttributeFlag mAttributeFlag = var; } +const fnd::List& nx::ApplicationControlPropertyBinary::getSupportedLanguages() const +{ + return mSupportedLanguages; +} + +void nx::ApplicationControlPropertyBinary::setSupportedLanguages(const fnd::List& var) +{ + mSupportedLanguages = var; +} + nx::nacp::ParentalControlFlag nx::ApplicationControlPropertyBinary::getParentalControlFlag() const { return mParentalControlFlag;