Skip to content

Commit

Permalink
roi: Add localized strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cohaereo committed Mar 18, 2024
1 parent 915cf11 commit 3e8527f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ lazy_static::lazy_static! {
]);

pub static ref REFERENCE_MAP_ROI: FxHashMap<u32, &'static str> = FxHashMap::from_iter([
(0x8080035A, "SLocalizedStrings"),
(0x808008BE, "SLocalizedStringsData"),
(0x80801AD7, "STechnique"),
(0x80801C47, "SScope"),
]);
Expand Down
23 changes: 20 additions & 3 deletions src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,14 @@ pub fn create_stringmap() -> anyhow::Result<StringCache> {
| 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!(
Expand All @@ -354,10 +359,22 @@ pub fn create_stringmap() -> anyhow::Result<StringCache> {
}

pub fn create_stringmap_d2() -> anyhow::Result<StringCache> {
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<u32, FxHashSet<String>> = 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::<StringContainer>(t) else {
Expand Down

0 comments on commit 3e8527f

Please sign in to comment.