aboutsummaryrefslogtreecommitdiffstats
path: root/packet/clc/parse.go
blob: 594a9dd5df8c69adc02827026e0c3972d9227b42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package clc

import (
	"github.com/osm/quake/common/buffer"
	"github.com/osm/quake/common/context"
	"github.com/osm/quake/packet"
)

func Parse(ctx *context.Context, data []byte) (packet.Packet, error) {
	buf := buffer.New(buffer.WithData(data))

	header, _ := buf.PeekInt32()
	if header == -1 {
		return parseConnectionless(ctx, buf)
	}

	return parseGameData(ctx, buf)
}