diff --git a/Cargo.lock b/Cargo.lock index 22eefec..0b3f883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -805,7 +805,7 @@ dependencies = [ [[package]] name = "msg_tool" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 95d4a65..82a6b32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "msg_tool" -version = "0.1.1" +version = "0.1.2" edition = "2024" repository = "https://github.com/lifegpc/msg-tool" description = "A command-line tool for exporting, importing, packing, and unpacking script files." diff --git a/src/scripts/bgi/bp.rs b/src/scripts/bgi/bp.rs index 4a1e90e..1653e26 100644 --- a/src/scripts/bgi/bp.rs +++ b/src/scripts/bgi/bp.rs @@ -73,10 +73,14 @@ impl BGIBpScript { } let mut last_instr_pos = 0; reader.seek(SeekFrom::Start(header_size as u64))?; - for _ in 0..instr_size / 4 { - let instr = reader.read_u32()?; + let max_instr_len = reader.data.len() - 4; + while reader.pos < max_instr_len { + let instr = reader.cpeek_u32()?; if instr == 0x17 { last_instr_pos = reader.pos; + reader.pos += 4; + } else { + reader.pos += 1; } } if last_instr_pos == 0 { diff --git a/src/scripts/entis_gls/srcxml.rs b/src/scripts/entis_gls/srcxml.rs index 47b250e..b6c06f7 100644 --- a/src/scripts/entis_gls/srcxml.rs +++ b/src/scripts/entis_gls/srcxml.rs @@ -56,7 +56,7 @@ pub struct SrcXmlScript { impl SrcXmlScript { /// Creates a new `SrcXmlScript` from the provided buffer and encoding. - /// + /// /// * `buf` - The buffer containing the XML data. /// * `encoding` - The encoding of the XML data. /// * `config` - Additional configuration options.