mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:54:55 +08:00
feat(patch):统一清单驱动汉化发布
This commit is contained in:
@@ -149,8 +149,18 @@ pub fn patch_unityfs_text_asset(data: &[u8], patch: &TextAssetPatch) -> Result<V
|
||||
patch.path_id,
|
||||
None,
|
||||
)?;
|
||||
let asset = verified
|
||||
.text_assets
|
||||
let verified_serialized = verified
|
||||
.serialized_files
|
||||
.iter()
|
||||
.find(|file| file.source_path.as_deref() == Some(patch.serialized_file_path.as_str()))
|
||||
.ok_or_else(|| {
|
||||
AssetBundleError::Parse(format!(
|
||||
"patched serialized file {} was not found after rebuild",
|
||||
patch.serialized_file_path
|
||||
))
|
||||
})?;
|
||||
let asset = verified_serialized
|
||||
.text_assets()
|
||||
.iter()
|
||||
.find(|asset| asset.path_id == patch.path_id)
|
||||
.ok_or_else(|| {
|
||||
@@ -2119,6 +2129,50 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn post_rebuild_text_asset_verification_scopes_duplicate_path_id_to_serialized_file() {
|
||||
let first = synthetic_serialized_text_asset(b"first");
|
||||
let second = synthetic_serialized_text_asset(b"second");
|
||||
let source = synthetic_bundle_with_compressed_blocks(
|
||||
&[("CAB-first", &first), ("CAB-second", &second)],
|
||||
0,
|
||||
0,
|
||||
);
|
||||
|
||||
let patched = patch_unityfs_text_asset(
|
||||
&source,
|
||||
&TextAssetPatch {
|
||||
serialized_file_path: "CAB-second".to_string(),
|
||||
path_id: 1,
|
||||
expected_name: Some("Scenario".to_string()),
|
||||
replacement: b"localized-second".to_vec(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let reparsed = UnityFsParser::new().parse_bytes(&patched).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
reparsed
|
||||
.serialized_files
|
||||
.iter()
|
||||
.find(|file| file.source_path.as_deref() == Some("CAB-first"))
|
||||
.unwrap()
|
||||
.text_assets()[0]
|
||||
.bytes,
|
||||
b"first"
|
||||
);
|
||||
assert_eq!(
|
||||
reparsed
|
||||
.serialized_files
|
||||
.iter()
|
||||
.find(|file| file.source_path.as_deref() == Some("CAB-second"))
|
||||
.unwrap()
|
||||
.text_assets()[0]
|
||||
.bytes,
|
||||
b"localized-second"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rebuild_preserves_block_info_at_end_and_lzma_compression() {
|
||||
let serialized = synthetic_serialized_text_asset(b"old");
|
||||
|
||||
Reference in New Issue
Block a user