Internal callback for CSVCMsg_UpdateStringTable.
(m *dota.CSVCMsg_UpdateStringTable)
| 136 | |
| 137 | // Internal callback for CSVCMsg_UpdateStringTable. |
| 138 | func (p *Parser) onCSVCMsg_UpdateStringTable(m *dota.CSVCMsg_UpdateStringTable) error { |
| 139 | // TODO: integrate |
| 140 | t, ok := p.stringTables.Tables[m.GetTableId()] |
| 141 | if !ok { |
| 142 | _panicf("missing string table %d", m.GetTableId()) |
| 143 | } |
| 144 | |
| 145 | if v(5) { |
| 146 | _debugf("tick=%d name=%s changedEntries=%d size=%d", p.Tick, t.name, m.GetNumChangedEntries(), len(m.GetStringData())) |
| 147 | } |
| 148 | |
| 149 | // Parse the updates out of the string table data |
| 150 | items, err := parseStringTable(m.GetStringData(), m.GetNumChangedEntries(), t.name, t.userDataFixedSize, t.userDataSizeBits, t.flags, t.varintBitCounts) |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | |
| 155 | // Apply the updates to the parser state |
| 156 | for _, item := range items { |
| 157 | index := item.Index |
| 158 | if _, ok := t.Items[index]; ok { |
| 159 | if item.Key != "" && item.Key != t.Items[index].Key { |
| 160 | t.Items[index].Key = item.Key |
| 161 | } |
| 162 | if len(item.Value) > 0 { |
| 163 | t.Items[index].Value = item.Value |
| 164 | } |
| 165 | } else { |
| 166 | t.Items[index] = item |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // Apply the updates to baseline state |
| 171 | if t.name == "instancebaseline" { |
| 172 | p.updateInstanceBaseline() |
| 173 | } |
| 174 | |
| 175 | // Emit events for modifier table entry updates |
| 176 | if t.name == "ActiveModifiers" { |
| 177 | if err := p.emitModifierTableEvents(items); err != nil { |
| 178 | return err |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | // Parse a string table data blob, returning a list of item updates. |
| 186 | func parseStringTable(buf []byte, numUpdates int32, name string, userDataFixed bool, userDataSizeBits int32, flags int32, varintBitCounts bool) (items []*stringTableItem, err error) { |
nothing calls this directly
no test coverage detected