Add add-on (DLC) support #1519

Manually merged
github merged 1 commit from gh-pr/1519/head into gh-pr/1519/base 2026-11-26 09:58:35 +00:00
Owner

@⁠Pipe530 on GitHub · 2026-10-15 04:36 UTC · original
Pipe530:pipe530-dlc-addcont-support → main · +633 −17 · 18 files · 1 commits · merged 2026-10-16 00:09 UTC

Adds support for extracted PS5 add-on packages through the global Add-ons folder setting and --addcont-dir. Shared discovery validates content IDs, filters packages by title before deduplication, and skips base-game and malformed metadata.

The launcher’s Additional Content dialog lists names and icons with fallbacks. Detected packages are reported as owned and can be mounted at /addcontN/. Existing GTA V entitlements remain first in the list, followed by detected add-ons.

Validation: Linux launcher/emulator build and five focused CTest checks passed, including regressions for combined entitlement lists, title filtering, mounted file access, duplicate mounts, and the 64-mount limit. In-game validation remains to be done for this revision.

**@⁠Pipe530** on GitHub · 2026-10-15 04:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519) `Pipe530:pipe530-dlc-addcont-support` → `main` · +633 −17 · 18 files · 1 commits · merged 2026-10-16 00:09 UTC Adds support for extracted PS5 add-on packages through the global Add-ons folder setting and `--addcont-dir`. Shared discovery validates content IDs, filters packages by title before deduplication, and skips base-game and malformed metadata. The launcher’s Additional Content dialog lists names and icons with fallbacks. Detected packages are reported as owned and can be mounted at `/addcontN/`. Existing GTA V entitlements remain first in the list, followed by detected add-ons. Validation: Linux launcher/emulator build and five focused CTest checks passed, including regressions for combined entitlement lists, title filtering, mounted file access, duplicate mounts, and the 64-mount limit. In-game validation remains to be done for this revision.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:33 +00:00
github manually merged commit 4eb35a8de8 into gh-pr/1519/base 2026-11-26 09:58:35 +00:00
github-bot referenced this pull request from a commit 2026-11-26 09:59:50 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original · edited 2026-10-16 00:10 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fdfc926-8eb2-40b8-b2c2-f80cd3278992
📥 Commits

Reviewing files that changed from the base of the PR and between 39a8606f585316a42a2af83f347516233b7e5646 and 065cb72216b2d8c3d3dd0102e4629104c3af0179.

📒 Files selected for processing: 2
  • src/launcher/src/additionalContentDialog.cpp
  • src/loader/addContent.cpp
🚧 Files skipped from review as they are similar to previous changes: 2
  • src/launcher/src/additionalContentDialog.cpp
  • src/loader/addContent.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The launcher now stores an add-ons directory, passes it to the emulator, and provides a dialog to browse matching content packages. The emulator loads package entries filtered by title ID. The loader exposes entries through entitlement lookup and enumeration. App-content APIs use those entries to mount and unmount content.

Priority: ➖ Normal

Change: Feature

Merge Risk: 🔵 Low · up to 065cb

Add-on handling has a few minor correctness gaps. Add-ons for other titles can be matched or registered, and clearing global settings can leave the add-ons folder set. These do not block normal use, but they are worth fixing before or soon after merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely summarizes the main change: support for add-on (DLC) content.
Description check Passed The description directly explains the add-on discovery, launcher settings, mounting, entitlement reporting, validation, and remaining in-game testing.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#issuecomment-6184695571) · edited 2026-10-16 00:10 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1519?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2fdfc926-8eb2-40b8-b2c2-f80cd3278992` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 39a8606f585316a42a2af83f347516233b7e5646 and 065cb72216b2d8c3d3dd0102e4629104c3af0179. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 2</strong></summary> <dl> <dd> * `src/launcher/src/additionalContentDialog.cpp` * `src/loader/addContent.cpp` </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes: 2</strong></summary> <dl> <dd> * src/launcher/src/additionalContentDialog.cpp * src/loader/addContent.cpp </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The launcher now stores an add-ons directory, passes it to the emulator, and provides a dialog to browse matching content packages. The emulator loads package entries filtered by title ID. The loader exposes entries through entitlement lookup and enumeration. App-content APIs use those entries to mount and unmount content. </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"065cb72216b2d8c3d3dd0102e4629104c3af0179" --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>065cb</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `065cb` --> <!-- final_review_risk_coverage:{"sourceCommitId":"065cb72216b2d8c3d3dd0102e4629104c3af0179","coveredCommitId":"065cb72216b2d8c3d3dd0102e4629104c3af0179","kind":"reviewed"} --> Add-on handling has a few minor correctness gaps. Add-ons for other titles can be matched or registered, and clearing global settings can leave the add-ons folder set. These do not block normal use, but they are worth fixing before or soon after merge. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 15 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely summarizes the main change: support for add-on (DLC) content. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the add-on discovery, launcher settings, mounting, entitlement reporting, validation, and remaining in-game testing. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1519)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original
On src/emulator.cpp line 223 (outdated):

