dbc

package module
v0.0.0-...-16ef6cd Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 7 Imported by: 0

README

go-dbc

A package for simple reading and writing of DBC files from World of Warcraft versions 1.12 to 3.3.5 using Go. (Support for other versions may be partial, and functionality cannot be guaranteed.)

Installation

To install, simply run:

go get -u github.com/AcoStar7819/go-dbc

Usage

Before working with a specific DBC file, you need to define its format.

An example usage can be found in the example/main.go file.

Documentation

Index

Constants

View Source
const MagicWDBC = 0x43424457

MagicWDBC is the constant corresponding to "WDBC" in ASCII. 0x57 = 'W', 0x44 = 'D', 0x42 = 'B', 0x43 = 'C'

Variables

This section is empty.

Functions

func UnmarshalRecords

func UnmarshalRecords(dbcFile *File, userStructSlice interface{}) error

UnmarshalRecords reads raw records into a slice of user-defined structures (e.g., *[]ChrClassesRecord). It uses tags like: `dbc:"column=0,type=uint32"`. Supports basic types: int32/uint32/float32/float64 and strings (via offset). For localized columns (offset + mask), the logic can be extended if needed.

func WriteDBC

func WriteDBC(w io.Writer, f *File) error

WriteDBC writes the File structure into writer, forming a correct header.

func WriteFile

func WriteFile(filename string, dbcFile *File) error

WriteFile is a convenient wrapper to write to a file by name.

Types

type File

type File struct {
	Header      Header
	RawRecords  []byte // length = RecordCount * RecordSize
	StringBlock []byte // length = StringBlockSize
}

File describes the structure of a read DBC file in raw form.

func MarshalRecords

func MarshalRecords(userStructSlice interface{}) (*File, error)

MarshalRecords performs the reverse operation — forms raw records in a DBCFile from the given slice of structures. Simplified: generates a new stringBlock and sets string offsets. For localized strings with a bitmask (0), reserves 2 columns (offset, mask=0).

func ReadDBC

func ReadDBC(r io.Reader) (*File, error)

ReadDBC reads the entire DBC file from reader into a File structure.

func ReadFile

func ReadFile(filename string) (*File, error)

ReadFile is a convenient wrapper to read from a file by name.

type Header struct {
	Magic           uint32 // should always be MagicWDBC (0x43424457)
	RecordCount     uint32
	FieldCount      uint32
	RecordSize      uint32
	StringBlockSize uint32
}

Header describes the header of a DBC file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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