From 561e4a4dd3459f889719b10fae10fd685f3b430d Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Thu, 31 Aug 2023 06:54:57 +0300 Subject: [PATCH] some discoveries about ESH data types --- format.txt | 21 ++++++++++++++++++++- src/fot/esh.rs | 2 ++ src/fot/stream.rs | 3 +++ src/fot/world.rs | 5 +++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/format.txt b/format.txt index 2d19a58..ad9ee13 100644 --- a/format.txt +++ b/format.txt @@ -57,4 +57,23 @@ next zar = + 0x1A + unk5 FString name uint32_t type uint32_t dataSize - uint8_t data[dataSize] \ No newline at end of file + uint8_t data[dataSize] + +esh data types +1 - bool, 1 byte +2 - float, 4 byte +3 - int32_t/uint32_t +4 - FString +5 - entity? FString? +8 - FString (Sprite) +11 - esbin +13 - frame, 48 bytes -- multiply all numbers by 4.0 + uint8_t unk1[36] + float c + float b + float a +14 - rect, 16 bytes + int32_t top + int32_t left + int32_t right + int32_t bottom \ No newline at end of file diff --git a/src/fot/esh.rs b/src/fot/esh.rs index 535fcc2..5d22a09 100644 --- a/src/fot/esh.rs +++ b/src/fot/esh.rs @@ -6,11 +6,13 @@ use super::stream::{ReadStream, WriteStream}; use anyhow::Result; use indexmap::IndexMap; +#[derive(Debug)] pub struct ESHValue { pub data_type: u32, pub data: Vec } +#[derive(Debug)] pub struct ESH { pub tag: Tag, pub props: IndexMap, diff --git a/src/fot/stream.rs b/src/fot/stream.rs index 070923a..d47c27e 100644 --- a/src/fot/stream.rs +++ b/src/fot/stream.rs @@ -39,6 +39,9 @@ impl<'a> ReadStream<'a> { Ok(self.as_bytes(size)?.to_vec()) } + // "size" is not required to be actual size, it's only + // a hint for Decoder::decode. Most of the structures are + // dynamically determining their decoding and encoding sizes pub fn read(&mut self, size: usize) -> Result { let val = T::decode(&self.raw, self.offset(), size)?; self.skip(val.get_enc_size()); diff --git a/src/fot/world.rs b/src/fot/world.rs index 18e5bfa..940b2f8 100644 --- a/src/fot/world.rs +++ b/src/fot/world.rs @@ -3,6 +3,7 @@ use super::fstring::FString; use super::raw::Raw; use super::sgd::SGD; use super::ssg::SSG; +use super::esh::ESH; use super::stream::ReadStream; use super::tag::Tag; use anyhow::anyhow; @@ -29,6 +30,10 @@ impl World { const WORLD_HDR_LEN: usize = 0x13; pub fn test(&self) -> Result<()> { + let mut rd = ReadStream::new(&self.data, 0x14AC); + let esh: ESH = rd.read(0)?; + dbg!(&esh); + Ok(()) } }