Documentation
¶
Overview ¶
Package wdc decodes WDC5 .db2 game files tables into rows shaped by a .dbd definition, and overlays the game files' XFTH DBCache hotfix records onto them.
Index ¶
- func CombineHotfixFiles(files []string) (map[uint32]*HotfixReader, error)
- func LoadHotfixCaches(cachesDir, baseDir string) (map[uint32]*HotfixReader, error)
- func OrderHotfixReaders(readers map[uint32]*HotfixReader, build uint32, carry bool) (carried []*HotfixReader, own *HotfixReader, newer []uint32)
- func SStrHash(s string) uint32
- type Decoded
- type HotfixEntry
- type HotfixReader
- type Row
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombineHotfixFiles ¶
func CombineHotfixFiles(files []string) (map[uint32]*HotfixReader, error)
CombineHotfixFiles parses each file in order into readers keyed by BuildId: the first file seen for a build becomes its base reader and later files Combine into it.
func LoadHotfixCaches ¶
func LoadHotfixCaches(cachesDir, baseDir string) (map[uint32]*HotfixReader, error)
LoadHotfixCaches scans for cache files: if cachesDir exists, every *.bin under it (recursively) loads first, then every file named DBCache.bin anywhere under baseDir (skipped when baseDir is empty, as in CDN mode). Finding no cache file is not an error; a malformed or unsupported-version file fails loud. Files are visited in WalkDir's deterministic lexical order.
Both roots are resolved through any symlinks before the walk. WalkDir never follows symlinks, and that includes a root that is itself one. An install reached through a linked path would otherwise scan clean and silently run hotfix-free.
func OrderHotfixReaders ¶
func OrderHotfixReaders(readers map[uint32]*HotfixReader, build uint32, carry bool) (carried []*HotfixReader, own *HotfixReader, newer []uint32)
The readers that overlay build: own is build's own reader, or nil. With carry, carried holds the readers of older builds in ascending build order, applied before own so a same-build record wins, and newer lists the builds after build, whose caches are never carried.
Types ¶
type HotfixEntry ¶
type HotfixEntry struct {
RegionID int32
PushID int32
UniqueID int32
TableHash uint32
RecordID int32
DataSize int32
IsValid bool // status/op byte == 1
Data []byte
}
HotfixEntry is one XFTH v9 record: the HotfixEntryV9 header plus its data blob. DataSize always equals len(Data) after parsing; it is kept explicit because it is part of the Combine dedup identity.
type HotfixReader ¶
HotfixReader holds every hotfix record of one DBCache build, in file/combine insertion order.
func ReadHotfixFile ¶
func ReadHotfixFile(path string) (*HotfixReader, error)
ReadHotfixFile parses one DBCache-format file. Only XFTH version 9 is supported; older versions fail loud.
func (*HotfixReader) ApplyHotfixes ¶
func (h *HotfixReader) ApplyHotfixes(t *Table, def dbd.DBDefinition, version dbd.VersionDefinitions, buildNumber uint32, decoded *Decoded) (applied, layoutSkipped bool, err error)
ApplyHotfixes overlays this reader's records for table t onto decoded in place. Records apply in a stable ascending-PushId sort (file/combine insertion order preserved within a PushId). An Add (IsValid && DataSize > 0) replaces or inserts the whole row decoded from the blob; otherwise the row is deleted when shouldDelete. Rows come back out in ascending-ID order, the order the sqlite inserts expect. A reader of another build applies nothing when version does not list its build, and reports layoutSkipped when it holds records for t; applied reports whether any record applied.
func (*HotfixReader) Combine ¶
func (h *HotfixReader) Combine(other *HotfixReader)
Combine merges another reader into this one: other's records are appended in order unless an identical record is already present. Readers for a different build are ignored.
func (*HotfixReader) HighestPush ¶
func (h *HotfixReader) HighestPush() int32
The highest server push among the records, the hotfix level the reader brings; 0 when it holds none. Push -1 marks a row the game cached on demand, and ids from 0x01000000 up are synthetic ones given to on-demand rows, so neither counts.
type Row ¶
Row is one decoded record; Values align 1:1 with the version block's Definitions. Value dynamic types are limited to int64/uint64 scalars, float32, string, []int64, []uint64, []float32 and []string, never []byte, so encoding/json writes every array element-by-element as numbers (no base64), the wowsims.db array-text format.
type Table ¶
type Table struct {
RecordsCount int32
FieldsCount int32
RecordSize int32
StringTableSize int32
TableHash uint32
MinIndex int32
Flags db2Flags
IdFieldIndex uint16
Sections []sectionHeader
Meta []fieldMeta
ColumnMeta []columnMeta
PalletData [][]value32
CommonData []map[int32]value32
StringTable map[int64]string
// SkippedSections counts encrypted sections whose data was zero-filled and
// therefore skipped, which is why the header record count exceeds the number
// of emitted rows.
SkippedSections int
// contains filtered or unexported fields
}
Table is the parsed (but not field-decoded) WDC5 file.
func ReadFile ¶
ReadFile parses a WDC5 .db2 file. Only WDC5 is supported; anything else (including WDC6+) fails loud.
func (*Table) DecodeRows ¶
func (t *Table) DecodeRows(def dbd.DBDefinition, version dbd.VersionDefinitions, buildNumber uint32) (*Decoded, error)
DecodeRows decodes every record (including copy-table duplicates) into values aligned with version.Definitions, returned in ascending-ID order.