cubecode

package module
v0.0.0-...-05ee938 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: BSD-2-Clause Imports: 5 Imported by: 1

README

CubeCode

A basic Go package to parse Cube 2: Sauerbraten network messages.

This package offers easy methods to read Sauerbraten network messages with Go and does integer decompression and character translation to Unicode for you.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBufferTooShort = errors.New("cubecode: buffer too short")

Functions

func SanitizeString

func SanitizeString(s string) string

SanitizeString returns the string, cleared of sauer color codes like \f3 for red.

Types

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

Packet represents a Sauerbraten UDP packet.

func NewPacket

func NewPacket(buf []byte) *Packet

NewPacket returns a Packet using buf as the underlying buffer.

func (*Packet) HasRemaining

func (p *Packet) HasRemaining() bool

HasRemaining returns true if there are bytes remaining to be read in the packet.

func (*Packet) Len

func (p *Packet) Len() int

Len returns the number of unread bytes left in the packet.

func (*Packet) ReadByte

func (p *Packet) ReadByte() (byte, error)

ReadByte returns the next byte in the packet.

func (*Packet) ReadInt

func (p *Packet) ReadInt() (int, error)

ReadInt returns the integer value encoded in the next bytes of the packet.

func (*Packet) ReadString

func (p *Packet) ReadString() (s string, err error)

ReadString returns a string of the next bytes up to 0x00.

func (*Packet) SubPacket

func (p *Packet) SubPacket(n int) (q *Packet, err error)

SubPacket returns a part of the packet as new packet. It does not copy the underlying slice!

func (*Packet) SubPacketFromRemaining

func (p *Packet) SubPacketFromRemaining() (*Packet, error)

SubPacketFromRemaining returns a packet from the bytes remaining in p's buffer.

func (*Packet) WriteByte

func (p *Packet) WriteByte(b byte) error

func (*Packet) WriteInt

func (p *Packet) WriteInt(value int32)

WriteInt writes an int32 to the packet buffer. It grows the packet as needed.

func (*Packet) WriteString

func (p *Packet) WriteString(s string)

Jump to

Keyboard shortcuts

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