diff --git a/format.txt b/format.txt new file mode 100644 index 0000000..59bc896 --- /dev/null +++ b/format.txt @@ -0,0 +1,30 @@ +string format - uint32_t len, 31 bit represents encoding where 0 is UTF-7 (ASCII), and 1 is UTF-16 (WCS-2) + +tag format ? +\0version\0 + +/* + uint32_t unk1 + uint32_t unk2 + uint8_t unk3 ? + uint32_t unk4 + 0x46C - + 0x15 + (unk4 << 2) - B2 00 + 0x46D - unk5 + +next zar = + 0x1A + unk5 +0xBC22 + (0x100<<2) = unk5 0x7659*/ + + ++0x0A - int16_t ? ++0x0B - 4 strings. + 1. uknown + 2. name + 3. location + 4. date + + + uint32_t unk1 - used in calloc, unk1 * 0x10C + + + uint32_t uncompressed_size; + uint32_t uncompressed_size; \ No newline at end of file diff --git a/src/fot/raw.rs b/src/fot/raw.rs index 470ffdc..554ed2f 100644 --- a/src/fot/raw.rs +++ b/src/fot/raw.rs @@ -5,9 +5,6 @@ use std::fs::OpenOptions; use std::path::Path; use anyhow::Result; -// I can use traits to dynamically implement encode/decode for every header -// or I can just pass Vec with already encoded data to patch file - pub struct Raw { pub offset: usize, pub size: usize, diff --git a/src/fot/save.rs b/src/fot/save.rs index 9d3d7c2..21105b1 100644 --- a/src/fot/save.rs +++ b/src/fot/save.rs @@ -79,42 +79,6 @@ impl Save { } pub fn save(&self, path: &Path) -> Result<()> { - let mut file = OpenOptions::new() - .create(true).truncate(true).write(true).open(path)?; - - // write unknown block - /*let unk_size = match self.worlds.first() { - Some(w) => w.offset - 1, - None => return Err(anyhow!("no offsets found")) - }; - file.write(&self.raw[..unk_size])?; - - for world in self.worlds.iter() { - file.write(&self.raw[world.offset..world.offset+0x12])?; - file.write(&world.encode())?; - }*/ - - // determine world block size be next campaign - /*const START: usize = 0x99A84; - const END: usize = 0xD1B1E; //0xD1B1E; - const SIZE: usize = 0x38088; - //let world = self.worlds.last().unwrap(); - let world = World::decode(&self.raw, START, END - START)?; - file.write(&self.raw[..START])?; - - file.write(&self.raw[world.offset..world.offset+0x13])?; - { - let enc = world.encode(); - let real_len = SIZE; - println!("enc len {} real_len {}", enc.len(), real_len); - file.write(&enc)?; - if (enc.len() < real_len) { - file.write(&vec![0; real_len - enc.len()])?; - } - } - - file.write(&self.raw[END+1..])?;*/ - let raw = Raw { offset: 0, size: self.raw.len(), mem: self.raw.clone() }; const START: usize = 0x99A84;