Skip to content

Commit

Permalink
feat: skip unknown demo commands messages
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Apr 28, 2024
1 parent 83c78cb commit 8dc98fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/demoinfocs/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ const (
WarnTypeBombsiteUnknown // may occur on de_grind for bombsite B as the bounding box of the bombsite is wrong
WarnTypeTeamSwapPlayerNil // TODO: figure out why this happens
WarnTypeGameEventBeforeDescriptors // may occur in POV demos
WarnUnknownDemoCommandMessageType // occur when we have an unknown EDemoCommands message type, the protobuf messages probably need to be updated

// WarnTypeMissingNetMessageDecryptionKey occurs when encrypted net-messages are encountered and the decryption key is missing.
// See ParserConfig.NetMessageDecryptionKey
Expand Down
13 changes: 12 additions & 1 deletion pkg/demoinfocs/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ func (p *parser) parseFrameS2() bool {

size := p.bitReader.ReadVarInt32()

msgCreator := demoCommandMsgsCreators[msgType]
if msgCreator == nil {
p.eventDispatcher.Dispatch(events.ParserWarn{
Message: fmt.Sprintf("skipping unknown demo commands message type with value %d", msgType),
Type: events.WarnUnknownDemoCommandMessageType,
})
p.bitReader.Skip(int(size) << 3)

return true
}

buf := p.bitReader.ReadBytes(int(size))

if msgCompressed {
Expand All @@ -357,7 +368,7 @@ func (p *parser) parseFrameS2() bool {
}
}

msg := demoCommandMsgsCreators[msgType]()
msg := msgCreator()

if msg == nil {
panic(fmt.Sprintf("Unknown demo command: %d", msgType))
Expand Down

0 comments on commit 8dc98fb

Please sign in to comment.