stingray

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

"triad" describes a storage unit used in the game files. It consists of a "main" file (no extension), a "stream" file (.stream), and a "GPU" file (.gpu_resources). The stream and GPU files are optional.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataDir

type DataDir struct {
	Files map[FileID]*File
}

func OpenDataDir

func OpenDataDir(ctx context.Context, dirPath string, onProgress func(curr, total int)) (*DataDir, error)

Opens the "data" game directory, reading all file metadata. Ctx allows for granular cancellation (before each triad open). onProgress is optional.

type DataType

type DataType int
const (
	DataMain DataType = iota
	DataStream
	DataGPU
	NumDataType
)

func (DataType) String

func (t DataType) String() string

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Exists

func (f *File) Exists(typ DataType) bool

func (*File) ID added in v0.3.0

func (f *File) ID() FileID

func (*File) Open

func (f *File) Open(ctx context.Context, typ DataType) (io.ReadSeekCloser, error)

Call Close() on returned reader when done.

func (*File) OpenMulti added in v0.3.0

func (f *File) OpenMulti(ctx context.Context, types ...DataType) (io.ReadCloser, error)

Returns a MultiReader concatenating the given data stream types. Skips any specified types that don't exist. If you need seeking functionality, use Open(). Call Close() on returned reader when done.

type FileData

type FileData struct {
	ID               FileID
	MainOffset       uint64
	StreamOffset     uint64
	GPUOffset        uint64
	MainBufferOffset uint64
	GPUBufferOffset  uint64
	MainSize         uint32
	StreamSize       uint32
	GPUSize          uint32
	MainAlignment    uint32
	GPUAlignment     uint32
	Index            uint32
}

type FileID

type FileID struct {
	Name Hash
	Type Hash
}

type Hash

type Hash struct{ Value uint64 }

func Sum64

func Sum64(b []byte) Hash

Murmur64a hash

func (Hash) String

func (h Hash) String() string

func (Hash) StringEndian added in v0.1.7

func (h Hash) StringEndian(endian binary.ByteOrder) string

func (Hash) Thin added in v0.1.6

func (h Hash) Thin() ThinHash

type HeaderData

type HeaderData struct {
	MagicNum [4]byte // 0x11 0x00 0x00 0xF0
	NumTypes uint32
	NumFiles uint32

	Unk00          [20]byte
	ApproxMainSize uint64 // aligned by 256 / weirdly offset
	ApproxGPUSize  uint64 // aligned by 256 / weirdly offset
	Unk01          [24]byte
}

Unk means the data's purpose is unknown.

type ThinHash

type ThinHash struct{ Value uint32 }

func (ThinHash) String added in v0.1.6

func (h ThinHash) String() string

func (ThinHash) StringEndian added in v0.1.7

func (h ThinHash) StringEndian(endian binary.ByteOrder) string

type Triad

type Triad struct {
	MainPath   string
	StreamPath string // optional
	GPUpath    string // optional
	Header     HeaderData
	Types      []TypeData
	Files      []FileData
}

A triad consists of a main file, a stream file and a GPU resource file. The stream file and GPU resource file are optional.

func OpenTriad

func OpenTriad(mainPath string) (*Triad, error)

func (*Triad) HasDataType

func (tr *Triad) HasDataType(typ DataType) bool

func (*Triad) HasFile

func (tr *Triad) HasFile(fileIndex int, typ DataType) (bool, error)

func (*Triad) OpenFile

func (tr *Triad) OpenFile(fileIndex int, typ DataType) (io.ReadSeekCloser, error)

Call Close() on returned reader when done.

type TypeData

type TypeData struct {
	Unk00         uint32
	Unk01         uint32
	Name          Hash
	Count         uint32
	Unk02         uint32
	MainAlignment uint32
	GPUAlignment  uint32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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