diff options
Diffstat (limited to 'messages')
| -rw-r--r-- | messages/header.go | 7 | ||||
| -rw-r--r-- | messages/messages.go | 18 | ||||
| -rw-r--r-- | messages/types.go | 2 |
3 files changed, 17 insertions, 10 deletions
diff --git a/messages/header.go b/messages/header.go index 6320c71..34b36d3 100644 --- a/messages/header.go +++ b/messages/header.go | |||
| @@ -4,8 +4,8 @@ import ( | |||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "os" | 5 | "os" |
| 6 | 6 | ||
| 7 | "github.com/bisaxa/bitreader" | 7 | "github.com/pektezol/bitreader" |
| 8 | "github.com/bisaxa/demoparser/utils" | 8 | "github.com/pektezol/demoparser/utils" |
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | func ParseHeader(file *os.File) { | 11 | func ParseHeader(file *os.File) { |
| @@ -22,5 +22,8 @@ func ParseHeader(file *os.File) { | |||
| 22 | header.PlaybackTicks = int32(reader.TryReadInt32()) | 22 | header.PlaybackTicks = int32(reader.TryReadInt32()) |
| 23 | header.PlaybackFrames = int32(reader.TryReadInt32()) | 23 | header.PlaybackFrames = int32(reader.TryReadInt32()) |
| 24 | header.SignOnLength = int32(reader.TryReadInt32()) | 24 | header.SignOnLength = int32(reader.TryReadInt32()) |
| 25 | if header.DemoProtocol != 4 { // Old Engine == 2, 3 / New Engine == 4 | ||
| 26 | panic("Only New Engine is supported.") | ||
| 27 | } | ||
| 25 | fmt.Printf("%+v", header) | 28 | fmt.Printf("%+v", header) |
| 26 | } | 29 | } |
diff --git a/messages/messages.go b/messages/messages.go index 478b7c7..b40684b 100644 --- a/messages/messages.go +++ b/messages/messages.go | |||
| @@ -4,9 +4,10 @@ import ( | |||
| 4 | "fmt" | 4 | "fmt" |
| 5 | "os" | 5 | "os" |
| 6 | 6 | ||
| 7 | "github.com/bisaxa/bitreader" | 7 | "github.com/pektezol/bitreader" |
| 8 | "github.com/bisaxa/demoparser/classes" | 8 | "github.com/pektezol/demoparser/classes" |
| 9 | "github.com/bisaxa/demoparser/utils" | 9 | "github.com/pektezol/demoparser/classes/netsvc" |
| 10 | "github.com/pektezol/demoparser/utils" | ||
| 10 | ) | 11 | ) |
| 11 | 12 | ||
| 12 | func ParseMessage(file *os.File) (statusCode int) { | 13 | func ParseMessage(file *os.File) (statusCode int) { |
| @@ -22,7 +23,10 @@ func ParseMessage(file *os.File) (statusCode int) { | |||
| 22 | packet.InSequence = int32(reader.TryReadInt32()) | 23 | packet.InSequence = int32(reader.TryReadInt32()) |
| 23 | packet.OutSequence = int32(reader.TryReadInt32()) | 24 | packet.OutSequence = int32(reader.TryReadInt32()) |
| 24 | packet.Size = int32(reader.TryReadInt32()) | 25 | packet.Size = int32(reader.TryReadInt32()) |
| 25 | reader.SkipBytes(int(packet.Size)) // TODO: NET/SVC Message Parsing | 26 | data := utils.ReadByteFromFile(file, packet.Size) |
| 27 | //fmt.Println(data) | ||
| 28 | netsvc.ParseNetSvcMessage(data) | ||
| 29 | //reader.SkipBytes(int(packet.Size)) // TODO: NET/SVC Message Parsing | ||
| 26 | fmt.Printf("[%d] (%d) SignOn: %v\n", messageTick, messageSlot, packet) | 30 | fmt.Printf("[%d] (%d) SignOn: %v\n", messageTick, messageSlot, packet) |
| 27 | return 1 | 31 | return 1 |
| 28 | case 0x02: // Packet | 32 | case 0x02: // Packet |
| @@ -32,7 +36,7 @@ func ParseMessage(file *os.File) (statusCode int) { | |||
| 32 | packet.OutSequence = int32(reader.TryReadInt32()) | 36 | packet.OutSequence = int32(reader.TryReadInt32()) |
| 33 | packet.Size = int32(reader.TryReadInt32()) | 37 | packet.Size = int32(reader.TryReadInt32()) |
| 34 | reader.SkipBytes(int(packet.Size)) // TODO: NET/SVC Message Parsing | 38 | reader.SkipBytes(int(packet.Size)) // TODO: NET/SVC Message Parsing |
| 35 | fmt.Printf("[%d] Packet: %v\n", messageTick, packet) | 39 | //fmt.Printf("[%d] Packet: %v\n", messageTick, packet) |
| 36 | return 2 | 40 | return 2 |
| 37 | case 0x03: // SyncTick | 41 | case 0x03: // SyncTick |
| 38 | return 3 | 42 | return 3 |
| @@ -40,14 +44,14 @@ func ParseMessage(file *os.File) (statusCode int) { | |||
| 40 | var consolecmd ConsoleCmd | 44 | var consolecmd ConsoleCmd |
| 41 | consolecmd.Size = int32(reader.TryReadInt32()) | 45 | consolecmd.Size = int32(reader.TryReadInt32()) |
| 42 | consolecmd.Data = string(utils.ReadByteFromFile(file, consolecmd.Size)) | 46 | consolecmd.Data = string(utils.ReadByteFromFile(file, consolecmd.Size)) |
| 43 | fmt.Printf("[%d] ConsoleCmd: %s\n", messageTick, consolecmd.Data) | 47 | //fmt.Printf("[%d] ConsoleCmd: %s\n", messageTick, consolecmd.Data) |
| 44 | return 4 | 48 | return 4 |
| 45 | case 0x05: // UserCmd | 49 | case 0x05: // UserCmd |
| 46 | var usercmd UserCmd | 50 | var usercmd UserCmd |
| 47 | usercmd.Cmd = int32(reader.TryReadInt32()) | 51 | usercmd.Cmd = int32(reader.TryReadInt32()) |
| 48 | usercmd.Size = int32(reader.TryReadInt32()) | 52 | usercmd.Size = int32(reader.TryReadInt32()) |
| 49 | usercmd.Data = classes.ParseUserCmdInfo(file, int(usercmd.Size)) | 53 | usercmd.Data = classes.ParseUserCmdInfo(file, int(usercmd.Size)) |
| 50 | fmt.Printf("[%d] UserCmd: %v\n", messageTick, usercmd.Data) | 54 | //fmt.Printf("[%d] UserCmd: %v\n", messageTick, usercmd.Data) |
| 51 | return 5 | 55 | return 5 |
| 52 | case 0x06: // DataTables | 56 | case 0x06: // DataTables |
| 53 | var datatables DataTables | 57 | var datatables DataTables |
diff --git a/messages/types.go b/messages/types.go index a8dd19a..9c92c54 100644 --- a/messages/types.go +++ b/messages/types.go | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | package messages | 1 | package messages |
| 2 | 2 | ||
| 3 | import "github.com/bisaxa/demoparser/classes" | 3 | import "github.com/pektezol/demoparser/classes" |
| 4 | 4 | ||
| 5 | type Header struct { | 5 | type Header struct { |
| 6 | DemoFileStamp string | 6 | DemoFileStamp string |