update fbs

This commit is contained in:
2020-06-26 00:41:07 +08:00
parent fa722f19cf
commit 67787c3399
2 changed files with 22 additions and 0 deletions

View File

@@ -27,4 +27,20 @@ fn main() {
let monster_2 = flatbuffers::get_root::<Monster>(&buff);
println!("Monster hp: {}", monster_2.hp());
println!("Monster name: {:?}", monster_2.name());
let offset_to_body = i32::from_le_bytes(get_4bytes(&buff));
println!("Offset to body : {:>4}, hex: {}", offset_to_body, hex::encode(&get_4bytes(&buff)));
let xx = &buff[4..offset_to_body as usize];
println!("{}", hex::encode(xx));
let offset_to_vtable = i32::from_le_bytes(get_4bytes(&buff[offset_to_body as usize..]));
println!("Offset to vtable: {:>4}, hex: {}", offset_to_vtable, hex::encode(get_4bytes(&buff[offset_to_body as usize..])));
}
fn get_4bytes(buff: &[u8]) -> [u8; 4] {
let mut ret = [0_u8; 4];
ret[0] = buff[0];
ret[1] = buff[1];
ret[2] = buff[2];
ret[3] = buff[3];
ret
}