Skip to content

Commit 6831f82

Browse files
authored
don't panic for unknown bombsites, raise ParserWarn event instead (#283)
1 parent dd05964 commit 6831f82

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pkg/demoinfocs/events/events.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,18 @@ type StringTableCreated struct {
499499
TableName string
500500
}
501501

502+
// WarnType identifies a kind of warning for the ParserWarn event.
503+
type WarnType int
504+
505+
const (
506+
WarnTypeUndefined = iota
507+
WarnTypeBombsiteUnknown // may occur on de_grind for bombsite B as the bounding box of the bombsite is wrong
508+
)
509+
502510
// ParserWarn signals that a non-fatal problem occurred during parsing.
503511
type ParserWarn struct {
504512
Message string
513+
Type WarnType
505514
}
506515

507516
// GenericGameEvent signals any game-event.

pkg/demoinfocs/game_events.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package demoinfocs
22

33
import (
4-
"errors"
54
"fmt"
65

76
"github.com/golang/geo/r3"
@@ -652,7 +651,12 @@ func (geh gameEventHandler) bombEvent(data map[string]*msg.CSVCMsg_GameEventKeyT
652651
bombEvent.Site = events.BombsiteB
653652
geh.parser.bombsiteB.index = site
654653
} else {
655-
return bombEvent, errors.New("bomb not planted on bombsite A or B")
654+
// this may occur on de_grind for bombsite B, really makes you think
655+
// see https://github.com/markus-wa/demoinfocs-golang/issues/280
656+
geh.dispatch(events.ParserWarn{
657+
Message: "bombsite unknown for bomb related event",
658+
Type: events.WarnTypeBombsiteUnknown,
659+
})
656660
}
657661
}
658662

0 commit comments

Comments
 (0)