diff options
Diffstat (limited to 'packet/command/updatestatlong/updatestatlong.go')
| -rw-r--r-- | packet/command/updatestatlong/updatestatlong.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packet/command/updatestatlong/updatestatlong.go b/packet/command/updatestatlong/updatestatlong.go new file mode 100644 index 0000000..f45a0d9 --- /dev/null +++ b/packet/command/updatestatlong/updatestatlong.go @@ -0,0 +1,37 @@ +package updatestatlong + +import ( + "github.com/osm/quake/common/buffer" + "github.com/osm/quake/common/context" + "github.com/osm/quake/protocol" +) + +type Command struct { + Stat byte + Value int32 +} + +func (cmd *Command) Bytes() []byte { + buf := buffer.New() + + buf.PutByte(protocol.SVCUpdateStatLong) + buf.PutByte(cmd.Stat) + buf.PutInt32(cmd.Value) + + return buf.Bytes() +} + +func Parse(ctx *context.Context, buf *buffer.Buffer) (*Command, error) { + var err error + var cmd Command + + if cmd.Stat, err = buf.ReadByte(); err != nil { + return nil, err + } + + if cmd.Value, err = buf.GetInt32(); err != nil { + return nil, err + } + + return &cmd, nil +} |
