Skip to content

Commit

Permalink
Add support for 5.2 and 5.3 assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenpt committed Sep 18, 2023
1 parent d77ef3c commit a79d4eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ pub struct AssetHeader<R> {
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<i32>,
}

impl<R> AssetHeader<R>
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -566,6 +580,7 @@ where
preload_dependency_offset,
names_referenced_from_export_data_count,
payload_toc_offset,
data_resource_offset,
})
}
}
Expand Down
8 changes: 8 additions & 0 deletions test_utilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

0 comments on commit a79d4eb

Please sign in to comment.