implement ESH
This commit is contained in:
parent
7ac969aff4
commit
628010e6c2
4 changed files with 52 additions and 4 deletions
|
|
@ -49,11 +49,12 @@ next zar = <zar> + 0x1A + unk5
|
|||
uint32_t unk1
|
||||
uint16_t ?
|
||||
uint16_t ? (0xFFFF = no <esh>)
|
||||
<esh>
|
||||
|
||||
<esh>
|
||||
uint32_t N
|
||||
N times
|
||||
FString name
|
||||
uint32_t type
|
||||
uint32_t dataLen
|
||||
uint8_t data[dataLen]
|
||||
uint32_t dataSize
|
||||
uint8_t data[dataSize]
|
||||
|
|
@ -4,6 +4,7 @@ mod raw;
|
|||
pub mod save;
|
||||
mod sgd;
|
||||
mod ssg;
|
||||
mod esh;
|
||||
mod stream;
|
||||
mod tag;
|
||||
mod world;
|
||||
|
|
|
|||
46
src/fot/esh.rs
Normal file
46
src/fot/esh.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use super::raw::Raw;
|
||||
use super::tag::Tag;
|
||||
use super::decoder::Decoder;
|
||||
use super::fstring::FString;
|
||||
use super::stream::{ReadStream, WriteStream};
|
||||
use anyhow::Result;
|
||||
use indexmap::IndexMap;
|
||||
|
||||
pub struct ESHValue {
|
||||
pub data_type: u32,
|
||||
pub data: Vec<u8>
|
||||
}
|
||||
|
||||
pub struct ESH {
|
||||
pub tag: Tag,
|
||||
pub props: IndexMap<FString, ESHValue>,
|
||||
enc_size: usize
|
||||
}
|
||||
|
||||
impl Decoder for ESH {
|
||||
fn decode(raw: &Raw, offset: usize, _: usize) -> Result<Self> {
|
||||
let mut rd = ReadStream::new(raw, offset);
|
||||
let tag: Tag = rd.read(0)?;
|
||||
|
||||
let n = rd.read_u32()? as usize;
|
||||
let mut props: IndexMap<FString, ESHValue> = IndexMap::with_capacity(n);
|
||||
for _ in 0..n {
|
||||
let name: FString = rd.read(0)?;
|
||||
let data_type = rd.read_u32()?;
|
||||
let data_size = rd.read_u32()? as usize;
|
||||
let data = rd.read_bytes(data_size)?;
|
||||
props.insert(name, ESHValue { data_type, data });
|
||||
}
|
||||
|
||||
let enc_size = rd.offset() - offset;
|
||||
Ok(ESH { tag, props, enc_size })
|
||||
}
|
||||
|
||||
fn encode(&self) -> Result<Raw> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn get_enc_size(&self) -> usize {
|
||||
self.enc_size
|
||||
}
|
||||
}
|
||||
|
|
@ -7,13 +7,13 @@ use std::io::Cursor;
|
|||
|
||||
// FString - Fallout
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
|
||||
pub enum FStringEncoding {
|
||||
ANSI,
|
||||
WCS2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
|
||||
pub struct FString {
|
||||
pub encoding: FStringEncoding,
|
||||
pub enc_len: usize,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue