aboutsummaryrefslogtreecommitdiffstats
path: root/packet/command/time/time.go
diff options
context:
space:
mode:
Diffstat (limited to 'packet/command/time/time.go')
-rw-r--r--packet/command/time/time.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/packet/command/time/time.go b/packet/command/time/time.go
new file mode 100644
index 0000000..825d571
--- /dev/null
+++ b/packet/command/time/time.go
@@ -0,0 +1,31 @@
+package time
+
+import (
+ "github.com/osm/quake/common/buffer"
+ "github.com/osm/quake/common/context"
+ "github.com/osm/quake/protocol"
+)
+
+type Command struct {
+ Time float32
+}
+
+func (cmd *Command) Bytes() []byte {
+ buf := buffer.New()
+
+ buf.PutByte(protocol.SVCTime)
+ buf.PutFloat32(cmd.Time)
+
+ return buf.Bytes()
+}
+
+func Parse(ctx *context.Context, buf *buffer.Buffer) (*Command, error) {
+ var err error
+ var cmd Command
+
+ if cmd.Time, err = buf.GetFloat32(); err != nil {
+ return nil, err
+ }
+
+ return &cmd, nil
+}