From ca90ebdfa8789654766c5d7969baa7afacd9ebd2 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Mon, 16 Feb 2026 16:31:54 -0500 Subject: initial commit --- packet/command/setinfo/setinfo.go | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packet/command/setinfo/setinfo.go (limited to 'packet/command/setinfo') diff --git a/packet/command/setinfo/setinfo.go b/packet/command/setinfo/setinfo.go new file mode 100644 index 0000000..6262ab8 --- /dev/null +++ b/packet/command/setinfo/setinfo.go @@ -0,0 +1,43 @@ +package setinfo + +import ( + "github.com/osm/quake/common/buffer" + "github.com/osm/quake/common/context" + "github.com/osm/quake/protocol" +) + +type Command struct { + PlayerIndex byte + Key string + Value string +} + +func (cmd *Command) Bytes() []byte { + buf := buffer.New() + + buf.PutByte(protocol.SVCSetInfo) + buf.PutByte(cmd.PlayerIndex) + buf.PutString(cmd.Key) + buf.PutString(cmd.Value) + + return buf.Bytes() +} + +func Parse(ctx *context.Context, buf *buffer.Buffer) (*Command, error) { + var err error + var cmd Command + + if cmd.PlayerIndex, err = buf.ReadByte(); err != nil { + return nil, err + } + + if cmd.Key, err = buf.GetString(); err != nil { + return nil, err + } + + if cmd.Value, err = buf.GetString(); err != nil { + return nil, err + } + + return &cmd, nil +} -- cgit v1.2.3-59-g8ed1b