-
Notifications
You must be signed in to change notification settings - Fork 16
/
debugger.go
85 lines (73 loc) · 2.07 KB
/
debugger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"bytes"
"fmt"
"os"
"strconv"
"time"
"github.com/1lann/lol-replay/recording"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("GLR File Debugger")
fmt.Println("This utility dumps information for debugging recordings")
fmt.Println("Usage: " + os.Args[0] + " recording.glr")
return
}
file, err := os.OpenFile(os.Args[1], os.O_RDWR, 0666)
if err != nil {
fmt.Println("failed to open file:", err)
return
}
rec, err := recording.NewRecording(file)
if err != nil {
fmt.Println("failed to read recording:", err)
file.Close()
return
}
fmt.Println("--- Recording properties ---")
fmt.Println("Has game metadata:", rec.HasGameMetadata())
fmt.Println("Has user metadata:", rec.HasUserMetadata())
fmt.Println("Is recording complete:", rec.IsComplete())
fmt.Println("")
fmt.Println("--- Game information ---")
gameInfo := rec.RetrieveGameInfo()
fmt.Println("Platform:", gameInfo.Platform)
fmt.Println("Game version:", gameInfo.Version)
fmt.Println("Record time", gameInfo.RecordTime.Format(time.RFC1123Z))
fmt.Println("Encryption key:", gameInfo.EncryptionKey)
fmt.Println("")
buf := new(bytes.Buffer)
fmt.Println("--- Metadata information ---")
rec.RetrieveGameMetadataTo(buf)
fmt.Println(buf.String())
fmt.Println("--- Chunk information ---")
buf.Reset()
rec.RetrieveFirstChunkInfo().WriteTo(buf)
fmt.Println("First chunk information:")
fmt.Println(buf.String())
buf.Reset()
rec.RetrieveLastChunkInfo().WriteTo(buf)
fmt.Println("Last chunk information:")
fmt.Println(buf.String())
fmt.Println("")
fmt.Println("--- Chunk and key frame data ---")
fmt.Println("Chunks found:")
for i := 0; i < 1000; i++ {
if rec.HasChunk(i) {
buf.Reset()
rec.RetrieveChunkTo(i, buf)
fmt.Println(" " + strconv.Itoa(i) + ": size: " + strconv.Itoa(buf.Len()))
}
}
fmt.Println("Key frames found:")
for i := 0; i < 1000; i++ {
if rec.HasKeyFrame(i) {
buf.Reset()
rec.RetrieveKeyFrameTo(i, buf)
fmt.Println(" " + strconv.Itoa(i) + ": size: " + strconv.Itoa(buf.Len()))
}
}
fmt.Println("")
fmt.Println("--- End of report ---")
}