MCPcopy Create free account
hub / github.com/dotabuff/manta / onCSVCMsg_CreateStringTable

Method onCSVCMsg_CreateStringTable

string_table.go:72–135  ·  view source on GitHub ↗

Internal callback for CSVCMsg_CreateStringTable. XXX TODO: This is currently using an artificial, internally crafted message. This should be replaced with the real message once we have updated protos.

(m *dota.CSVCMsg_CreateStringTable)

Source from the content-addressed store, hash-verified

70// XXX TODO: This is currently using an artificial, internally crafted message.
71// This should be replaced with the real message once we have updated protos.
72func (p *Parser) onCSVCMsg_CreateStringTable(m *dota.CSVCMsg_CreateStringTable) error {
73 // Create a new string table at the next index position
74 t := &stringTable{
75 index: p.stringTables.nextIndex,
76 name: m.GetName(),
77 Items: make(map[int32]*stringTableItem),
78 userDataFixedSize: m.GetUserDataFixedSize(),
79 userDataSizeBits: m.GetUserDataSizeBits(),
80 flags: m.GetFlags(),
81 varintBitCounts: m.GetUsingVarintBitcounts(),
82 }
83
84 // Increment the index
85 p.stringTables.nextIndex += 1
86
87 // Decompress the data if necessary
88 buf := m.GetStringData()
89 if m.GetDataCompressed() {
90 // old replays = lzss
91 // new replays = snappy
92
93 r := newReader(buf)
94 var err error
95
96 if s := r.readStringN(4); s != "LZSS" {
97 if buf, err = snappy.Decode(nil, buf); err != nil {
98 return err
99 }
100 } else {
101 if buf, err = unlzss(buf); err != nil {
102 return err
103 }
104 }
105 }
106
107 // Parse the items out of the string table data
108 items, err := parseStringTable(buf, m.GetNumEntries(), t.name, t.userDataFixedSize, t.userDataSizeBits, t.flags, t.varintBitCounts)
109 if err != nil {
110 return err
111 }
112
113 // Insert the items into the table
114 for _, item := range items {
115 t.Items[item.Index] = item
116 }
117
118 // Add the table to the parser state
119 p.stringTables.Tables[t.index] = t
120 p.stringTables.NameIndex[t.name] = t.index
121
122 // Apply the updates to baseline state
123 if t.name == "instancebaseline" {
124 p.updateInstanceBaseline()
125 }
126
127 // Emit events for modifier table entry updates
128 if t.name == "ActiveModifiers" {
129 if err := p.emitModifierTableEvents(items); err != nil {

Callers

nothing calls this directly

Calls 14

newReaderFunction · 0.85
unlzssFunction · 0.85
parseStringTableFunction · 0.85
GetUserDataFixedSizeMethod · 0.80
GetUserDataSizeBitsMethod · 0.80
GetDataCompressedMethod · 0.80
readStringNMethod · 0.80
GetNameMethod · 0.45
GetFlagsMethod · 0.45

Tested by

no test coverage detected