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)
| 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. |
| 72 | func (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 { |
nothing calls this directly
no test coverage detected