Skip to main content

Save

Struct Save 

Source
pub struct Save {
    pub metadata: Vec<u8>,
    pub state: Vec<u8>,
}
Expand description

A save file: its two payloads, expanded. See the module documentation.

Fields§

§metadata: Vec<u8>

Expanded metadata stream (the first payload; see SaveMetadata).

§state: Vec<u8>

Expanded game-state stream (the second payload).

Implementations§

Source§

impl Save

Source

pub fn parse(data: &[u8]) -> Result<Save>

Read a Save from the bytes of its resource.

Source

pub fn read_metadata(data: &[u8]) -> Result<SaveMetadata>

Only the metadata, as the save list reads it: the game state is not expanded.

Original: Persistence::BeginGetSaveGameInfo, then SaveLoad::LoadMetaData.

Original: Runtime 0x1800c43a0.

Source

pub fn metadata(&self) -> Result<SaveMetadata>

The metadata: the town’s name, the preview picture and the mods.

Source

pub fn write(metadata: &SaveMetadata, state: &[u8]) -> Vec<u8> ⓘ

A version 2 save file: the metadata as payload 0x24 and the game state as payload 1, each compressed (IO::CompressedStream), behind the checked header.

Source

pub fn event_log(&self) -> Option<SavedEventLog>

Find the event-log block (version 1: six notify bytes, a count and entries of colour, text, type, severity, cell, category, icon). Located by scanning for a block whose contents parse as exactly that and fill the block; the game-state order before it is not walked.

Source

pub fn references(&self) -> Result<Vec<(u32, String)>>

External reference table: (id, path) pairs.

Source

pub fn loop_header(&self) -> Result<LoopHeader>

The game loop’s header: the seed, the map size, and the terrain, climate and start condition.

Source

pub fn map_heights(&self) -> Result<MapHeights>

Locate the map block by its dimension header (2n, n, 32, 33, 2n+1, 33^2).

Source§

impl Save

Source

pub fn map_cells(&self) -> Result<MapCells>

Locate the gameplay map block (0xaaaaaaaa, size, 4, n, n²) and read its cells. n is half the terrain size (see map_heights).

Auto Trait Implementations§

§

impl Freeze for Save

§

impl RefUnwindSafe for Save

§

impl Send for Save

§

impl Sync for Save

§

impl Unpin for Save

§

impl UnsafeUnpin for Save

§

impl UnwindSafe for Save

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.