implement SSG (though it's unknown)

This commit is contained in:
mykola2312 2023-08-30 23:57:03 +03:00
parent 6597063d7c
commit 7ac969aff4
4 changed files with 38 additions and 4 deletions

View file

@ -3,6 +3,7 @@ mod fstring;
mod raw;
pub mod save;
mod sgd;
mod ssg;
mod stream;
mod tag;
mod world;

View file

@ -1,5 +1,3 @@
use std::ops::Index;
use super::decoder::Decoder;
use super::fstring::FString;
use super::raw::Raw;
@ -17,7 +15,7 @@ pub struct SGD {
}
impl Decoder for SGD {
fn decode(raw: &Raw, offset: usize, size: usize) -> Result<Self> {
fn decode(raw: &Raw, offset: usize, _: usize) -> Result<Self> {
let mut rd = ReadStream::new(raw, offset);
let tag: Tag = rd.read(0)?;
let unk1 = rd.read_bytes(0x48)?;

31
src/fot/ssg.rs Normal file
View file

@ -0,0 +1,31 @@
use super::decoder::Decoder;
use super::raw::Raw;
use super::stream::{ReadStream, WriteStream};
use super::tag::Tag;
use anyhow::Result;
#[derive(Debug)]
pub struct SSG {
tag: Tag,
unk1: Vec<u8>,
}
impl Decoder for SSG {
fn decode(raw: &Raw, offset: usize, _: usize) -> Result<Self> {
let mut rd = ReadStream::new(raw, offset);
let tag: Tag = rd.read(0)?;
let unk1 = rd.read_bytes(0x14)?;
Ok(SSG { tag, unk1 })
}
fn encode(&self) -> Result<Raw> {
let mut wd = WriteStream::new(self.get_enc_size());
wd.write(&self.tag)?;
wd.write_bytes(&self.unk1);
Ok(wd.into_raw(0, 0x14))
}
fn get_enc_size(&self) -> usize {
self.tag.get_enc_size() + 0x14
}
}

View file

@ -2,11 +2,12 @@ use super::decoder::Decoder;
use super::fstring::FString;
use super::raw::Raw;
use super::sgd::SGD;
use super::ssg::SSG;
use super::stream::ReadStream;
use super::tag::Tag;
use anyhow::anyhow;
use anyhow::Result;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use byteorder::{LittleEndian, WriteBytesExt};
use deflate::deflate_bytes_zlib;
use inflate::inflate_bytes_zlib;
use std::io::Cursor;
@ -20,6 +21,7 @@ pub struct World {
pub mission: FString,
pub sgd: SGD,
pub ssg: SSG,
}
impl World {
@ -51,6 +53,7 @@ impl Decoder for World {
let mission: FString = rd.read(0)?;
let sgd: SGD = rd.read(0)?;
let ssg: SSG = rd.read(0)?;
Ok(World {
tag,
@ -58,6 +61,7 @@ impl Decoder for World {
data,
mission,
sgd,
ssg,
})
}