Skip to content

Commit

Permalink
simplify Parser.parseFrameS2
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Dec 2, 2024
1 parent 47aca2b commit ae3c7a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
5 changes: 5 additions & 0 deletions pkg/demoinfocs/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ func NewParserWithConfig(demostream io.Reader, config ParserConfig) Parser {
p.msgDispatcher.RegisterHandler(p.handleServerRankUpdate)
p.msgDispatcher.RegisterHandler(p.handleMessageSayText)
p.msgDispatcher.RegisterHandler(p.handleMessageSayText2)
p.msgDispatcher.RegisterHandler(p.handleSendTables)
p.msgDispatcher.RegisterHandler(p.handleFileInfo)
p.msgDispatcher.RegisterHandler(p.handleDemoFileHeader)
p.msgDispatcher.RegisterHandler(p.handleClassInfo)
p.msgDispatcher.RegisterHandler(p.handleStringTables)

if config.MsgQueueBufferSize >= 0 {
p.initMsgQueue(config.MsgQueueBufferSize)
Expand Down
19 changes: 4 additions & 15 deletions pkg/demoinfocs/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,26 +393,15 @@ func (p *parser) parseFrameS2() bool {
p.msgQueue <- msg

switch m := msg.(type) {
case *msgs2.CDemoFileHeader:
p.handleDemoFileHeader(m)

case *msgs2.CDemoPacket:
p.handleDemoPacket(m)

case *msgs2.CDemoFullPacket:
p.handleFullPacket(m)

case *msgs2.CDemoSendTables:
p.handleSendTables(m)

case *msgs2.CDemoClassInfo:
p.handleClassInfo(m)
p.msgQueue <- m.StringTable

case *msgs2.CDemoStringTables:
p.handleStringTables(m)

case *msgs2.CDemoFileInfo:
p.handleFileInfo(m)
if m.Packet.GetData() != nil {
p.handleDemoPacket(m.Packet)
}
}

// Queue up some post processing
Expand Down
4 changes: 0 additions & 4 deletions pkg/demoinfocs/s2_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ import (
)

func (p *parser) handleSendTables(msg *msgs2.CDemoSendTables) {
p.msgDispatcher.SyncAllQueues()

err := p.stParser.ParsePacket(msg.Data)
if err != nil {
panic(errors.Wrap(err, "failed to unmarshal flattened serializer"))
}
}

func (p *parser) handleClassInfo(msg *msgs2.CDemoClassInfo) {
p.msgDispatcher.SyncAllQueues()

err := p.stParser.OnDemoClassInfo(msg)
if err != nil {
panic(err)
Expand Down
2 changes: 0 additions & 2 deletions pkg/demoinfocs/stringtables.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,6 @@ func (p *parser) processModelPreCacheUpdate() {
// XXX TODO: decide if we want to at all integrate these updates,
// or trust create/update entirely. Let's ignore them for now.
func (p *parser) handleStringTables(msg *msgs2.CDemoStringTables) {
p.msgDispatcher.SyncAllQueues()

for _, tab := range msg.GetTables() {
if tab.GetTableName() == stNameInstanceBaseline {
for _, item := range tab.GetItems() {
Expand Down

0 comments on commit ae3c7a2

Please sign in to comment.