protocol

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPlayers        = 32
	PlayerNameLen     = 16
	TeamNameLen       = 10
	ProtocolVersion75 = 3
)
View Source
const (
	MagazineAmmoRifle75   = 10
	MagazineAmmoSMG75     = 30
	MagazineAmmoShotgun75 = 6

	ReserveAmmoRifle75   = 50
	ReserveAmmoSMG75     = 120
	ReserveAmmoShotgun75 = 48

	FireDelayMillisecondsRifle75   = 500
	FireDelayMillisecondsSMG75     = 100
	FireDelayMillisecondsShotgun75 = 1000

	PelletQuantityRifle75   = 1
	PelletQuantitySMG75     = 1
	PelletQuantityShotgun75 = 8

	InitialBlocks   = 50
	InitialGrenades = 3
	InitialHP       = 100

	MaxHP       = 100
	MaxBlocks   = 50
	MaxGrenades = 3
)

Variables

This section is empty.

Functions

func CP437ToString

func CP437ToString(b []byte) (string, error)

func GetDefaultMagazineAmmo

func GetDefaultMagazineAmmo(weapon WeaponType) uint8

func GetDefaultReserveAmmo

func GetDefaultReserveAmmo(weapon WeaponType) uint8

func GetFireDelay

func GetFireDelay(weapon WeaponType) int

func GetPelletCount

func GetPelletCount(weapon WeaponType) int

func IsValidOrientation

func IsValidOrientation(x, y, z float32) bool

func IsValidPosition

func IsValidPosition(x, y, z float32) bool

func ReadPacket

func ReadPacket(r io.Reader, packet interface{}) error

func StringToCP437

func StringToCP437(s string) ([]byte, error)

func WritePacket

func WritePacket(w io.Writer, packet interface{}) error

Types

type BlockActionType

type BlockActionType uint8
const (
	BlockActionTypeBuild                 BlockActionType = 0
	BlockActionTypeSpadeGunDestroy       BlockActionType = 1
	BlockActionTypeSpadeSecondaryDestroy BlockActionType = 2
	BlockActionTypeGrenadeDestroy        BlockActionType = 3
)

type CTFStateData

type CTFStateData struct {
	Team1Score   uint8
	Team2Score   uint8
	CaptureLimit uint8
	HeldIntels   uint8
	CarrierIDs   [2]uint8
	Team1Intel   Vector3f
	Team2Intel   Vector3f
	Team1Base    Vector3f
	Team2Base    Vector3f
}

type ChatType

type ChatType uint8
const (
	ChatTypeAll     ChatType = 0
	ChatTypeTeam    ChatType = 1
	ChatTypeSystem  ChatType = 2
	ChatTypeBig     ChatType = 3
	ChatTypeInfo    ChatType = 4
	ChatTypeWarning ChatType = 5
	ChatTypeError   ChatType = 6
)

type Color3b

type Color3b struct {
	B, G, R uint8
}

type DisconnectReason

type DisconnectReason uint8
const (
	DisconnectReasonUndefined    DisconnectReason = 0
	DisconnectReasonBanned       DisconnectReason = 1
	DisconnectReasonIPLimit      DisconnectReason = 2
	DisconnectReasonWrongVersion DisconnectReason = 3
	DisconnectReasonServerFull   DisconnectReason = 4
	DisconnectReasonShutdown     DisconnectReason = 5
	DisconnectReasonKicked       DisconnectReason = 10
	DisconnectReasonInvalidName  DisconnectReason = 20
)

type ExtensionEntry

type ExtensionEntry struct {
	ExtensionID      ExtensionID
	ExtensionVersion uint8
}

type ExtensionID

type ExtensionID uint8
const (
	ExtensionIDPlayerProperties ExtensionID = 0
	ExtensionID256Players       ExtensionID = 192
	ExtensionIDMessageTypes     ExtensionID = 193
	ExtensionIDKickReason       ExtensionID = 194
)

type GamemodeType

type GamemodeType uint8
const (
	GamemodeTypeCTF GamemodeType = 0
	GamemodeTypeTC  GamemodeType = 1
)

type HitType

type HitType uint8
const (
	HitTypeTorso HitType = 0
	HitTypeHead  HitType = 1
	HitTypeArms  HitType = 2
	HitTypeLegs  HitType = 3
	HitTypeMelee HitType = 4
)

