mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-22 04:37:46 +00:00
Fix broken 6.5 patching
Thanks to the goatcorp team for figuring this out first, there's some parts of the patches that are actually unsigned ints. Should constitute further testing, but it now patches up to 6.5
This commit is contained in:
parent
74cc82a425
commit
267feae8cf
1 changed files with 17 additions and 17 deletions
34
src/patch.rs
34
src/patch.rs
|
@ -181,12 +181,12 @@ struct SqpkAddData {
|
||||||
sub_id: u16,
|
sub_id: u16,
|
||||||
file_id: u32,
|
file_id: u32,
|
||||||
|
|
||||||
#[br(map = | x : i32 | x << 7 )]
|
#[br(map = | x : u32 | x << 7 )]
|
||||||
block_offset: i32,
|
block_offset: u32,
|
||||||
#[br(map = | x : i32 | x << 7 )]
|
#[br(map = | x : u32 | x << 7 )]
|
||||||
block_number: i32,
|
block_number: u32,
|
||||||
#[br(map = | x : i32 | x << 7 )]
|
#[br(map = | x : u32 | x << 7 )]
|
||||||
block_delete_number: i32,
|
block_delete_number: u32,
|
||||||
|
|
||||||
#[br(count = block_number)]
|
#[br(count = block_number)]
|
||||||
block_data: Vec<u8>,
|
block_data: Vec<u8>,
|
||||||
|
@ -200,10 +200,10 @@ struct SqpkDeleteData {
|
||||||
sub_id: u16,
|
sub_id: u16,
|
||||||
file_id: u32,
|
file_id: u32,
|
||||||
|
|
||||||
#[br(map = | x : i32 | x << 7 )]
|
#[br(map = | x : u32 | x << 7 )]
|
||||||
block_offset: i32,
|
block_offset: u32,
|
||||||
#[br(pad_after = 4)]
|
#[br(pad_after = 4)]
|
||||||
block_number: i32,
|
block_number: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binread]
|
#[binread]
|
||||||
|
@ -249,7 +249,7 @@ struct SqpkFileOperationData {
|
||||||
operation: SqpkFileOperation,
|
operation: SqpkFileOperation,
|
||||||
|
|
||||||
offset: i64,
|
offset: i64,
|
||||||
file_size: u64,
|
file_size: i64,
|
||||||
|
|
||||||
#[br(temp)]
|
#[br(temp)]
|
||||||
path_length: u32,
|
path_length: u32,
|
||||||
|
@ -328,10 +328,10 @@ struct SqpkChunk {
|
||||||
|
|
||||||
const WIPE_BUFFER: [u8; 1 << 16] = [0; 1 << 16];
|
const WIPE_BUFFER: [u8; 1 << 16] = [0; 1 << 16];
|
||||||
|
|
||||||
fn wipe(mut file: &File, length: i32) -> Result<(), PatchError> {
|
fn wipe(mut file: &File, length: u32) -> Result<(), PatchError> {
|
||||||
let mut length = length;
|
let mut length: usize = length as usize;
|
||||||
while length > 0 {
|
while length > 0 {
|
||||||
let num_bytes = min(WIPE_BUFFER.len() as i32, length);
|
let num_bytes = min(WIPE_BUFFER.len(), length as usize);
|
||||||
file.write_all(&WIPE_BUFFER[0..num_bytes as usize])?;
|
file.write_all(&WIPE_BUFFER[0..num_bytes as usize])?;
|
||||||
length -= num_bytes;
|
length -= num_bytes;
|
||||||
}
|
}
|
||||||
|
@ -339,15 +339,15 @@ fn wipe(mut file: &File, length: i32) -> Result<(), PatchError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wipe_from_offset(mut file: &File, length: i32, offset: i32) -> Result<(), PatchError> {
|
fn wipe_from_offset(mut file: &File, length: u32, offset: u32) -> Result<(), PatchError> {
|
||||||
file.seek(SeekFrom::Start(offset as u64))?;
|
file.seek(SeekFrom::Start(offset as u64))?;
|
||||||
wipe(file, length)
|
wipe(file, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_empty_file_block_at(
|
fn write_empty_file_block_at(
|
||||||
mut file: &File,
|
mut file: &File,
|
||||||
offset: i32,
|
offset: u32,
|
||||||
block_number: i32,
|
block_number: u32,
|
||||||
) -> Result<(), PatchError> {
|
) -> Result<(), PatchError> {
|
||||||
wipe_from_offset(file, block_number << 7, offset)?;
|
wipe_from_offset(file, block_number << 7, offset)?;
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ fn write_empty_file_block_at(
|
||||||
let file_size: i32 = 0;
|
let file_size: i32 = 0;
|
||||||
file.write_all(file_size.to_le_bytes().as_slice())?;
|
file.write_all(file_size.to_le_bytes().as_slice())?;
|
||||||
|
|
||||||
let num_blocks: i32 = block_number - 1;
|
let num_blocks: i32 = (block_number - 1).try_into().unwrap();
|
||||||
file.write_all(num_blocks.to_le_bytes().as_slice())?;
|
file.write_all(num_blocks.to_le_bytes().as_slice())?;
|
||||||
|
|
||||||
let used_blocks: i32 = 0;
|
let used_blocks: i32 = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue