aboutsummaryrefslogtreecommitdiffstats
path: root/packet/command/damage
diff options
context:
space:
mode:
Diffstat (limited to 'packet/command/damage')
-rw-r--r--packet/command/damage/damage.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/packet/command/damage/damage.go b/packet/command/damage/damage.go
new file mode 100644
index 0000000..93ddb1e
--- /dev/null
+++ b/packet/command/damage/damage.go
@@ -0,0 +1,61 @@
+package damage
+
+import (
+ "github.com/osm/quake/common/buffer"
+ "github.com/osm/quake/common/context"
+ "github.com/osm/quake/protocol"
+)
+
+type Command struct {
+ CoordSize uint8
+
+ Armor byte
+ Blood byte
+ Coord [3]float32
+}
+
+func (cmd *Command) Bytes() []byte {
+ buf := buffer.New()
+
+ writeCoord := buf.PutCoord16
+ if cmd.CoordSize == 4 {
+ writeCoord = buf.PutCoord32
+ }
+
+ buf.PutByte(byte(protocol.SVCDamage))
+ buf.PutByte(cmd.Armor)
+ buf.PutByte(cmd.Blood)
+
+ for i := 0; i < 3; i++ {
+ writeCoord(cmd.Coord[i])
+ }
+
+ return buf.Bytes()
+}
+
+func Parse(ctx *context.Context, buf *buffer.Buffer) (*Command, error) {
+ var err error
+ var cmd Command
+
+ cmd.CoordSize = ctx.GetCoordSize()
+ readCoord := buf.GetCoord16
+ if cmd.CoordSize == 4 {
+ readCoord = buf.GetCoord32
+ }
+
+ if cmd.Armor, err = buf.ReadByte(); err != nil {
+ return nil, err
+ }
+
+ if cmd.Blood, err = buf.ReadByte(); err != nil {
+ return nil, err
+ }
+
+ for i := 0; i < 3; i++ {
+ if cmd.Coord[i], err = readCoord(); err != nil {
+ return nil, err
+ }
+ }
+
+ return &cmd, nil
+}
2006-08-10Added tag 0.3 for changeset d352e9dc112ee96aa5cad961a0ed880ae9ce7276Gravatar Anselm R.Garbe 1-0/+1 2006-08-10readded border colors, this sucks leastGravatar Anselm R.Garbe 5-26/+38 2006-08-10drawing border around sel itemGravatar Anselm R.Garbe 2-6/+21 2006-08-10removed unnecessary border colorGravatar Anselm R.Garbe 5-34/+7 2006-08-10swapping my default colorsGravatar Anselm R.Garbe 1-2/+2 2006-08-10added uppercase chars for C-u and C-h as wellGravatar Anselm R.Garbe 1-0/+2 2006-08-10removed C-[ from source and man pageGravatar Anselm R.Garbe 2-5/+1 2006-08-09removed control sequences which actually aren't implemented anymore (only the...Gravatar Anselm R.Garbe 1-4/+4 2006-08-08fixes to READMEGravatar Anselm R.Garbe 1-2/+2 2006-08-08default colors are bestGravatar Anselm R.Garbe 1-3/+3 2006-08-08noborderGravatar Anselm R.Garbe 1-2/+2 2006-08-08ditoGravatar Anselm R.Garbe 1-2/+2 2006-08-08using a better colorschemeGravatar Anselm R.Garbe 1-1/+1 2006-08-07removed unnecessary typedefGravatar arg@10ksloc.org 1-1/+0 2006-08-07made dmenu(1) more dwm(1) alikeGravatar arg@10ksloc.org 1-23/+22 2006-08-07font size changed as wellGravatar arg@10ksloc.org 1-1/+1 2006-08-07appliead Sanders manpage/Makefile pacthGravatar arg@10ksloc.org 2-2/+2 2006-08-07fixed dmenu.1 version infoGravatar arg@10ksloc.org 1-1/+1 2006-08-07settle with greyGravatar arg@10ksloc.org 1-2/+2 2006-08-07next version is 0.3Gravatar arg@10ksloc.org 1-1/+1 2006-08-07also made my colors tasting better with my overall colorschemeGravatar arg@10ksloc.org 1-3/+3 2006-08-07next attempt for bright background switchGravatar arg@10ksloc.org 1-3/+3 2006-08-07Added tag 0.2 for changeset 656be0f47df545dfdd2e1e0663663b8b1b26f031Gravatar arg@10ksloc.org 1-0/+1 2006-08-07added stripping to dmenu targetGravatar arg@10ksloc.org 1-0/+1 2006-08-07fixed a bad mistake setting the dmenu border to False;Gravatar arg@10ksloc.org 1-1/+0 2006-08-07renamed some functions to make it more readableGravatar arg@10ksloc.org 1-9/+9 2006-08-07updated man pageGravatar arg@10ksloc.org 1-1/+1 2006-08-07updated man pageGravatar arg@10ksloc.org 1-0/+4 2006-08-07removed -t title crap from dmenuGravatar arg@10ksloc.org 2-57/+12 2006-08-05menu now also uses -OsGravatar arg@10ksloc.org 1-2/+2 2006-08-05small changeGravatar arg@10ksloc.org 1-1/+1 2006-08-04yet another fixGravatar arg@10ksloc.org 1-2/+2 2006-08-04fixed README of dmenuGravatar arg@10ksloc.org 1-27/+10 2006-08-04fixed dist targetGravatar arg@10ksloc.org 1-1/+1 2006-08-04removed config.hGravatar arg@10ksloc.org 1-9/+0