Skip to content

Commit 2a42478

Browse files
committed
feat: skip unknown demo commands messages
1 parent 52940a5 commit 2a42478

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pkg/demoinfocs/events/events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ const (
570570
WarnTypeBombsiteUnknown // may occur on de_grind for bombsite B as the bounding box of the bombsite is wrong
571571
WarnTypeTeamSwapPlayerNil // TODO: figure out why this happens
572572
WarnTypeGameEventBeforeDescriptors // may occur in POV demos
573+
WarnUnknownDemoCommandMessageType // occur when we have an unknown EDemoCommands message type, the protobuf messages probably need to be updated
573574

574575
// WarnTypeMissingNetMessageDecryptionKey occurs when encrypted net-messages are encountered and the decryption key is missing.
575576
// See ParserConfig.NetMessageDecryptionKey

pkg/demoinfocs/parsing.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,17 @@ func (p *parser) parseFrameS2() bool {
340340

341341
size := p.bitReader.ReadVarInt32()
342342

343+
msgCreator := demoCommandMsgsCreators[msgType]
344+
if msgCreator == nil {
345+
p.eventDispatcher.Dispatch(events.ParserWarn{
346+
Message: fmt.Sprintf("skipping unknown demo commands message type with value %d", msgType),
347+
Type: events.WarnUnknownDemoCommandMessageType,
348+
})
349+
p.bitReader.Skip(int(size) << 3)
350+
351+
return true
352+
}
353+
343354
buf := p.bitReader.ReadBytes(int(size))
344355

345356
if msgCompressed {
@@ -357,7 +368,7 @@ func (p *parser) parseFrameS2() bool {
357368
}
358369
}
359370

360-
msg := demoCommandMsgsCreators[msgType]()
371+
msg := msgCreator()
361372

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

0 commit comments

Comments
 (0)