From 3e8527f6908cdee041cdfdf63a542b8984c5f741 Mon Sep 17 00:00:00 2001 From: cohaereo Date: Tue, 19 Mar 2024 00:28:55 +0100 Subject: [PATCH] roi: Add localized strings --- src/references.rs | 2 ++ src/text.rs | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/references.rs b/src/references.rs index 3270964..d2f7862 100644 --- a/src/references.rs +++ b/src/references.rs @@ -23,6 +23,8 @@ lazy_static::lazy_static! { ]); pub static ref REFERENCE_MAP_ROI: FxHashMap = FxHashMap::from_iter([ + (0x8080035A, "SLocalizedStrings"), + (0x808008BE, "SLocalizedStringsData"), (0x80801AD7, "STechnique"), (0x80801C47, "SScope"), ]); diff --git a/src/text.rs b/src/text.rs index a28e73e..7848996 100644 --- a/src/text.rs +++ b/src/text.rs @@ -340,9 +340,14 @@ pub fn create_stringmap() -> anyhow::Result { | PackageVersion::Destiny2BeyondLight | PackageVersion::Destiny2WitchQueen | PackageVersion::Destiny2Lightfall + // cohae: Rise of Iron uses the same string format as D2 + | PackageVersion::DestinyRiseOfIron ) { create_stringmap_d2() - } else if package_manager().version == PackageVersion::DestinyTheTakenKing { + } else if matches!( + package_manager().version, + PackageVersion::DestinyTheTakenKing + ) { create_stringmap_d1() } else { warn!( @@ -354,10 +359,22 @@ pub fn create_stringmap() -> anyhow::Result { } pub fn create_stringmap_d2() -> anyhow::Result { - let prebl = package_manager().version == PackageVersion::Destiny2Shadowkeep; + // TODO(cohae): We should probably derive PartialOrd for PackageVersion + let prebl = matches!( + package_manager().version, + PackageVersion::DestinyTheTakenKing + | PackageVersion::DestinyRiseOfIron + | PackageVersion::Destiny2Shadowkeep + ); let mut tmp_map: FxHashMap> = Default::default(); for (t, _) in package_manager() - .get_all_by_reference(u32::from_be(if prebl { 0x889a8080 } else { 0xEF998080 })) + .get_all_by_reference(if package_manager().version.is_d1() { + 0x8080035A + } else if prebl { + 0x80809A88 + } else { + 0x808099EF + }) .into_iter() { let Ok(textset_header) = package_manager().read_tag_binrw::(t) else {