wtf23a

package
v0.0.0-...-a0f82c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2017 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package wtf23a implements the encoding used by Dwarf Fortress for save files created before version 40d.

Ported from http://dwarffortresswiki.org/index.php/User:Quietust/wtf23a.php

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIndex = errors.New("wtf23a: invalid header index")

ErrInvalidIndex is returned if a header has an index greater than the size of the state array or is not an integer.

Functions

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader wraps an io.Reader to decode Dwarf Fortress 23a's obfuscated file encoding.

func NewWriter

func NewWriter(w io.Writer, generateHeader func() Header) io.Writer

NewWriter wraps an io.Writer to output Dwarf Fortress 23a's obfuscated file encoding. ZeroHeader and RandomHeader(r) are predefined header generators.

func RandomHeader

func RandomHeader(r *rand.Rand) func() Header

RandomHeader returns a function that can be used with NewWriter to generate random valid header values.

Types

type Header struct {
	State [624]uint32
	Index uint32
}

Header is the header used to store the initial state of a wtf23a segment.

func ReadHeader

func ReadHeader(r io.Reader) (Header, error)

ReadHeader reads a Header from an io.Reader.

func ZeroHeader

func ZeroHeader() Header

ZeroHeader is a function that can be used with NewWriter to generate headers that do not obfuscate the data.

func (*Header) Next

func (h *Header) Next() uint32

Next returns the next value. It modifies the State and Index of the Header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL