Skip to content

Commit

Permalink
fix: support demos protocol >= 13992 and missing game event list
Browse files Browse the repository at this point in the history
The fake game event list changed, it needs to be updated.
  • Loading branch information
akiver committed Feb 20, 2024
1 parent 488c1f9 commit 6b6c51f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/api/analyzer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"embed"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -89,6 +90,18 @@ func getNetMessageDecryptionKey(demoFilePath string) []byte {
return key
}

//go:embed event-list-dump/*.bin
var eventListFolder embed.FS

func getGameEventListBinForProtocol(networkProtocol int) ([]byte, error) {
switch {
case networkProtocol < 13992:
return eventListFolder.ReadFile("event-list-dump/s2_CMsgSource1LegacyGameEventList.bin")
default:
return eventListFolder.ReadFile("event-list-dump/s2_CMsgSource1LegacyGameEventList_13992.bin")
}
}

type AnalyzeDemoOptions struct {
IncludePositions bool
Source constants.DemoSource
Expand Down Expand Up @@ -122,6 +135,12 @@ func analyzeDemo(demoPath string, options AnalyzeDemoOptions) (*Match, error) {
parserConfig.NetMessageDecryptionKey = key
}

gameEventListBin, err := getGameEventListBinForProtocol(demo.NetworkProtocol)
if err != nil {
return nil, err
}
parserConfig.Source2FallbackGameEventListBin = gameEventListBin

parser := dem.NewParserWithConfig(file, parserConfig)
defer parser.Close()

Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 6b6c51f

Please sign in to comment.