@@ -217,6 +218,9 @@ void Run(const RunOptions& options) {
 
 	MountSandboxDirs();
 
+	std::string addcont_title_id;
+	Loader::SystemContentParamSfoGetString("TITLE_ID", &addcont_title_id);
+	Loader::AddContentLoad(options.addcont_dir, addcont_title_id);

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reuse the title-ID lookup and fall back to CONTENT_ID for PS5 titles.

PS5 titles often have no TITLE_ID; ResolveTitleId in libAppContent.cpp handles that case with a CONTENT_ID fallback. This code ignores the getter's return value and passes an empty string. AddContentLoad then skips the title filter, so add-ons for every title in the folder are registered and reported as owned. Resolve the title ID from CONTENT_ID here as well, and reuse title_id from line 204.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#discussion_r4279132635) On `src/emulator.cpp` line 223 (outdated): ```diff @@ -217,6 +218,9 @@ void Run(const RunOptions& options) { MountSandboxDirs(); + std::string addcont_title_id; + Loader::SystemContentParamSfoGetString("TITLE_ID", &addcont_title_id); + Loader::AddContentLoad(options.addcont_dir, addcont_title_id); ``` **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Reuse the title-ID lookup and fall back to `CONTENT_ID` for PS5 titles.** PS5 titles often have no `TITLE_ID`; `ResolveTitleId` in `libAppContent.cpp` handles that case with a `CONTENT_ID` fallback. This code ignores the getter's return value and passes an empty string. `AddContentLoad` then skips the title filter, so add-ons for every title in the folder are registered and reported as owned. Resolve the title ID from `CONTENT_ID` here as well, and reuse `title_id` from line 204. <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:49d86db6f522e30faac7355a --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original · edited 2026-10-15 11:38 UTC
On src/launcher/src/additionalContentDialog.cpp line 62 (outdated):

@@ -0,0 +1,258 @@
+#include "additionalContentDialog.h"
+
+#include "configuration.h"
+#include "gameContent.h"
+
+#include <QDesktopServices>
+#include <QDir>
+#include <QDirIterator>
+#include <QFile>
+#include <QFileInfo>
+#include <QHBoxLayout>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QLabel>
+#include <QListWidget>
+#include <QPushButton>
+#include <QRegularExpression>
+#include <QStandardPaths>
+#include <QUrl>
+#include <QVBoxLayout>
+
+#include <map>
+
+namespace {
+
+struct DlcEntry {
+	QString content_id;
+	QString package_dir;
+	QString title;
+};
+
+bool IsValidContentId(const QString& id) {
+	static const QRegularExpression re(QStringLiteral("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$"));
+	return id.size() == 36 && re.match(id).hasMatch();
+}
+
+QString LabelOf(const QString& content_id) {
+	const auto dash = content_id.lastIndexOf('-');
+	return dash < 0 ? QString() : content_id.mid(dash + 1);
+}
+
+QString TitleOf(const QJsonObject& root) {
+	const auto loc = root.value(QStringLiteral("localizedParameters")).toObject();
+	QString    title = loc.value(loc.value(QStringLiteral("defaultLanguage")).toString())
+	                    .toObject()
+	                    .value(QStringLiteral("titleName"))
+	                    .toString();
+	for (auto it = loc.begin(); title.isEmpty() && it != loc.end(); ++it) {
+		title = it.value().toObject().value(QStringLiteral("titleName")).toString();
+	}
+	return title.isEmpty() ? root.value(QStringLiteral("titleName")).toString() : title;
+}
+
+void AddEntry(std::map<QString, DlcEntry>& entries, const QString& content_id,
+              const QString& package_dir, const QString& title) {
+	const auto label = LabelOf(content_id);
+	if (!IsValidContentId(content_id) || label.isEmpty()) {
+		return;
+	}
+	auto it = entries.find(label);
+	if (it == entries.end()) {
+		entries[label] = {content_id, package_dir, title};

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

sed -n '25,105p' src/launcher/src/additionalContentDialog.cpp
sed -n '190,245p' src/launcher/src/additionalContentDialog.cpp
sed -n '38,165p' src/loader/addContent.cpp

Repository: KytyPS5/KytyPS5

Length of output: 9220


🏁 Script executed:

sed -n '145,235p' src/launcher/src/additionalContentDialog.cpp
sed -n '1,75p' src/loader/addContent.cpp

Repository: KytyPS5/KytyPS5

Length of output: 5506


Filter by title ID before deduplicating labels.

Two titles can have valid content IDs with the same final label. AddEntry() and AddOrUpdateEntry() keep one entry per label before filtering by title ID. If the other title is scanned first, the selected title’s add-on is omitted from both the dialog and runtime registration.

Pass the requested title ID into the parsing or insertion path and apply the existing title predicate before inserting into either label map. Keep label deduplication for entries belonging to the selected title.

✅ Addressed in commit 065cb72

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#discussion_r4279132645) · edited 2026-10-15 11:38 UTC On `src/launcher/src/additionalContentDialog.cpp` line 62 (outdated): ```diff @@ -0,0 +1,258 @@ +#include "additionalContentDialog.h" + +#include "configuration.h" +#include "gameContent.h" + +#include <QDesktopServices> +#include <QDir> +#include <QDirIterator> +#include <QFile> +#include <QFileInfo> +#include <QHBoxLayout> +#include <QJsonDocument> +#include <QJsonObject> +#include <QLabel> +#include <QListWidget> +#include <QPushButton> +#include <QRegularExpression> +#include <QStandardPaths> +#include <QUrl> +#include <QVBoxLayout> + +#include <map> + +namespace { + +struct DlcEntry { + QString content_id; + QString package_dir; + QString title; +}; + +bool IsValidContentId(const QString& id) { + static const QRegularExpression re(QStringLiteral("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$")); + return id.size() == 36 && re.match(id).hasMatch(); +} + +QString LabelOf(const QString& content_id) { + const auto dash = content_id.lastIndexOf('-'); + return dash < 0 ? QString() : content_id.mid(dash + 1); +} + +QString TitleOf(const QJsonObject& root) { + const auto loc = root.value(QStringLiteral("localizedParameters")).toObject(); + QString title = loc.value(loc.value(QStringLiteral("defaultLanguage")).toString()) + .toObject() + .value(QStringLiteral("titleName")) + .toString(); + for (auto it = loc.begin(); title.isEmpty() && it != loc.end(); ++it) { + title = it.value().toObject().value(QStringLiteral("titleName")).toString(); + } + return title.isEmpty() ? root.value(QStringLiteral("titleName")).toString() : title; +} + +void AddEntry(std::map<QString, DlcEntry>& entries, const QString& content_id, + const QString& package_dir, const QString& title) { + const auto label = LabelOf(content_id); + if (!IsValidContentId(content_id) || label.isEmpty()) { + return; + } + auto it = entries.find(label); + if (it == entries.end()) { + entries[label] = {content_id, package_dir, title}; ``` **🎯 Functional Correctness** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '25,105p' src/launcher/src/additionalContentDialog.cpp sed -n '190,245p' src/launcher/src/additionalContentDialog.cpp sed -n '38,165p' src/loader/addContent.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 9220 --- 🏁 Script executed: ```bash sed -n '145,235p' src/launcher/src/additionalContentDialog.cpp sed -n '1,75p' src/loader/addContent.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 5506 --- </details> **Filter by title ID before deduplicating labels.** Two titles can have valid content IDs with the same final label. `AddEntry()` and `AddOrUpdateEntry()` keep one entry per label before filtering by title ID. If the other title is scanned first, the selected title’s add-on is omitted from both the dialog and runtime registration. Pass the requested title ID into the parsing or insertion path and apply the existing title predicate before inserting into either label map. Keep label deduplication for entries belonging to the selected title. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:ead27fc7eba073219e6543d3 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 065cb72
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original
On src/launcher/src/additionalContentDialog.cpp line 205 (outdated):

@@ -0,0 +1,258 @@
+#include "additionalContentDialog.h"
+
+#include "configuration.h"
+#include "gameContent.h"
+
+#include <QDesktopServices>
+#include <QDir>
+#include <QDirIterator>
+#include <QFile>
+#include <QFileInfo>
+#include <QHBoxLayout>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QLabel>
+#include <QListWidget>
+#include <QPushButton>
+#include <QRegularExpression>
+#include <QStandardPaths>
+#include <QUrl>
+#include <QVBoxLayout>
+
+#include <map>
+
+namespace {
+
+struct DlcEntry {
+	QString content_id;
+	QString package_dir;
+	QString title;
+};
+
+bool IsValidContentId(const QString& id) {
+	static const QRegularExpression re(QStringLiteral("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$"));
+	return id.size() == 36 && re.match(id).hasMatch();
+}
+
+QString LabelOf(const QString& content_id) {
+	const auto dash = content_id.lastIndexOf('-');
+	return dash < 0 ? QString() : content_id.mid(dash + 1);
+}
+
+QString TitleOf(const QJsonObject& root) {
+	const auto loc = root.value(QStringLiteral("localizedParameters")).toObject();
+	QString    title = loc.value(loc.value(QStringLiteral("defaultLanguage")).toString())
+	                    .toObject()
+	                    .value(QStringLiteral("titleName"))
+	                    .toString();
+	for (auto it = loc.begin(); title.isEmpty() && it != loc.end(); ++it) {
+		title = it.value().toObject().value(QStringLiteral("titleName")).toString();
+	}
+	return title.isEmpty() ? root.value(QStringLiteral("titleName")).toString() : title;
+}
+
+void AddEntry(std::map<QString, DlcEntry>& entries, const QString& content_id,
+              const QString& package_dir, const QString& title) {
+	const auto label = LabelOf(content_id);
+	if (!IsValidContentId(content_id) || label.isEmpty()) {
+		return;
+	}
+	auto it = entries.find(label);
+	if (it == entries.end()) {
+		entries[label] = {content_id, package_dir, title};
+	} else if (it->second.package_dir.isEmpty() && !package_dir.isEmpty()) {
+		it->second.package_dir = package_dir;
+	}
+}
+
+void ParseParamJson(const QString& path, std::map<QString, DlcEntry>& entries) {
+	QFile f(path);
+	if (!f.open(QIODevice::ReadOnly)) {
+		return;
+	}
+	const auto root = QJsonDocument::fromJson(f.readAll()).object();
+	const auto id   = root.value(QStringLiteral("contentId")).toString();
+	if (id.isEmpty()) {
+		return;
+	}
+	QDir dir = QFileInfo(path).dir();
+	if (dir.dirName() == QStringLiteral("sce_sys")) {
+		dir.cdUp();
+	}
+	AddEntry(entries, id, dir.absolutePath(), TitleOf(root));
+}
+
+QLabel* IconLabel(const QPixmap& pixmap, int size, QWidget* parent) {
+	auto* label = new QLabel(parent);
+	label->setFixedSize(size, size);
+	if (pixmap.isNull()) {
+		label->setStyleSheet(QStringLiteral("background: #3a3d45;"));
+	} else {
+		label->setPixmap(pixmap.scaled(size, size, Qt::KeepAspectRatioByExpanding,
+		                               Qt::SmoothTransformation));
+	}
+	return label;
+}
+
+const char* const STYLE =
+    "QDialog { background: qlineargradient(x1:0,y1:0,x2:1,y2:1, stop:0 #1d1f24, stop:1 #101114); }"
+    "QLabel { color: #ffffff; background: transparent; }"
+    "QLabel#subtle { color: #9aa0aa; }"
+    "QLabel#section { color: #c9ced6; font-size: 15px; }"
+    "QListWidget { background: transparent; border: none; outline: none; }"
+    "QListWidget::item { border-bottom: 1px solid #2c2f36; }"
+    "QListWidget::item:hover { background: rgba(255,255,255,18); }"
+    "QListWidget::item:selected { background: rgba(255,255,255,30); }"
+    "QPushButton { color: #ffffff; background: #2c2f36; border: none; border-radius: 15px; "
+    "padding: 7px 20px; }"
+    "QPushButton:hover { background: #3d414b; }";
+
+} // namespace
+
+AdditionalContentDialog::AdditionalContentDialog(const Configuration& game, const QString& folder,
+                                                 QWidget* parent)
+    : QDialog(parent), m_title_id(game.title_id.trimmed().toUpper()), m_game_name(game.name),
+      m_folder(folder.trimmed()) {
+	setAttribute(Qt::WA_DeleteOnClose);
+	setWindowTitle(tr("Additional Content - %1").arg(game.name));
+	resize(820, 560);
+	setStyleSheet(QString::fromLatin1(STYLE));
+
+	const auto icon_data = GameContent::ReadFile(
+	    game.basedir, QStringLiteral("sce_sys/icon0.png"), GameContent::MaxImageSize);
+	if (!icon_data.isEmpty()) {
+		m_game_icon.loadFromData(icon_data);
+	}
+
+	auto* layout = new QVBoxLayout(this);
+	layout->setContentsMargins(36, 28, 36, 24);
+	layout->setSpacing(10);
+
+	auto* header = new QHBoxLayout;
+	header->setSpacing(16);
+	header->addWidget(IconLabel(m_game_icon, 72, this));
+	auto* titles = new QVBoxLayout;
+	titles->setSpacing(2);
+	auto* name = new QLabel(m_game_name, this);
+	name->setStyleSheet(QStringLiteral("font-size: 24px;"));
+	auto* subtitle = new QLabel(m_title_id, this);
+	subtitle->setObjectName(QStringLiteral("subtle"));
+	subtitle->setStyleSheet(QStringLiteral("font-size: 15px;"));
+	titles->addStretch();
+	titles->addWidget(name);
+	titles->addWidget(subtitle);
+	titles->addStretch();
+	header->addLayout(titles, 1);
+	m_count = new QLabel(this);
+	m_count->setObjectName(QStringLiteral("subtle"));
+	m_count->setStyleSheet(QStringLiteral("font-size: 15px;"));
+	header->addWidget(m_count, 0, Qt::AlignTop);
+	layout->addLayout(header);
+
+	layout->addSpacing(18);
+	auto* section = new QLabel(tr("Add-ons"), this);
+	section->setObjectName(QStringLiteral("section"));
+	layout->addWidget(section);
+
+	m_list = new QListWidget(this);
+	m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+	m_list->setFrameShape(QFrame::NoFrame);
+	layout->addWidget(m_list, 1);
+
+	m_empty = new QLabel(this);
+	m_empty->setObjectName(QStringLiteral("subtle"));
+	m_empty->setAlignment(Qt::AlignCenter);
+	m_empty->setWordWrap(true);
+	m_empty->setStyleSheet(QStringLiteral("font-size: 16px;"));
+	layout->addWidget(m_empty, 1);
+
+	auto* buttons = new QHBoxLayout;
+	buttons->addStretch();
+	auto* refresh = new QPushButton(tr("Refresh"), this);
+	auto* open    = new QPushButton(tr("Open folder"), this);
+	auto* close   = new QPushButton(tr("Close"), this);
+	buttons->addWidget(refresh);
+	buttons->addWidget(open);
+	open->setVisible(!m_folder.isEmpty());
+	buttons->addWidget(close);
+	layout->addLayout(buttons);
+
+	connect(refresh, &QPushButton::clicked, this, &AdditionalContentDialog::Scan);
+	connect(open, &QPushButton::clicked, this, &AdditionalContentDialog::OpenFolder);
+	connect(close, &QPushButton::clicked, this, &QDialog::close);
+
+	Scan();
+}
+
+void AdditionalContentDialog::Scan() {
+	m_list->clear();
+
+	std::map<QString, DlcEntry> entries;
+	if (!m_folder.isEmpty() && QDir(m_folder).exists()) {
+		QDirIterator it(m_folder, QDir::Files, QDirIterator::Subdirectories);
+		while (it.hasNext()) {
+			const auto path = it.next();
+			const auto name = QFileInfo(path).fileName();
+			if (name.compare(QStringLiteral("param.json"), Qt::CaseInsensitive) == 0) {
+				ParseParamJson(path, entries);
+			}
+		}
+	}
+
+	int count = 0;
+	for (const auto& [label, entry]: entries) {
+		if (!m_title_id.isEmpty() && !entry.content_id.contains(m_title_id, Qt::CaseInsensitive)) {
+			continue;

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '20,90p' src/launcher/src/additionalContentDialog.cpp
sed -n '187,234p' src/launcher/src/additionalContentDialog.cpp

Repository: KytyPS5/KytyPS5

Length of output: 4015


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- dialog references and surrounding implementation ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'AdditionalContentDialog' -e 'm_title_id' -e 'IsValidContentId' -e 'content_id.contains' src || test "$?" -eq 1
printf '%s\n' '--- dialog source ---'
sed -n '1,280p' src/launcher/src/additionalContentDialog.cpp
printf '%s\n' '--- declarations and callers ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'AdditionalContent' -e 'additionalContent' src || test "$?" -eq 1
printf '%s\n' '--- matching content-ID logic ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'contentId' -e 'content_id' -e 'ContentId' -e 'addcont' src | head -240
printf '%s\n' '--- PR diff for dialog and related matching code ---'
git diff --no-ext-diff --unified=30 9e41d8320a2774b303fbad344c2347e8d0292e83 39a8606f585316a42a2af83f347516233b7e5646 -- src/launcher/src/additionalContentDialog.cpp src | sed -n '1,520p'

Repository: KytyPS5/KytyPS5

Length of output: 37115


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- context-menu caller ---'
sed -n '1228,1272p' src/launcher/src/configurationListWidget.cpp
printf '%s\n' '--- loader content-ID parsing and filtering ---'
sed -n '1,185p' src/loader/addContent.cpp
sed -n '1,90p' src/loader/addContent.h
printf '%s\n' '--- title-ID/content-ID consumers and tests ---'
rg -n -F --glob '*.{cpp,h,hpp,json,md,txt}' -e 'TryGetTitleIdFromContentId' -e 'CUSA12345' -e 'content_id.find(title_id)' -e 'contentId' tests src docs || test "$?" -eq 1
printf '%s\n' '--- current exact source lines for proposed dialog correction ---'
nl -ba src/launcher/src/additionalContentDialog.cpp | sed -n '180,216p'

Repository: KytyPS5/KytyPS5

Length of output: 11839


Match the content ID’s title segment in the dialog.

When a foreign valid content ID contains the selected title ID in its final label, AdditionalContentDialog::Scan() adds it to the list. Users then see a foreign DLC for the selected game. Loader-only matching or deduplication fixes do not change this dialog predicate.

Compare the nine-character segment between the first - and _ with m_title_id.

Suggested fix
-		if (!m_title_id.isEmpty() && !entry.content_id.contains(m_title_id, Qt::CaseInsensitive)) {
+		const auto dash       = entry.content_id.indexOf('-');
+		const auto underscore = entry.content_id.indexOf('_', dash + 1);
+		if (!m_title_id.isEmpty() &&
+		    entry.content_id.mid(dash + 1, underscore - dash - 1) != m_title_id) {
 			continue;
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	std::map<QString, DlcEntry> entries;
	if (!m_folder.isEmpty() && QDir(m_folder).exists()) {
		QDirIterator it(m_folder, QDir::Files, QDirIterator::Subdirectories);
		while (it.hasNext()) {
			const auto path = it.next();
			const auto name = QFileInfo(path).fileName();
			if (name.compare(QStringLiteral("param.json"), Qt::CaseInsensitive) == 0) {
				ParseParamJson(path, entries);
			}
		}
	}

	int count = 0;
	for (const auto& [label, entry]: entries) {
		const auto dash       = entry.content_id.indexOf('-');
		const auto underscore = entry.content_id.indexOf('_', dash + 1);
		if (!m_title_id.isEmpty() &&
		    entry.content_id.mid(dash + 1, underscore - dash - 1) != m_title_id) {
			continue;
**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#discussion_r4279132651) On `src/launcher/src/additionalContentDialog.cpp` line 205 (outdated): ```diff @@ -0,0 +1,258 @@ +#include "additionalContentDialog.h" + +#include "configuration.h" +#include "gameContent.h" + +#include <QDesktopServices> +#include <QDir> +#include <QDirIterator> +#include <QFile> +#include <QFileInfo> +#include <QHBoxLayout> +#include <QJsonDocument> +#include <QJsonObject> +#include <QLabel> +#include <QListWidget> +#include <QPushButton> +#include <QRegularExpression> +#include <QStandardPaths> +#include <QUrl> +#include <QVBoxLayout> + +#include <map> + +namespace { + +struct DlcEntry { + QString content_id; + QString package_dir; + QString title; +}; + +bool IsValidContentId(const QString& id) { + static const QRegularExpression re(QStringLiteral("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$")); + return id.size() == 36 && re.match(id).hasMatch(); +} + +QString LabelOf(const QString& content_id) { + const auto dash = content_id.lastIndexOf('-'); + return dash < 0 ? QString() : content_id.mid(dash + 1); +} + +QString TitleOf(const QJsonObject& root) { + const auto loc = root.value(QStringLiteral("localizedParameters")).toObject(); + QString title = loc.value(loc.value(QStringLiteral("defaultLanguage")).toString()) + .toObject() + .value(QStringLiteral("titleName")) + .toString(); + for (auto it = loc.begin(); title.isEmpty() && it != loc.end(); ++it) { + title = it.value().toObject().value(QStringLiteral("titleName")).toString(); + } + return title.isEmpty() ? root.value(QStringLiteral("titleName")).toString() : title; +} + +void AddEntry(std::map<QString, DlcEntry>& entries, const QString& content_id, + const QString& package_dir, const QString& title) { + const auto label = LabelOf(content_id); + if (!IsValidContentId(content_id) || label.isEmpty()) { + return; + } + auto it = entries.find(label); + if (it == entries.end()) { + entries[label] = {content_id, package_dir, title}; + } else if (it->second.package_dir.isEmpty() && !package_dir.isEmpty()) { + it->second.package_dir = package_dir; + } +} + +void ParseParamJson(const QString& path, std::map<QString, DlcEntry>& entries) { + QFile f(path); + if (!f.open(QIODevice::ReadOnly)) { + return; + } + const auto root = QJsonDocument::fromJson(f.readAll()).object(); + const auto id = root.value(QStringLiteral("contentId")).toString(); + if (id.isEmpty()) { + return; + } + QDir dir = QFileInfo(path).dir(); + if (dir.dirName() == QStringLiteral("sce_sys")) { + dir.cdUp(); + } + AddEntry(entries, id, dir.absolutePath(), TitleOf(root)); +} + +QLabel* IconLabel(const QPixmap& pixmap, int size, QWidget* parent) { + auto* label = new QLabel(parent); + label->setFixedSize(size, size); + if (pixmap.isNull()) { + label->setStyleSheet(QStringLiteral("background: #3a3d45;")); + } else { + label->setPixmap(pixmap.scaled(size, size, Qt::KeepAspectRatioByExpanding, + Qt::SmoothTransformation)); + } + return label; +} + +const char* const STYLE = + "QDialog { background: qlineargradient(x1:0,y1:0,x2:1,y2:1, stop:0 #1d1f24, stop:1 #101114); }" + "QLabel { color: #ffffff; background: transparent; }" + "QLabel#subtle { color: #9aa0aa; }" + "QLabel#section { color: #c9ced6; font-size: 15px; }" + "QListWidget { background: transparent; border: none; outline: none; }" + "QListWidget::item { border-bottom: 1px solid #2c2f36; }" + "QListWidget::item:hover { background: rgba(255,255,255,18); }" + "QListWidget::item:selected { background: rgba(255,255,255,30); }" + "QPushButton { color: #ffffff; background: #2c2f36; border: none; border-radius: 15px; " + "padding: 7px 20px; }" + "QPushButton:hover { background: #3d414b; }"; + +} // namespace + +AdditionalContentDialog::AdditionalContentDialog(const Configuration& game, const QString& folder, + QWidget* parent) + : QDialog(parent), m_title_id(game.title_id.trimmed().toUpper()), m_game_name(game.name), + m_folder(folder.trimmed()) { + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("Additional Content - %1").arg(game.name)); + resize(820, 560); + setStyleSheet(QString::fromLatin1(STYLE)); + + const auto icon_data = GameContent::ReadFile( + game.basedir, QStringLiteral("sce_sys/icon0.png"), GameContent::MaxImageSize); + if (!icon_data.isEmpty()) { + m_game_icon.loadFromData(icon_data); + } + + auto* layout = new QVBoxLayout(this); + layout->setContentsMargins(36, 28, 36, 24); + layout->setSpacing(10); + + auto* header = new QHBoxLayout; + header->setSpacing(16); + header->addWidget(IconLabel(m_game_icon, 72, this)); + auto* titles = new QVBoxLayout; + titles->setSpacing(2); + auto* name = new QLabel(m_game_name, this); + name->setStyleSheet(QStringLiteral("font-size: 24px;")); + auto* subtitle = new QLabel(m_title_id, this); + subtitle->setObjectName(QStringLiteral("subtle")); + subtitle->setStyleSheet(QStringLiteral("font-size: 15px;")); + titles->addStretch(); + titles->addWidget(name); + titles->addWidget(subtitle); + titles->addStretch(); + header->addLayout(titles, 1); + m_count = new QLabel(this); + m_count->setObjectName(QStringLiteral("subtle")); + m_count->setStyleSheet(QStringLiteral("font-size: 15px;")); + header->addWidget(m_count, 0, Qt::AlignTop); + layout->addLayout(header); + + layout->addSpacing(18); + auto* section = new QLabel(tr("Add-ons"), this); + section->setObjectName(QStringLiteral("section")); + layout->addWidget(section); + + m_list = new QListWidget(this); + m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + m_list->setFrameShape(QFrame::NoFrame); + layout->addWidget(m_list, 1); + + m_empty = new QLabel(this); + m_empty->setObjectName(QStringLiteral("subtle")); + m_empty->setAlignment(Qt::AlignCenter); + m_empty->setWordWrap(true); + m_empty->setStyleSheet(QStringLiteral("font-size: 16px;")); + layout->addWidget(m_empty, 1); + + auto* buttons = new QHBoxLayout; + buttons->addStretch(); + auto* refresh = new QPushButton(tr("Refresh"), this); + auto* open = new QPushButton(tr("Open folder"), this); + auto* close = new QPushButton(tr("Close"), this); + buttons->addWidget(refresh); + buttons->addWidget(open); + open->setVisible(!m_folder.isEmpty()); + buttons->addWidget(close); + layout->addLayout(buttons); + + connect(refresh, &QPushButton::clicked, this, &AdditionalContentDialog::Scan); + connect(open, &QPushButton::clicked, this, &AdditionalContentDialog::OpenFolder); + connect(close, &QPushButton::clicked, this, &QDialog::close); + + Scan(); +} + +void AdditionalContentDialog::Scan() { + m_list->clear(); + + std::map<QString, DlcEntry> entries; + if (!m_folder.isEmpty() && QDir(m_folder).exists()) { + QDirIterator it(m_folder, QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) { + const auto path = it.next(); + const auto name = QFileInfo(path).fileName(); + if (name.compare(QStringLiteral("param.json"), Qt::CaseInsensitive) == 0) { + ParseParamJson(path, entries); + } + } + } + + int count = 0; + for (const auto& [label, entry]: entries) { + if (!m_title_id.isEmpty() && !entry.content_id.contains(m_title_id, Qt::CaseInsensitive)) { + continue; ``` **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '20,90p' src/launcher/src/additionalContentDialog.cpp sed -n '187,234p' src/launcher/src/additionalContentDialog.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 4015 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- dialog references and surrounding implementation ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'AdditionalContentDialog' -e 'm_title_id' -e 'IsValidContentId' -e 'content_id.contains' src || test "$?" -eq 1 printf '%s\n' '--- dialog source ---' sed -n '1,280p' src/launcher/src/additionalContentDialog.cpp printf '%s\n' '--- declarations and callers ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'AdditionalContent' -e 'additionalContent' src || test "$?" -eq 1 printf '%s\n' '--- matching content-ID logic ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'contentId' -e 'content_id' -e 'ContentId' -e 'addcont' src | head -240 printf '%s\n' '--- PR diff for dialog and related matching code ---' git diff --no-ext-diff --unified=30 9e41d8320a2774b303fbad344c2347e8d0292e83 39a8606f585316a42a2af83f347516233b7e5646 -- src/launcher/src/additionalContentDialog.cpp src | sed -n '1,520p' ``` Repository: KytyPS5/KytyPS5 Length of output: 37115 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- context-menu caller ---' sed -n '1228,1272p' src/launcher/src/configurationListWidget.cpp printf '%s\n' '--- loader content-ID parsing and filtering ---' sed -n '1,185p' src/loader/addContent.cpp sed -n '1,90p' src/loader/addContent.h printf '%s\n' '--- title-ID/content-ID consumers and tests ---' rg -n -F --glob '*.{cpp,h,hpp,json,md,txt}' -e 'TryGetTitleIdFromContentId' -e 'CUSA12345' -e 'content_id.find(title_id)' -e 'contentId' tests src docs || test "$?" -eq 1 printf '%s\n' '--- current exact source lines for proposed dialog correction ---' nl -ba src/launcher/src/additionalContentDialog.cpp | sed -n '180,216p' ``` Repository: KytyPS5/KytyPS5 Length of output: 11839 --- </details> **Match the content ID’s title segment in the dialog.** When a foreign valid content ID contains the selected title ID in its final label, `AdditionalContentDialog::Scan()` adds it to the list. Users then see a foreign DLC for the selected game. Loader-only matching or deduplication fixes do not change this dialog predicate. Compare the nine-character segment between the first `-` and `_` with `m_title_id`. <details><summary>Suggested fix</summary> ```diff - if (!m_title_id.isEmpty() && !entry.content_id.contains(m_title_id, Qt::CaseInsensitive)) { + const auto dash = entry.content_id.indexOf('-'); + const auto underscore = entry.content_id.indexOf('_', dash + 1); + if (!m_title_id.isEmpty() && + entry.content_id.mid(dash + 1, underscore - dash - 1) != m_title_id) { continue; } ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion std::map<QString, DlcEntry> entries; if (!m_folder.isEmpty() && QDir(m_folder).exists()) { QDirIterator it(m_folder, QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) { const auto path = it.next(); const auto name = QFileInfo(path).fileName(); if (name.compare(QStringLiteral("param.json"), Qt::CaseInsensitive) == 0) { ParseParamJson(path, entries); } } } int count = 0; for (const auto& [label, entry]: entries) { const auto dash = entry.content_id.indexOf('-'); const auto underscore = entry.content_id.indexOf('_', dash + 1); if (!m_title_id.isEmpty() && entry.content_id.mid(dash + 1, underscore - dash - 1) != m_title_id) { continue; ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:c2f6a7de2a6a9c8babf57605 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -350,0 +352,4 @@
auto* addons_layout = new QHBoxLayout;
addons_layout->setContentsMargins(0, 0, 0, 0);
addons_layout->setSpacing(4);
m_addons_dir_edit = new QLineEdit(m_game_dirs_group);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear the add-ons folder when resetting global settings.

The new editor is not reset by clear(). If a user clicks Clear and saves, GetAddonsDirectory() returns the old folder, so the reset leaves add-ons enabled. Clear m_addons_dir_edit in the global-settings branch of clear().

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#discussion_r4279132669) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Clear the add-ons folder when resetting global settings.** The new editor is not reset by `clear()`. If a user clicks Clear and saves, `GetAddonsDirectory()` returns the old folder, so the reset leaves add-ons enabled. Clear `m_addons_dir_edit` in the global-settings branch of `clear()`. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:74933ea7429a1a0eb8600af7 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original
On src/loader/addContent.cpp line 157 (outdated):

@@ -0,0 +1,193 @@
+#include "loader/addContent.h"
+
+#include "common/file.h"
+#include "common/logging/log.h"
+#include "common/singleton.h"
+#include "common/stringUtils.h"
+
+#include <algorithm>
+#include <cctype>
+#include <cstdlib>
+#include <cstring>
+#include <filesystem>
+#include <map>
+#include <nlohmann/json.hpp>
+#include <regex>
+#include <system_error>
+
+namespace Loader {
+
+namespace {
+
+struct AddContentRegistry {
+	std::vector<AddContentEntry> entries;
+};
+
+std::string DeriveEntitlementLabel(const std::string& content_id) {
+	// A PS4/PS5 content id looks like "<dist>-<title_id>_<svc>-<label>".
+	// The entitlement label used by AppContent/NpEntitlementAccess is the
+	// final segment after the last '-'.
+	const auto dash = content_id.rfind('-');
+	if (dash == std::string::npos || dash + 1 >= content_id.size()) {
+		return {};
+	}
+
+	auto label = content_id.substr(dash + 1);
+	if (label.size() > 16) {
+		LOGF("AddContent: entitlement label too long (truncated): %s\n", label.c_str());
+		label.resize(16);
+	}
+	return label;
+}
+
+bool IsValidContentId(const std::string& id) {
+	// 36 chars: <2 letters><4 digits>-<4 letters><5 digits>_<2 digits>-<16 chars, zero padded>
+	static const std::regex re("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$");
+	return id.size() == 36 && std::regex_match(id, re);
+}
+
+void AddOrUpdateEntry(std::map<std::string, AddContentEntry>& by_label, std::string content_id,
+                     std::filesystem::path mount_dir) {
+	if (!IsValidContentId(content_id)) {
+		LOGF("AddContent: invalid content_id, ignored: %s\n", content_id.c_str());
+		return;
+	}
+	auto label = DeriveEntitlementLabel(content_id);
+	if (label.empty()) {
+		LOGF("AddContent: can't derive entitlement label from content_id: %s\n",
+		     content_id.c_str());
+		return;
+	}
+
+	auto it = by_label.find(label);
+	if (it == by_label.end()) {
+		by_label.emplace(label, AddContentEntry {std::move(content_id), label, std::move(mount_dir)});
+	} else if (it->second.mount_dir.empty() && !mount_dir.empty()) {
+		// Prefer an entry that points at real data over a bare unlock-only ini.
+		it->second.mount_dir = std::move(mount_dir);
+	}
+}
+
+void ParseParamJson(const std::filesystem::path& file_name,
+                    std::map<std::string, AddContentEntry>& by_label) {
+	Common::File f;
+	f.Open(file_name, Common::File::Mode::Read);
+	if (f.IsInvalid()) {
+		return;
+	}
+
+	const auto buf = f.ReadWholeBuffer();
+	f.Close();
+
+	if (buf.empty()) {
+		return;
+	}
+
+	const auto* json_begin = reinterpret_cast<const char*>(buf.data());
+	const auto* json_end   = json_begin + buf.size();
+	auto        param_json = nlohmann::json::parse(json_begin, json_end, nullptr, false);
+	if (param_json.is_discarded() || !param_json.is_object()) {
+		return;
+	}
+
+	const auto it = param_json.find("contentId");
+	if (it == param_json.end() || !it->is_string()) {
+		return;
+	}
+
+	// sce_sys/param.json -> content root is two levels up.
+	auto mount_dir = file_name.parent_path();
+	if (mount_dir.filename() == "sce_sys") {
+		mount_dir = mount_dir.parent_path();
+	}
+
+	AddOrUpdateEntry(by_label, it->get<std::string>(), mount_dir);
+	LOGF("AddContent: found dumped package: %s (%s)\n",
+	     it->get_ref<const std::string&>().c_str(), Common::PathToString(mount_dir).c_str());
+}
+
+void ScanDirectory(const std::filesystem::path& dir,
+                   std::map<std::string, AddContentEntry>& by_label) {
+	std::error_code ec;
+	std::filesystem::recursive_directory_iterator it(
+	    dir, std::filesystem::directory_options::skip_permission_denied, ec);
+	const std::filesystem::recursive_directory_iterator end;
+
+	for (; !ec && it != end; it.increment(ec)) {
+		const auto& entry = *it;
+
+		std::error_code file_ec;
+		if (!entry.is_regular_file(file_ec) || file_ec) {
+			continue;
+		}
+
+		const auto& path = entry.path();
+		const auto  name  = Common::PathToString(path.filename());
+
+		if (Common::EqualNoCase(name, "param.json")) {
+			ParseParamJson(path, by_label);
+		}
+	}
+}
+
+} // namespace
+
+void AddContentLoad(const std::filesystem::path& dir, const std::string& title_id) {
+	auto* reg = Common::Singleton<AddContentRegistry>::Instance();
+	reg->entries.clear();
+
+	if (dir.empty() || !Common::File::IsDirectoryExisting(dir)) {
+		LOGF("AddContent: directory not found, skipping: %s\n",
+		     Common::PathToString(dir).c_str());
+		return;
+	}
+
+	LOGF("AddContent: scanning %s (title_id=%s)\n", Common::PathToString(dir).c_str(),
+	     title_id.c_str());
+
+	std::map<std::string, AddContentEntry> by_label;
+	ScanDirectory(dir, by_label);
+
+	reg->entries.reserve(by_label.size());
+	for (auto& [label, entry]: by_label) {
+		if (!title_id.empty() && entry.content_id.find(title_id) == std::string::npos) {
+			LOGF("AddContent: skipping %s (belongs to another title, current=%s)\n",
+			     entry.content_id.c_str(), title_id.c_str());
+			continue;
+		}

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Compare the title segment exactly instead of using a substring search.

content_id.find(title_id) matches the title ID at any position in the content ID. A 16-character label can contain another title's ID, so content for other titles can be registered. The content ID format is fixed, so the title ID is always at characters 7–15. Compare that segment exactly.

Proposed fix
-		if (!title_id.empty() && entry.content_id.find(title_id) == std::string::npos) {
+		if (!title_id.empty() && entry.content_id.compare(7, 9, title_id) != 0) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	for (auto& [label, entry]: by_label) {
		if (!title_id.empty() && entry.content_id.compare(7, 9, title_id) != 0) {
			LOGF("AddContent: skipping %s (belongs to another title, current=%s)\n",
			     entry.content_id.c_str(), title_id.c_str());
			continue;
		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#discussion_r4279132672) On `src/loader/addContent.cpp` line 157 (outdated): ```diff @@ -0,0 +1,193 @@ +#include "loader/addContent.h" + +#include "common/file.h" +#include "common/logging/log.h" +#include "common/singleton.h" +#include "common/stringUtils.h" + +#include <algorithm> +#include <cctype> +#include <cstdlib> +#include <cstring> +#include <filesystem> +#include <map> +#include <nlohmann/json.hpp> +#include <regex> +#include <system_error> + +namespace Loader { + +namespace { + +struct AddContentRegistry { + std::vector<AddContentEntry> entries; +}; + +std::string DeriveEntitlementLabel(const std::string& content_id) { + // A PS4/PS5 content id looks like "<dist>-<title_id>_<svc>-<label>". + // The entitlement label used by AppContent/NpEntitlementAccess is the + // final segment after the last '-'. + const auto dash = content_id.rfind('-'); + if (dash == std::string::npos || dash + 1 >= content_id.size()) { + return {}; + } + + auto label = content_id.substr(dash + 1); + if (label.size() > 16) { + LOGF("AddContent: entitlement label too long (truncated): %s\n", label.c_str()); + label.resize(16); + } + return label; +} + +bool IsValidContentId(const std::string& id) { + // 36 chars: <2 letters><4 digits>-<4 letters><5 digits>_<2 digits>-<16 chars, zero padded> + static const std::regex re("^[A-Z]{2}[0-9]{4}-[A-Z]{4}[0-9]{5}_[0-9]{2}-[A-Z0-9]{16}$"); + return id.size() == 36 && std::regex_match(id, re); +} + +void AddOrUpdateEntry(std::map<std::string, AddContentEntry>& by_label, std::string content_id, + std::filesystem::path mount_dir) { + if (!IsValidContentId(content_id)) { + LOGF("AddContent: invalid content_id, ignored: %s\n", content_id.c_str()); + return; + } + auto label = DeriveEntitlementLabel(content_id); + if (label.empty()) { + LOGF("AddContent: can't derive entitlement label from content_id: %s\n", + content_id.c_str()); + return; + } + + auto it = by_label.find(label); + if (it == by_label.end()) { + by_label.emplace(label, AddContentEntry {std::move(content_id), label, std::move(mount_dir)}); + } else if (it->second.mount_dir.empty() && !mount_dir.empty()) { + // Prefer an entry that points at real data over a bare unlock-only ini. + it->second.mount_dir = std::move(mount_dir); + } +} + +void ParseParamJson(const std::filesystem::path& file_name, + std::map<std::string, AddContentEntry>& by_label) { + Common::File f; + f.Open(file_name, Common::File::Mode::Read); + if (f.IsInvalid()) { + return; + } + + const auto buf = f.ReadWholeBuffer(); + f.Close(); + + if (buf.empty()) { + return; + } + + const auto* json_begin = reinterpret_cast<const char*>(buf.data()); + const auto* json_end = json_begin + buf.size(); + auto param_json = nlohmann::json::parse(json_begin, json_end, nullptr, false); + if (param_json.is_discarded() || !param_json.is_object()) { + return; + } + + const auto it = param_json.find("contentId"); + if (it == param_json.end() || !it->is_string()) { + return; + } + + // sce_sys/param.json -> content root is two levels up. + auto mount_dir = file_name.parent_path(); + if (mount_dir.filename() == "sce_sys") { + mount_dir = mount_dir.parent_path(); + } + + AddOrUpdateEntry(by_label, it->get<std::string>(), mount_dir); + LOGF("AddContent: found dumped package: %s (%s)\n", + it->get_ref<const std::string&>().c_str(), Common::PathToString(mount_dir).c_str()); +} + +void ScanDirectory(const std::filesystem::path& dir, + std::map<std::string, AddContentEntry>& by_label) { + std::error_code ec; + std::filesystem::recursive_directory_iterator it( + dir, std::filesystem::directory_options::skip_permission_denied, ec); + const std::filesystem::recursive_directory_iterator end; + + for (; !ec && it != end; it.increment(ec)) { + const auto& entry = *it; + + std::error_code file_ec; + if (!entry.is_regular_file(file_ec) || file_ec) { + continue; + } + + const auto& path = entry.path(); + const auto name = Common::PathToString(path.filename()); + + if (Common::EqualNoCase(name, "param.json")) { + ParseParamJson(path, by_label); + } + } +} + +} // namespace + +void AddContentLoad(const std::filesystem::path& dir, const std::string& title_id) { + auto* reg = Common::Singleton<AddContentRegistry>::Instance(); + reg->entries.clear(); + + if (dir.empty() || !Common::File::IsDirectoryExisting(dir)) { + LOGF("AddContent: directory not found, skipping: %s\n", + Common::PathToString(dir).c_str()); + return; + } + + LOGF("AddContent: scanning %s (title_id=%s)\n", Common::PathToString(dir).c_str(), + title_id.c_str()); + + std::map<std::string, AddContentEntry> by_label; + ScanDirectory(dir, by_label); + + reg->entries.reserve(by_label.size()); + for (auto& [label, entry]: by_label) { + if (!title_id.empty() && entry.content_id.find(title_id) == std::string::npos) { + LOGF("AddContent: skipping %s (belongs to another title, current=%s)\n", + entry.content_id.c_str(), title_id.c_str()); + continue; + } ``` **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Compare the title segment exactly instead of using a substring search.** `content_id.find(title_id)` matches the title ID at any position in the content ID. A 16-character label can contain another title's ID, so content for other titles can be registered. The content ID format is fixed, so the title ID is always at characters 7–15. Compare that segment exactly. <details> <summary>Proposed fix</summary> ```diff - if (!title_id.empty() && entry.content_id.find(title_id) == std::string::npos) { + if (!title_id.empty() && entry.content_id.compare(7, 9, title_id) != 0) { ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion for (auto& [label, entry]: by_label) { if (!title_id.empty() && entry.content_id.compare(7, 9, title_id) != 0) { LOGF("AddContent: skipping %s (belongs to another title, current=%s)\n", entry.content_id.c_str(), title_id.c_str()); continue; } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d460ce40e82fdaef3a16900c --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-15 04:52 UTC · original · reviewed

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0854798-4539-479d-8e54-b8a04b5395fb
📥 Commits

Reviewing files that changed from the base of the PR and between 9e41d8320a and 39a8606f585316a42a2af83f347516233b7e5646.

📒 Files selected for processing: 15
  • src/emulator.cpp
  • src/emulator.h
  • src/launcher/include/additionalContentDialog.h
  • src/launcher/include/configuration.h
  • src/launcher/include/configurationEditDialog.h
  • src/launcher/include/configurationListWidget.h
  • src/launcher/src/additionalContentDialog.cpp
  • src/launcher/src/configurationEditDialog.cpp
  • src/launcher/src/configurationListWidget.cpp
  • src/launcher/src/mainDialog.cpp
  • src/libs/libAppContent.cpp
  • src/libs/libNet.cpp
  • src/loader/addContent.cpp
  • src/loader/addContent.h
  • src/main.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-15 04:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1519#pullrequestreview-5528226359) · **reviewed** **Actionable comments posted: 5** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d0854798-4539-479d-8e54-b8a04b5395fb` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9e41d8320a2774b303fbad344c2347e8d0292e83 and 39a8606f585316a42a2af83f347516233b7e5646. </details> <details> <summary>📒 Files selected for processing: 15</summary> * `src/emulator.cpp` * `src/emulator.h` * `src/launcher/include/additionalContentDialog.h` * `src/launcher/include/configuration.h` * `src/launcher/include/configurationEditDialog.h` * `src/launcher/include/configurationListWidget.h` * `src/launcher/src/additionalContentDialog.cpp` * `src/launcher/src/configurationEditDialog.cpp` * `src/launcher/src/configurationListWidget.cpp` * `src/launcher/src/mainDialog.cpp` * `src/libs/libAppContent.cpp` * `src/libs/libNet.cpp` * `src/loader/addContent.cpp` * `src/loader/addContent.h` * `src/main.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=b923a1df-c397-47d5-b108-56185dc59cfa attempt=7fd0b6fd-3ed8-4225-9667-f66eba019647 batch=1/1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.