type HurtType added in v0.2.0

type HurtType uint8
const (
	HurtTypeFall   HurtType = 0
	HurtTypeWeapon HurtType = 1
)

type ItemType

type ItemType uint8
const (
	ItemTypeSpade   ItemType = 0
	ItemTypeBlock   ItemType = 1
	ItemTypeGun     ItemType = 2
	ItemTypeGrenade ItemType = 3
)

type KeyState

type KeyState uint8
const (
	KeyStateForward  KeyState = 1 << 0
	KeyStateBackward KeyState = 1 << 1
	KeyStateLeft     KeyState = 1 << 2
	KeyStateRight    KeyState = 1 << 3
	KeyStateJump     KeyState = 1 << 4
	KeyStateCrouch   KeyState = 1 << 5
	KeyStateSneak    KeyState = 1 << 6
	KeyStateSprint   KeyState = 1 << 7
)

type KillType

type KillType uint8
const (
	KillTypeWeapon      KillType = 0
	KillTypeHeadshot    KillType = 1
	KillTypeMelee       KillType = 2
	KillTypeGrenade     KillType = 3
	KillTypeFall        KillType = 4
	KillTypeTeamChange  KillType = 5
	KillTypeClassChange KillType = 6
)

type PacketBlockAction

type PacketBlockAction struct {
	PacketID uint8
	PlayerID uint8
	Action   BlockActionType
	X, Y, Z  int32
}

type PacketBlockLine

type PacketBlockLine struct {
	PacketID               uint8
	PlayerID               uint8
	StartX, StartY, StartZ uint32
	EndX, EndY, EndZ       uint32
}

type PacketChangeTeam

type PacketChangeTeam struct {
	PacketID uint8
	PlayerID uint8
	TeamID   uint8
}

type PacketChangeWeapon

type PacketChangeWeapon struct {
	PacketID uint8
	PlayerID uint8
	WeaponID WeaponType
}

type PacketChatMessage

type PacketChatMessage struct {
	PacketID uint8
	PlayerID uint8
	Type     ChatType
	Message  []byte
}

func (*PacketChatMessage) Read

func (p *PacketChatMessage) Read(data []byte) error

func (*PacketChatMessage) Write

func (p *PacketChatMessage) Write(w io.Writer) error

type PacketCreatePlayer

type PacketCreatePlayer struct {
	PacketID uint8
	PlayerID uint8
	Weapon   WeaponType
	Team     uint8
	X, Y, Z  float32
	Name     [PlayerNameLen]byte
}

type PacketExistingPlayer

type PacketExistingPlayer struct {
	PacketID uint8
	PlayerID uint8
	Team     uint8
	Weapon   WeaponType
	Item     ItemType
	Kills    uint32
	Color    Color3b
	Name     [PlayerNameLen]byte
}

type PacketExtensionInfo

type PacketExtensionInfo struct {
	PacketID uint8
	Length   uint8
	Entries  []ExtensionEntry
}

func (*PacketExtensionInfo) Read

func (p *PacketExtensionInfo) Read(data []byte) error

func (*PacketExtensionInfo) Write

func (p *PacketExtensionInfo) Write(w io.Writer) error

type PacketFogColor

type PacketFogColor struct {
	PacketID uint8
	Color    Color3b
	A        uint8
}

type PacketGrenade

type PacketGrenade struct {
	PacketID   uint8
	PlayerID   uint8
	FuseLength float32
	X, Y, Z    float32
	VX, VY, VZ float32
}

type PacketHandShakeInit

type PacketHandShakeInit struct {
	PacketID  uint8
	Challenge uint32
}

func (*PacketHandShakeInit) Write

func (p *PacketHandShakeInit) Write(w io.Writer) error

type PacketHandShakeReturn

type PacketHandShakeReturn struct {
	PacketID  uint8
	Challenge uint32
}

func (*PacketHandShakeReturn) Read

func (p *PacketHandShakeReturn) Read(data []byte) error

type PacketHit

type PacketHit struct {
	PacketID uint8
	PlayerID uint8
	HitType  HitType
}

type PacketInputData

type PacketInputData struct {
	PacketID  uint8
	PlayerID  uint8
	KeyStates KeyState
}

type PacketIntelCapture

type PacketIntelCapture struct {
	PacketID uint8
	PlayerID uint8
	Winning  uint8
}

