Skip to content

Commit 4e94ca5

Browse files
committed
[libromdata] Xbox360_XDBF_Private::loadString_GPD(): Fix string lookups.
- p.resource_id is 64-bit, so we have to use cpu_to_be64() on the 16-bit string ID. Otherwise, we'll never find the string. This fixes a regression from commit 66411c5. (Xbox360_XDBF.cpp: loadString_GPD(): Actually search for the correct string ID.) Affects: v2.0 - v2.7 Fixes #475: 360 GPD achievement files all show with Title: Unknown Reported by @Masamune3210.
1 parent aba8d3c commit 4e94ca5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changes
22

3-
## v2.7.1 (released 2025/??/??)
3+
## v2.7.1 (released 2026/??/??)
44

55
* New features:
66
* Achievements lists, e.g. for Xbox 360 games, now use the same formatting
@@ -40,6 +40,10 @@
4040
when using an older version of MSVCP140.dll.
4141
* Fixes #472: Error caused by version 2.7 | Error causado por la versión 2.7
4242
* Reported by @ctuais.
43+
* Xbox360_XDBF: Fix title retrieval for GPD files.
44+
* Affects: v2.0 - v2.7
45+
* Fixes #475: 360 GPD achievement files all show with Title: Unknown
46+
* Reported by @Masamune3210.
4347

4448
## v2.7 (released 2025/11/16)
4549

src/libromdata/Console/Xbox360_XDBF.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -545,18 +545,15 @@ string Xbox360_XDBF_Private::loadString_GPD(uint16_t string_id)
545545
return {};
546546
}
547547

548-
#if SYS_BYTEORDER == SYS_LIL_ENDIAN
549-
// Byteswap the ID to make it easier to find things.
550-
string_id = cpu_to_be16(string_id);
551-
#endif /* SYS_BYTEORDER == SYS_LIL_ENDIAN */
552-
553548
// TODO: Optimize by creating an unordered_map of IDs to strings?
554549
// Might not be a good optimization if we don't have that many strings...
555550

556551
// NOTE: GPDs only have one language, so not using RFT_STRING_MULTI here.
557552

558553
// GPD doesn't have string tables.
559554
// Instead, each string is its own entry in the main resource table.
555+
// Because of this, string IDs are 64-bit.
556+
const uint64_t string_id64 = cpu_to_be64(string_id);
560557
string s_ret;
561558
for (const XDBF_Entry &p : entryTable) {
562559
if (p.namespace_id != cpu_to_be16(XDBF_GPD_NAMESPACE_STRING)) {
@@ -565,7 +562,7 @@ string Xbox360_XDBF_Private::loadString_GPD(uint16_t string_id)
565562
}
566563

567564
// Check for a matching resource ID.
568-
if (p.resource_id != string_id) {
565+
if (p.resource_id != string_id64) {
569566
// Not a match. Skip this entry.
570567
continue;
571568
}
@@ -577,8 +574,9 @@ string Xbox360_XDBF_Private::loadString_GPD(uint16_t string_id)
577574
assert(length > 2);
578575
assert(length <= 4096);
579576
assert(length % 2 == 0);
580-
if (length < 2 || length > 4096 || length % 2 != 0)
577+
if (length < 2 || length > 4096 || length % 2 != 0) {
581578
continue;
579+
}
582580

583581
// Length includes the NULL terminator, so remove it.
584582
// NOTE: Some GPD files only have one NULL byte if the string

0 commit comments

Comments
 (0)