Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use user_data_size_bits instead of user_data_size #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions string_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type stringTable struct {
name string
Items map[int32]*stringTableItem
userDataFixedSize bool
userDataSize int32
userDataSizeBits int32
flags int32
varintBitCounts bool
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (p *Parser) onCSVCMsg_CreateStringTable(m *dota.CSVCMsg_CreateStringTable)
name: m.GetName(),
Items: make(map[int32]*stringTableItem),
userDataFixedSize: m.GetUserDataFixedSize(),
userDataSize: m.GetUserDataSize(),
userDataSizeBits: m.GetUserDataSizeBits(),
flags: m.GetFlags(),
varintBitCounts: m.GetUsingVarintBitcounts(),
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (p *Parser) onCSVCMsg_CreateStringTable(m *dota.CSVCMsg_CreateStringTable)
}

// Parse the items out of the string table data
items := parseStringTable(buf, m.GetNumEntries(), t.name, t.userDataFixedSize, t.userDataSize, t.flags, t.varintBitCounts)
items := parseStringTable(buf, m.GetNumEntries(), t.name, t.userDataFixedSize, t.userDataSizeBits, t.flags, t.varintBitCounts)

// Insert the items into the table
for _, item := range items {
Expand Down Expand Up @@ -144,7 +144,7 @@ func (p *Parser) onCSVCMsg_UpdateStringTable(m *dota.CSVCMsg_UpdateStringTable)
}

// Parse the updates out of the string table data
items := parseStringTable(m.GetStringData(), m.GetNumChangedEntries(), t.name, t.userDataFixedSize, t.userDataSize, t.flags, t.varintBitCounts)
items := parseStringTable(m.GetStringData(), m.GetNumChangedEntries(), t.name, t.userDataFixedSize, t.userDataSizeBits, t.flags, t.varintBitCounts)

// Apply the updates to the parser state
for _, item := range items {
Expand Down Expand Up @@ -177,7 +177,7 @@ func (p *Parser) onCSVCMsg_UpdateStringTable(m *dota.CSVCMsg_UpdateStringTable)
}

// Parse a string table data blob, returning a list of item updates.
func parseStringTable(buf []byte, numUpdates int32, name string, userDataFixed bool, userDataSize int32, flags int32, varintBitCounts bool) (items []*stringTableItem) {
func parseStringTable(buf []byte, numUpdates int32, name string, userDataFixed bool, userDataSizeBits int32, flags int32, varintBitCounts bool) (items []*stringTableItem) {
defer func() {
if err := recover(); err != nil {
_debugf("warning: unable to parse string table %s: %s", name, err)
Expand Down Expand Up @@ -267,7 +267,7 @@ func parseStringTable(buf []byte, numUpdates int32, name string, userDataFixed b
bitSize := uint32(0)
isCompressed := false
if userDataFixed {
bitSize = uint32(userDataSize)
bitSize = uint32(userDataSizeBits)
} else {
if (flags & 0x1) != 0 {
isCompressed = r.readBoolean()
Expand Down