Closed markus-wa closed 1 month ago
Describe the bug Due to #280, BombEvent.Site may not be set for some bomb sites. Currently the only known case is Bombsite B on de_grind.
BombEvent.Site
To Reproduce two sample demos are here: https://drive.google.com/drive/folders/1KptOTNbFlfQVdaz-i78Z0J7DnXhBs7GE?usp=sharing
Code:
package main import ( "fmt" "os" "bufio" "bytes" "compress/bzip2" "compress/gzip" "io" "io/ioutil" "path/filepath" demoinfocs "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs" "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events" ) func main() { demoFile, err := os.Open("/home/mark/Downloads/003480011012659216461_0088537034.dem.bz2") if err != nil { panic(err) } defer demoFile.Close() var demoUnzippedReader io.Reader switch filepath.Ext(demoFile.Name()) { case ".bz2": demoUnzippedReader = bzip2.NewReader(bufio.NewReader(demoFile)) case ".gz": demoZippedReader, err := gzip.NewReader(demoFile) if err != nil { panic(err) } t, err := ioutil.ReadAll(demoZippedReader) if err != nil { panic(err) } demoUnzippedReader = bytes.NewReader(t) case ".dem": demoUnzippedReader = bufio.NewReader(demoFile) default: panic(err) } demoUnzippedBytes, err := ioutil.ReadAll(demoUnzippedReader) if err != nil { panic(err) } r := bytes.NewReader(demoUnzippedBytes) p := demoinfocs.NewParser(r) defer p.Close() p.RegisterEventHandler(func(planted events.BombPlanted) { if planted.Site != events.BombsiteA && planted.Site != events.BombsiteB { fmt.Println("oh no! unknown bomb site") } // handle event as usual }) demoHerader, err := p.ParseHeader() if err != nil { panic(err) } fmt.Println(demoHerader.MapName) err = p.ParseToEnd() if err != nil { panic(err) } }
Expected behavior It never prints oh no! unknown bomb site for any bomb event
oh no! unknown bomb site
Actual behaviour For de_grind games, it prints oh no! unknown bomb site
Workaround The following code works around the issue as it seems like the only case of this happening is bomb site B on de_grind.
if planted.Site != events.BombsiteA && planted.Site != events.BombsiteB && p.Header().MapName == "de_grind" { planted.Site = events.BombsiteB }
Library version v2.7.1
Closing as this was for CS:GO
Describe the bug Due to #280,
BombEvent.Site
may not be set for some bomb sites. Currently the only known case is Bombsite B on de_grind.To Reproduce two sample demos are here: https://drive.google.com/drive/folders/1KptOTNbFlfQVdaz-i78Z0J7DnXhBs7GE?usp=sharing
Code:
Expected behavior It never prints
oh no! unknown bomb site
for any bomb eventActual behaviour For de_grind games, it prints
oh no! unknown bomb site
Workaround The following code works around the issue as it seems like the only case of this happening is bomb site B on de_grind.
Library version v2.7.1
Additional context