type PacketIntelDrop

type PacketIntelDrop struct {
	PacketID uint8
	PlayerID uint8
	Position Vector3f
}

type PacketIntelPickup

type PacketIntelPickup struct {
	PacketID uint8
	PlayerID uint8
}

type PacketKillAction

type PacketKillAction struct {
	PacketID    uint8
	PlayerID    uint8
	KillerID    uint8
	KillType    KillType
	RespawnTime uint8
}

type PacketMapChunk

type PacketMapChunk struct {
	PacketID uint8
	Data     []byte
}

func (*PacketMapChunk) Write

func (p *PacketMapChunk) Write(w io.Writer) error

type PacketMapStart

type PacketMapStart struct {
	PacketID uint8
	MapSize  uint32
}

func (*PacketMapStart) Write

func (p *PacketMapStart) Write(w io.Writer) error

type PacketMoveObject

type PacketMoveObject struct {
	PacketID uint8
	ObjectID uint8
	Team     uint8
	X, Y, Z  float32
}

func (*PacketMoveObject) Read

func (p *PacketMoveObject) Read(data []byte) error

func (*PacketMoveObject) Write

func (p *PacketMoveObject) Write(w io.Writer) error

type PacketOrientationData

type PacketOrientationData struct {
	PacketID uint8
	X, Y, Z  float32
}

func (*PacketOrientationData) Read

func (p *PacketOrientationData) Read(r io.Reader) error

func (*PacketOrientationData) Write

func (p *PacketOrientationData) Write(w io.Writer) error

type PacketPlayerLeft

type PacketPlayerLeft struct {
	PacketID uint8
	PlayerID uint8
}

type PacketPlayerProperties

type PacketPlayerProperties struct {
	PacketID     uint8
	SubPacketID  uint8
	PlayerID     uint8
	HP           uint8
	Blocks       uint8
	Grenades     uint8
	MagazineAmmo uint8
	ReserveAmmo  uint8
	Score        uint32
}

func (*PacketPlayerProperties) Write

func (p *PacketPlayerProperties) Write(w io.Writer) error

type PacketPositionData

type PacketPositionData struct {
	PacketID uint8
	X, Y, Z  float32
}

func (*PacketPositionData) Read

func (p *PacketPositionData) Read(r io.Reader) error

func (*PacketPositionData) Write

func (p *PacketPositionData) Write(w io.Writer) error

type PacketProgressBar

type PacketProgressBar struct {
	PacketID      uint8
	EntityID      uint8
	CapturingTeam uint8
	Rate          int8
	Progress      float32
}

func (*PacketProgressBar) Read

func (p *PacketProgressBar) Read(data []byte) error

func (*PacketProgressBar) Write

func (p *PacketProgressBar) Write(w io.Writer) error

type PacketRestock

type PacketRestock struct {
	PacketID uint8
	PlayerID uint8
}

type PacketSetColor

type PacketSetColor struct {
	PacketID uint8
	PlayerID uint8
	Color    Color3b
}

type PacketSetHP

type PacketSetHP struct {
	PacketID uint8
	HP       uint8
	Type     HurtType
	SourceX  float32
	SourceY  float32
	SourceZ  float32
}

type PacketSetTool

type PacketSetTool struct {
	PacketID uint8
	PlayerID uint8
	Tool     ItemType
}

type PacketShortPlayerData

type PacketShortPlayerData struct {
	PacketID uint8
	PlayerID uint8
	Team     uint8
	Weapon   WeaponType
}

type PacketStateData

type PacketStateData struct {
	PacketID   uint8
	PlayerID   uint8
	FogColor   Color3b
	Team1Color Color3b
	Team2Color Color3b
	Team1Name  [TeamNameLen]byte
	Team2Name  [TeamNameLen]byte
	Gamemode   GamemodeType
	CTFState   CTFStateData
	TCState    TCStateData
}

func (*PacketStateData) Write

func (p *PacketStateData) Write(w io.Writer) error

type PacketTerritoryCapture

type PacketTerritoryCapture struct {
	PacketID uint8
	PlayerID uint8
	EntityID uint8
	Winning  uint8
	State    uint8
}

func (*PacketTerritoryCapture) Read

func (p *PacketTerritoryCapture) Read(data []byte) error

func (*PacketTerritoryCapture) Write

func (p *PacketTerritoryCapture) Write(w io.Writer) error

