aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/header.go43
-rw-r--r--utils/utils.go12
2 files changed, 6 insertions, 49 deletions
diff --git a/utils/header.go b/utils/header.go
deleted file mode 100644
index 68def9e..0000000
--- a/utils/header.go
+++ /dev/null
@@ -1,43 +0,0 @@
1package utils
2
3import (
4 "fmt"
5 "os"
6)
7
8func HeaderOut(file *os.File) {
9 DemoFileStamp := make([]byte, 8)
10 DemoProtocol := make([]byte, 4)
11 NetworkProtocol := make([]byte, 4)
12 ServerName := make([]byte, 260)
13 ClientName := make([]byte, 260)
14 MapName := make([]byte, 260)
15 GameDirectory := make([]byte, 260)
16 PlaybackTime := make([]byte, 4)
17 PlaybackTicks := make([]byte, 4)
18 PlaybackFrames := make([]byte, 4)
19 SignOnLength := make([]byte, 4)
20 file.Read(DemoFileStamp)
21 file.Read(DemoProtocol)
22 file.Read(NetworkProtocol)
23 file.Read(ServerName)
24 file.Read(ClientName)
25 file.Read(MapName)
26 file.Read(GameDirectory)
27 file.Read(PlaybackTime)
28 file.Read(PlaybackTicks)
29 file.Read(PlaybackFrames)
30 file.Read(SignOnLength)
31
32 fmt.Println(string(DemoFileStamp))
33 fmt.Println(IntFromBytes(DemoProtocol))
34 fmt.Println(IntFromBytes(NetworkProtocol))
35 fmt.Println(string(ServerName))
36 fmt.Println(string(ClientName))
37 fmt.Println(string(MapName))
38 fmt.Println(string(GameDirectory))
39 fmt.Println(FloatFromBytes(PlaybackTime))
40 fmt.Println(IntFromBytes(PlaybackTicks))
41 fmt.Println(IntFromBytes(PlaybackFrames))
42 fmt.Println(IntFromBytes(SignOnLength))
43}
diff --git a/utils/utils.go b/utils/utils.go
index 6db28b0..5226e80 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -9,6 +9,12 @@ import (
9 "unsafe" 9 "unsafe"
10) 10)
11 11
12func CheckError(e error) {
13 if e != nil {
14 log.Panic(e)
15 }
16}
17
12func ReverseByteArrayValues(byteArr []byte, size int) []byte { 18func ReverseByteArrayValues(byteArr []byte, size int) []byte {
13 arr := make([]byte, size) 19 arr := make([]byte, size)
14 for index, byteValue := range byteArr { 20 for index, byteValue := range byteArr {
@@ -23,12 +29,6 @@ func ReadByteFromFile(file *os.File, size int32) []byte {
23 return tmp 29 return tmp
24} 30}
25 31
26func CheckError(e error) {
27 if e != nil {
28 log.Panic(e)
29 }
30}
31
32func IntFromBytes(byteArr []byte) uint32 { 32func IntFromBytes(byteArr []byte) uint32 {
33 int := binary.LittleEndian.Uint32(byteArr) 33 int := binary.LittleEndian.Uint32(byteArr)
34 return int 34 return int