Skip to content

Commit

Permalink
Fix dumb bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
widberg committed Oct 8, 2023
1 parent 660da9f commit 699aa3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions bff/src/bigfile/v1_06_63_02_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ fn pool_parser(objects: &mut HashMap<Name, Resource>) -> BinResult<ManifestPool>
for pool_object in pool.objects.into_iter() {
let name = pool_object.object.name;
match &mut objects.get_mut(&name).unwrap().data {
ExtendedData { ref mut body, .. } => *body = pool_object.object.body,
ExtendedData { body, compress, .. } => {
*body = pool_object.object.body;
*compress = pool_object.object.compress;
},
_ => unreachable!(),
}
}
Expand Down Expand Up @@ -382,7 +385,7 @@ impl BigFileWrite for BigFileV1_06_63_02PC {
.iter()
.filter(|y| pool.object_entries.get(**y as usize).unwrap().name == x.name)
.count() as u32,
padded_size: object_padded_sizes.get(&x.name).unwrap() / 2048,
padded_size: *object_padded_sizes.get(&x.name).unwrap(),
reference_records_index: x.reference_record_index,
})
.collect::<Vec<_>>();
Expand Down
14 changes: 10 additions & 4 deletions bff/src/bigfile/v1_06_63_02_pc/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub struct PoolHeader {
#[bw(map = unzip_object_description_soa)]
pub object_descriptions: Vec<ObjectDescription>,
pub reference_records: DynArray<ReferenceRecord>,
#[brw(align_after = 2048)]
#[br(align_after = 2048)]
#[serde(skip)]
#[bw(calc = <_>::default())]
_reference_records_sentinel: ReferenceRecord,
Expand All @@ -131,13 +131,19 @@ pub fn calculate_padded_pool_header_size(
object_descriptions_size: usize,
reference_records_size: usize,
) -> usize {
let size = 4
let size =
// equals524288
4
// equals2048
+ 4
// objectsCRC32CountSum
+ 4
// objectsCRC32s
+ 4
+ object_descriptions_indices_size * 4
+ 4 * 4
+ object_descriptions_size * 4
// crc32s, referenceCounts, paddedSizes, referenceRecordsIndices
+ 4 * (4 + object_descriptions_size * 4)
// referenceRecords
+ 4
+ (reference_records_size + 1) * (4 + 4 + 4 + 2 + 2 + 4 + 4 + 4);
calculated_padded(size, 2048)
Expand Down

0 comments on commit 699aa3d

Please sign in to comment.