From a79d4ebb21480a4039dc99268041e4d5eb4b05a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 18 Sep 2023 00:19:34 -0700 Subject: [PATCH] Add support for 5.2 and 5.3 assets --- src/enums.rs | 1 + src/lib.rs | 15 +++++++++++++++ test_utilities/src/lib.rs | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/enums.rs b/src/enums.rs index 3985839..930b0a8 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -337,6 +337,7 @@ pub enum ObjectVersionUE5 { TRACK_OBJECT_EXPORT_IS_INHERITED = 1006, FSOFTOBJECTPATH_REMOVE_ASSET_PATH_FNAMES = 1007, ADD_SOFTOBJECTPATH_LIST = 1008, + DATA_RESOURCES = 1009, } impl fmt::Display for ObjectVersionUE5 { diff --git a/src/lib.rs b/src/lib.rs index eb27cef..6ca12f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -317,6 +317,8 @@ pub struct AssetHeader { pub names_referenced_from_export_data_count: i32, /// Location into the file on disk for the payload table of contents data (C++ name: `PayloadTocOffset`) pub payload_toc_offset: i64, + /// Location into the file of the data resource(s) (C++ name: `DataResourceOffset `) + pub data_resource_offset: Option, } impl AssetHeader @@ -533,6 +535,18 @@ where -1 }; + let has_data_resource_offset = archive.serialized_with(ObjectVersionUE5::DATA_RESOURCES); + let data_resource_offset = if has_data_resource_offset { + let offset = archive.read_le()?; + if offset > 0 { + Some(offset) + } else { + None + } + } else { + None + }; + Ok(Self { archive, total_header_size, @@ -566,6 +580,7 @@ where preload_dependency_offset, names_referenced_from_export_data_count, payload_toc_offset, + data_resource_offset, }) } } diff --git a/test_utilities/src/lib.rs b/test_utilities/src/lib.rs index b301955..43c40b0 100644 --- a/test_utilities/src/lib.rs +++ b/test_utilities/src/lib.rs @@ -149,4 +149,12 @@ impl UnrealVersion { 1, test_utilities::ObjectVersionUE5::ADD_SOFTOBJECTPATH_LIST ))] +#[case::ue_5_2(test_utilities::UnrealVersionInfo::ue5( + 2, + test_utilities::ObjectVersionUE5::DATA_RESOURCES +))] +#[case::ue_5_3(test_utilities::UnrealVersionInfo::ue5( + 3, + test_utilities::ObjectVersionUE5::DATA_RESOURCES +))] fn all_versions(#[case] version_info: UnrealVersionInfo) {}