// 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.
499135
func (p *Parser) onCSVCMsg_CreateStringTable(m *dota.CSVCMsg_CreateStringTable) error {
	// Create a new string table at the next index position
	t := &stringTable{
		index:             p.stringTables.nextIndex,
		name:              m.GetName(),
		Items:             make(map[int32]*stringTableItem),
		userDataFixedSize: m.GetUserDataFixedSize(),
		userDataSize:      m.GetUserDataSize(),
		flags:             m.GetFlags(),
	}

	// Increment the index
	p.stringTables.nextIndex += 1

	// Decompress the data if necessary
	buf := m.GetStringData()
	if m.GetDataCompressed() {
		// old replays = lzss
		// new replays = snappy

		r := newReader(buf)
		var err error

		if s := r.readStringN(4); s != "LZSS" {
			if buf, err = snappy.Decode(nil, buf); err != nil {
				return err
			}
		} else {
			if buf, err = unlzss(buf); err != nil {
				return err
			}
		}
	}

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

	// Insert the items into the table
	for _, item := range items {
		t.Items[item.Index] = item
	}

	// Add the table to the parser state
	p.stringTables.Tables[t.index] = t
	p.stringTables.NameIndex[t.name] = t.index

	// Apply the updates to baseline state
	if t.name == "instancebaseline" {
		p.updateInstanceBaseline()
	}

	return nil
}
441394
func (c *Callbacks) OnCSVCMsg_CmdKeyValues(fn func(*dota.CSVCMsg_CmdKeyValues) error) {
	c.onCSVCMsg_CmdKeyValues = append(c.onCSVCMsg_CmdKeyValues, fn)
}
226347
func (c *Callbacks) OnCSVCMsg_VoiceData(fn func(*dota.CSVCMsg_VoiceData) error) {
	c.onCSVCMsg_VoiceData = append(c.onCSVCMsg_VoiceData, fn)
}
580527
func (z *Session) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 1
	// write "v"
	err = en.Append(0x81, 0xa1, 0x76)
	if err != nil {
		return err
	}
	err = en.WriteMapHeader(uint32(len(z.Values)))
	if err != nil {
		return
	}
	for xvk, bzg := range z.Values {
		err = en.WriteString(xvk)
		if err != nil {
			return
		}
		err = en.WriteIntf(bzg)
		if err != nil {
			return
		}
	}
	return
}
330900
func (c *Callbacks) OnCNETMsg_StringCmd(fn func(*dota.CNETMsg_StringCmd) error) {
	c.onCNETMsg_StringCmd = append(c.onCNETMsg_StringCmd, fn)
}
673614
func (m *NewRoundStepMessage) String() string {
	return fmt.Sprintf("[NewRoundStep H:%v R:%v S:%v LCR:%v]",
		m.Height, m.Round, m.Step, m.LastCommitRound)
}
950007
func (c *Callbacks) OnCSVCMsg_PacketEntities(fn func(*dota.CSVCMsg_PacketEntities) error) {
	c.onCSVCMsg_PacketEntities = append(c.onCSVCMsg_PacketEntities, fn)
}
1094839
func (c *Callbacks) OnCSVCMsg_SetView(fn func(*dota.CSVCMsg_SetView) error) {
	c.onCSVCMsg_SetView = append(c.onCSVCMsg_SetView, fn)
}
66433
func DecodeMsgString(msg *pstypes.WebSocketMessage) (string, error) {
	s, err := DecodeMsg(msg)
	if err != nil {
		return "", err
	}
	str, ok := s.(string)
	if !ok {
		return "", fmt.Errorf("content of Message was not of type string")
	}
	return str, nil
}
1319176
func (c *Callbacks) OnCSVCMsg_FlattenedSerializer(fn func(*dota.CSVCMsg_FlattenedSerializer) error) {
	c.onCSVCMsg_FlattenedSerializer = append(c.onCSVCMsg_FlattenedSerializer, fn)
}
598950
func (c *Callbacks) OnCSVCMsg_Sounds(fn func(*dota.CSVCMsg_Sounds) error) {
	c.onCSVCMsg_Sounds = append(c.onCSVCMsg_Sounds, fn)
}
277077
func (ds *DummyStatus) PrintMsg(msg message) {
	if !globalJSON {
		console.Println(msg.String())
	} else {
		console.Println(msg.JSON())
	}
}
291194
func (c *Callbacks) OnCUserMessageTextMsg(fn func(*dota.CUserMessageTextMsg) error) {
	c.onCUserMessageTextMsg = append(c.onCUserMessageTextMsg, fn)
}
1321936
func (c *Callbacks) OnCUserMessageHintText(fn func(*dota.CUserMessageHintText) error) {
	c.onCUserMessageHintText = append(c.onCUserMessageHintText, fn)
}
5139
func (c *Callbacks) OnCSVCMsg_UpdateStringTable(fn func(*dota.CSVCMsg_UpdateStringTable) error) {
	c.onCSVCMsg_UpdateStringTable = append(c.onCSVCMsg_UpdateStringTable, fn)
}
278812
func (c *Callbacks) OnCSVCMsg_BSPDecal(fn func(*dota.CSVCMsg_BSPDecal) error) {
	c.onCSVCMsg_BSPDecal = append(c.onCSVCMsg_BSPDecal, fn)
}
1366606
func protoMessageDoc(msg proto.Message) (name, doc string) {
	withDesc, ok := msg.(descriptor.Message)
	if !ok {
		return "", ""
	}

	fd, md := descriptor.ForMessage(withDesc)
	if fd == nil || md == nil {
		return "", ""
	}

	for _, info := range publicProtos {
		// Find the exact same *.proto file within publicProtos struct.
		if info.goPath == fd.GetName() {
			if info.docURL == "" {
				return "", "" // no docs for it
			}
			return md.GetName(), info.docURL
		}
	}

	return "", "" // not a public proto
}