This repository has been archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemofiledump.go
98 lines (83 loc) · 2.14 KB
/
demofiledump.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
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"fmt"
"log"
)
const (
NET_MAX_PAYLOAD int32 = (262144 - 4) // largest message that can be sent in bytes
DEMO_RECORD_BUFFER_SIZE int32 = (2 * 1024 * 1024) // should fit string tables and server classes
MAX_PLAYER_NAME_LENGTH int32 = 128
SIGNED_GUID_LEN int32 = 32 // hashed CD key
MAX_CUSTOM_FILES int32 = 4
)
var (
matchStartOccurred bool = false
currentTick int32
)
type StringTableData struct {
Name []byte
MaxEntries int
}
// Player's information on server
type PlayerInfo struct {
version uint64
xuid uint64
name [MAX_PLAYER_NAME_LENGTH]byte
userID int
guid [SIGNED_GUID_LEN + 1]byte
friendsID uint32
friendsName [MAX_PLAYER_NAME_LENGTH]byte
fakePlayer bool
isHLTV bool
customFiles [MAX_CUSTOM_FILES]CRC32
filesDownloaded uint8
}
type DemoFileDump struct {
demoFile DemoFile
frameNumber int
}
func (d *DemoFileDump) Open(fileName string) bool {
if d.demoFile.Open(fileName) == false {
log.Fatal("Unable to open demo file")
return false
}
return true
}
func (d *DemoFileDump) DoDump() {
matchStartOccurred = false
var demoFinished bool = false
fmt.Println("--- Header debug ---")
d.demoFile.debugHeader()
fmt.Println("--------------------\n")
for !demoFinished {
fmt.Println("--- Read loop ---")
// get data from command header
var cmd, playerSlot uint8
var tick int32 = 0
d.demoFile.ReadCmdHeader(&cmd, &tick, &playerSlot)
fmt.Println("Old tick: ", currentTick, " new tick: ", tick)
currentTick = tick
// command handling
switch cmd {
case dem_stop:
demoFinished = true
fmt.Println("Stopping demo at tick: ", tick)
case dem_consolecmd:
// read raw data
d.demoFile.ReadRawData(nil, 0)
case dem_datatables:
// read some data
//var data []byte = make([]byte, DEMO_RECORD_BUFFER_SIZE)
// parse data
case dem_stringtables:
// read raw data
// dump string tables
case dem_usercmd:
// read user command
var dummy int32
d.demoFile.ReadUserCmd(nil, &dummy)
case dem_signon, dem_packet, dem_synctick:
// handle packet
}
}
}