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/clientdata/clientdata.go | 164 ++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 packet/command/clientdata/clientdata.go (limited to 'packet/command/clientdata/clientdata.go') diff --git a/packet/command/clientdata/clientdata.go b/packet/command/clientdata/clientdata.go new file mode 100644 index 0000000..d032edd --- /dev/null +++ b/packet/command/clientdata/clientdata.go @@ -0,0 +1,164 @@ +package clientdata + +import ( + "github.com/osm/quake/common/buffer" + "github.com/osm/quake/common/context" + "github.com/osm/quake/protocol" +) + +type Command struct { + Bits uint16 + ViewHeight byte + IdealPitch byte + PunchAngle [3]byte + Velocity [3]byte + Items uint32 + WeaponFrame byte + Armor byte + Weapon byte + Health uint16 + ActiveAmmo byte + AmmoShells byte + AmmoNails byte + AmmoRockets byte + AmmoCells byte + ActiveWeapon byte +} + +func (cmd *Command) Bytes() []byte { + buf := buffer.New() + + buf.PutByte(protocol.SVCClientData) + buf.PutUint16(cmd.Bits) + + if cmd.Bits&protocol.SUViewHeight != 0 { + buf.PutByte(cmd.ViewHeight) + } + + if cmd.Bits&protocol.SUIdealPitch != 0 { + buf.PutByte(cmd.IdealPitch) + } + + for i := 0; i < 3; i++ { + if cmd.Bits&(protocol.SUPunch1<