1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-07-01 16:47:46 +00:00

Fix parsing of certain LGB files

These have unknown instance objects, and were tripping up our parsing. I
don't know what these are yet, but I added them anyway.

I also made sure that the parser doesn't return None for technically
valid but empty LGB files.
This commit is contained in:
Joshua Goins 2025-06-22 10:24:21 -04:00
parent 70ebe7d03d
commit 21a5ddc763
2 changed files with 12 additions and 4 deletions

View file

@ -10,6 +10,7 @@ use super::TriggerBoxInstanceObject;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum ExitType { pub enum ExitType {
ZoneLine = 0x1, ZoneLine = 0x1,
Unk = 0x2, // seen in bg/ex5/02_ykt_y6/fld/y6f1/level/planmap.lgb
} }
#[binread] #[binread]

View file

@ -298,6 +298,8 @@ pub enum LayerEntryType {
StableChocobo = 0x4F, StableChocobo = 0x4F,
MaxAssetType = 0x50, MaxAssetType = 0x50,
Unk1 = 90, Unk1 = 90,
Unk2 = 86, // seen in bg/ex5/02_ykt_y6/fld/y6f1/level/bg.lgb
Unk3 = 89, // seen in bg/ffxiv/sea_s1/fld/s1f3/level/planevent.lgb
} }
#[binread] #[binread]
@ -362,6 +364,10 @@ pub enum LayerEntryData {
FateRange(FateRangeInstanceObject), FateRange(FateRangeInstanceObject),
#[br(pre_assert(*magic == LayerEntryType::Unk1))] #[br(pre_assert(*magic == LayerEntryType::Unk1))]
Unk1(), Unk1(),
#[br(pre_assert(*magic == LayerEntryType::Unk2))]
Unk2(),
#[br(pre_assert(*magic == LayerEntryType::Unk3))]
Unk3(),
} }
#[binread] #[binread]
@ -659,9 +665,11 @@ impl LayerGroup {
let chunk_header = let chunk_header =
LayerChunkHeader::read_le_args(&mut cursor, (&chunk_string_heap,)).unwrap(); LayerChunkHeader::read_le_args(&mut cursor, (&chunk_string_heap,)).unwrap();
if chunk_header.chunk_size <= 0 { if chunk_header.chunk_size <= 0 {
return None; return Some(LayerGroup {
file_id: file_header.file_id,
chunks: Vec::new(),
});
} }
let old_pos = cursor.position(); let old_pos = cursor.position();
@ -706,8 +714,7 @@ impl LayerGroup {
let start = cursor.stream_position().unwrap(); let start = cursor.stream_position().unwrap();
let string_heap = StringHeap::from(start); let string_heap = StringHeap::from(start);
objects objects.push(InstanceObject::read_le_args(&mut cursor, (&string_heap,)).ok()?);
.push(InstanceObject::read_le_args(&mut cursor, (&string_heap,)).ok()?);
} }
} }