fix read atoms not incrementing the cursor

This commit is contained in:
Intege-rs
2024-12-24 13:10:55 -05:00
parent 9f8b1bdfc2
commit c95c8567df

View File

@@ -197,26 +197,32 @@ pub fn exec<Binary: Scannable + ?Sized>(
Atom::ReadU8(slot) => { Atom::ReadU8(slot) => {
let Some(value) = read::<_, u8>(bin, cursor) else { return None }; let Some(value) = read::<_, u8>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(1)
} }
Atom::ReadI8(slot) => { Atom::ReadI8(slot) => {
let Some(value) = read::<_, i8>(bin, cursor) else { return None }; let Some(value) = read::<_, i8>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(1)
} }
Atom::ReadU16(slot) => { Atom::ReadU16(slot) => {
let Some(value) = read::<_, u16>(bin, cursor) else { return None }; let Some(value) = read::<_, u16>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(2)
} }
Atom::ReadI16(slot) => { Atom::ReadI16(slot) => {
let Some(value) = read::<_, i16>(bin, cursor) else { return None }; let Some(value) = read::<_, i16>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(2)
} }
Atom::ReadU32(slot) => { Atom::ReadU32(slot) => {
let Some(value) = read::<_, u32>(bin, cursor) else { return None }; let Some(value) = read::<_, u32>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(4)
} }
Atom::ReadI32(slot) => { Atom::ReadI32(slot) => {
let Some(value) = read::<_, i32>(bin, cursor) else { return None }; let Some(value) = read::<_, i32>(bin, cursor) else { return None };
if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ } if let Some(slot) = saves.get_mut(slot as usize) { *slot = value as _ }
cursor = cursor.wrapping_add(4)
} }
Atom::Zero(slot) => { Atom::Zero(slot) => {
if let Some(slot) = saves.get_mut(slot as usize) { if let Some(slot) = saves.get_mut(slot as usize) {