type PacketType

type PacketType uint8
const (
	PacketTypePositionData     PacketType = 0
	PacketTypeOrientationData  PacketType = 1
	PacketTypeWorldUpdate      PacketType = 2
	PacketTypeInputData        PacketType = 3
	PacketTypeWeaponInput      PacketType = 4
	PacketTypeHit              PacketType = 5
	PacketTypeSetHP            PacketType = 5
	PacketTypeGrenade          PacketType = 6
	PacketTypeSetTool          PacketType = 7
	PacketTypeSetColor         PacketType = 8
	PacketTypeExistingPlayer   PacketType = 9
	PacketTypeShortPlayerData  PacketType = 10
	PacketTypeMoveObject       PacketType = 11
	PacketTypeCreatePlayer     PacketType = 12
	PacketTypeBlockAction      PacketType = 13
	PacketTypeBlockLine        PacketType = 14
	PacketTypeStateData        PacketType = 15
	PacketTypeKillAction       PacketType = 16
	PacketTypeChatMessage      PacketType = 17
	PacketTypeMapStart         PacketType = 18
	PacketTypeMapChunk         PacketType = 19
	PacketTypePlayerLeft       PacketType = 20
	PacketTypeTerritoryCapture PacketType = 21
	PacketTypeProgressBar      PacketType = 22
	PacketTypeIntelCapture     PacketType = 23
	PacketTypeIntelPickup      PacketType = 24
	PacketTypeIntelDrop        PacketType = 25
	PacketTypeRestock          PacketType = 26
	PacketTypeFogColor         PacketType = 27
	PacketTypeWeaponReload     PacketType = 28
	PacketTypeChangeTeam       PacketType = 29
	PacketTypeChangeWeapon     PacketType = 30

	PacketTypeHandShakeInit    PacketType = 31
	PacketTypeHandShakeReturn  PacketType = 32
	PacketTypeVersionRequest   PacketType = 33
	PacketTypeVersionResponse  PacketType = 34
	PacketTypeExtensionInfo    PacketType = 60
	PacketTypePlayerProperties PacketType = 64
)

func ReadPacketType

func ReadPacketType(data []byte) (PacketType, error)

type PacketVersionRequest

type PacketVersionRequest struct {
	PacketID uint8
}

func (*PacketVersionRequest) Write

func (p *PacketVersionRequest) Write(w io.Writer) error

type PacketVersionResponse

type PacketVersionResponse struct {
	PacketID         uint8
	ClientIdentifier byte
	VersionMajor     int8
	VersionMinor     int8
	VersionRevision  int8
	OSInfoRaw        []byte
	OSInfo           string
}

func (*PacketVersionResponse) Read

func (p *PacketVersionResponse) Read(data []byte) error

type PacketWeaponInput

type PacketWeaponInput struct {
	PacketID    uint8
	PlayerID    uint8
	WeaponInput WeaponInput
}

type PacketWeaponReload

type PacketWeaponReload struct {
	PacketID     uint8
	PlayerID     uint8
	MagazineAmmo uint8
	ReserveAmmo  uint8
}

type PacketWorldUpdate

type PacketWorldUpdate struct {
	PacketID uint8
	Players  [MaxPlayers]PlayerPositionData
}

func (*PacketWorldUpdate) Read

func (p *PacketWorldUpdate) Read(r io.Reader) error

func (*PacketWorldUpdate) Write

func (p *PacketWorldUpdate) Write(w io.Writer) error

type PlayerPositionData

type PlayerPositionData struct {
	X, Y, Z    float32
	OX, OY, OZ float32
}

type TCStateData

type TCStateData struct {
	TerritoryCount uint8
	Territories    [16]Territory
}

type Territory

type Territory struct {
	X, Y, Z float32
	Team    uint8
}

type Vector3f

type Vector3f struct {
	X, Y, Z float32
}

type Vector3i

type Vector3i struct {
	X, Y, Z int32
}

type WeaponInput

type WeaponInput uint8
const (
	WeaponInputPrimary   WeaponInput = 1 << 0
	WeaponInputSecondary WeaponInput = 1 << 1
)

type WeaponType

type WeaponType uint8
const (
	WeaponTypeRifle   WeaponType = 0
	WeaponTypeSMG     WeaponType = 1
	WeaponTypeShotgun WeaponType = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL