gdio

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 0 Imported by: 0

README

gdio

gdio is a library of low-level routines to decode and encode save files of Grim Dawn game. The supported files include, for example, save files of characters (player.gdc) or save files with tokens and quests progress (quests.gdd). The library is aimed to be a foundation layer for the more high-level projects and provides decryption/encryption contexts, processing of basic scalars (bytes and 32-bit unsigned numbers) and advanced values (strings, sequences, blocks) accordingly to the format of the save files. It provides subpackages pop and push to, correspondingly, decode and encode data.

Usage

The core of the library is type Decenc, which represents decryption/encryption contexts. The library provides function New as a constructor of the contexts, which "grows" them from "seeds". "Seeds" are just some 32-bit unsigned integers, which can be found at the very beginning of the save files. For example:

import (
	"encoding/binary"
	"os"

	"codeberg.org/alex-ilchukov/gdio"
)

func main() {
	data, err := os.ReadFile("/path/to/player.gdc")
	if err != nil {
		// Process the error
	}
	if len(data) < 4 {
		// Signal, that there is not enough data
	}
	seed := binary.LittleEndian.Uint32(data)
	// Grow a context from the acquired seed
	ctx := gdio.New(seed)
	…
}

Using a decryption/encryption context, one can start to pop and push values with help of the subpackages of the library:

import (
	"codeberg.org/alex-ilchukov/gdio"
	"codeberg.org/alex-ilchukov/gdio/pop"
	"codeberg.org/alex-ilchukov/gdio/push"
)

func main() {
	…
	ctx := gdio.New(seed)
	ctx.Data = data
	for range pop.Block(ctx, 1) {
		fmt.Printf("Version: %d", pop.Uint32(ctx))
		…
	}
	…
	ctx2 := gdio.New(seed)
	push.Uint32(ctx2, 123)
	push.String(ctx2, "abcd")
	push.Float32(ctx2, 1.4)
	…
}

The subpackages provide detailed documentation on the supported values and behavior of the processing. Most of the routines directly access and change slice of encoded data, which resides in the field Data of the context, allowing to decode or collect the data in some continous way. They signal on errors, halting input context with an error. Despite the unhindered access to the field Err, provided by the type Decenc, the routines use method Halt of the contexts, which doesn't overwrite an error already saved within. The approach allows swift and smooth processing without additional error values:

v := pop.Uint32(ctx)
if ctx.Err != nil {
	// Process the error
}

The subpackages use public singleton error values for simple cases along with public error types for more complex ones. The library always encourages to check an error value within a context against them.

License

The library is licensed under MIT license.

Documentation

Overview

Package gdio provides a type Decenc of decryption/encryption contexts to process encoded data of save files of Grim Dawn game. Such a context is supposed to be "grown" from a "seed" (which can usually be found in the beginning of a save file of interest) with function New and, after that, supplied to low-level routines of subpackages [pop] and [push] to obtain or encode values.

Index

Constants

View Source
const Version = "v1.0.0"

Version of the library

Variables

This section is empty.

Functions

This section is empty.

Types

type Decenc

type Decenc struct {

	// State is current state of the context, either obtained through
	// transformation method or installed directly
	State uint32

	// Data is a slice of raw bytes of encoded values. The bytes are always
	// supposed to be in little endian order. External routines can "pop"
	// bytes from the slice (almost in terms of a queue) or "push" bytes of
	// some encoded values to it (stack-like). The data is opened to any
	// transformation or replace, but it is supposed to have a continuous
	// history.
	Data []byte

	// Err is an error value, currently saved within the context
	Err error
	// contains filtered or unexported fields
}

Decenc is a type of decoding/encoding contexts, which encapsulate three pretty independent aspects:

  • a kind of state along with transformation rules, "grown" from a "seed";
  • a slice of encoded data, allowing to pop values from it to decode or push encoded values to it;
  • an error to signal a problem within a particular process along with ability to "halt" the context.

The aspects have been combined in the contexts, because they are supposed to be universal input/output entities, supplied to and thrown between different processes. The processes vary from low-level (to decode an unsigned 32-bit integer from the data) to high-level (say, to encode and push a block of stashes of a character to the context's data). Accordingly to that, the type provides direct access to some properties of the contexts (state of the context, data slice or current error value) to allow straightfoward transformation by the low-level facilities. It hides, nevertheless, the seed and the rules, as they aren't supposed to be accessed by any facility.

func New

func New(seed uint32) *Decenc

New takes a seed, "grows" transformation rules and a state from the seed, and returns a pointer to a decoding/encoding context with the data saved within

func (*Decenc) Halt

func (c *Decenc) Halt(err error)

Halt saves the provided error, if an error has yet to be saved within the context, or does nothing otherwise

func (*Decenc) Seed

func (c *Decenc) Seed() uint32

Seed returns the "seed", from which the transformation rules have been grown by function New along with the initial state

func (*Decenc) Transform

func (c *Decenc) Transform(b byte)

Transform accepts a byte and transforms the state accordingly to the corresponding entry in the table

Directories

Path Synopsis
Package pop provides low-level routines to decode values from save files of Grim Dawn.
Package pop provides low-level routines to decode values from save files of Grim Dawn.
Package push provides low-level routines to encode values accordingly to the format of save files of Grim Dawn.
Package push provides low-level routines to encode values accordingly to the format of save files of Grim Dawn.

Jump to

Keyboard shortcuts

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