From b180cf5aac7a89a93383da62e2185f5ce70fef5b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 30 Jul 2023 14:45:19 -0400 Subject: [PATCH] Fix patching for some patch files We still need to read the index type, even though it's NOP. It appeared in a recent patch! --- src/patch.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/patch.rs b/src/patch.rs index d4a0b04..8469979 100755 --- a/src/patch.rs +++ b/src/patch.rs @@ -141,6 +141,8 @@ enum SqpkOperation { PatchInfo(SqpkPatchInfo), #[br(magic = b'T')] TargetInfo(SqpkTargetInfo), + #[br(magic = b'I')] + Index(SqpkIndex) } #[derive(BinRead, PartialEq, Debug)] @@ -288,6 +290,30 @@ struct SqpkTargetInfo { seek_count: u64, } +#[binread] +#[derive(PartialEq, Debug)] +enum SqpkIndexCommand { + #[br(magic = b'A')] + Add, + #[br(magic = b'D')] + Delete, +} + +#[derive(BinRead, PartialEq, Debug)] +#[br(big)] +struct SqpkIndex { + command: SqpkIndexCommand, + #[br(map = | x : u8 | x == 1)] + is_synonym: bool, + + #[br(pad_before = 1)] + file_hash: u64, + + block_offset: u32, + #[br(pad_after = 8)] // data? + block_number: u32 +} + #[derive(BinRead, PartialEq, Debug)] #[br(big)] struct SqpkChunk { @@ -577,6 +603,9 @@ pub fn apply_patch(data_dir: &str, patch_path: &str) -> Result<(), PatchError> { SqpkOperation::TargetInfo(new_target_info) => { target_info = Some(new_target_info); } + SqpkOperation::Index(_) => { + // Currently, there's nothing we need from Index command. Intentional NOP. + } } } ChunkType::FileHeader(_) => {