osubinary

package
v0.0.0-...-212ad1a Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package osubinary provides fast binary reading and writing for Bancho packets/osu! database files. Its main advantage from bnch/osubinary is speed: this package uses github.com/thehowl/binary, which is a much faster binary encoder and does not make use of reflection.

Index

Constants

View Source
const SanityLimit = 1024 * 1024 * 5

SanityLimit is the maximum size of a packet.

Variables

This section is empty.

Functions

This section is empty.

Types

type Freemod

type Freemod struct {
	Enabled    bool
	PlayerMods [16]int32
}

Freemod specifies the settings of freemod if it's enabled in a multiplayer match.

type OsuReader

type OsuReader struct {
	binary.Reader
}

OsuReader extends binary.Reader, providing methods related to the osu! binary format.

func NewReader

func NewReader(r io.Reader) *OsuReader

NewReader creates a new reader.

func NewReaderFromBytes

func NewReaderFromBytes(b []byte) *OsuReader

NewReaderFromBytes calls NewReader automatically creating an io.Reader from a []byte

func (*OsuReader) BanchoString

func (o *OsuReader) BanchoString() string

BanchoString reads an osu!db-string from the Reader. Specifically, an osu!db string is an uleb128 int, specifying the string's length, and then the actual raw string.

func (*OsuReader) Freemod

func (o *OsuReader) Freemod() Freemod

Freemod reads the freemod settings from the reader.

func (*OsuReader) Int32Slice

func (o *OsuReader) Int32Slice() []int32

Int32Slice gets a slice of int32s, in the osu! format.

func (*OsuReader) Packet

func (o *OsuReader) Packet() (uint16, []byte, error)

Packet reads a packet from the Reader.

func (*OsuReader) Scorev2Portion

func (o *OsuReader) Scorev2Portion() Scorev2Portion

Scorev2Portion decodes a Scorev2Portion.

func (*OsuReader) SpectateFrameSlice

func (o *OsuReader) SpectateFrameSlice() []SpectateFrame

SpectateFrameSlice reads multiple frames broadcasted to spectators.

func (*OsuReader) Uint32Slice

func (o *OsuReader) Uint32Slice() []uint32

Uint32Slice gets a slice of uint32s, in the osu! format.

func (*OsuReader) Uleb128

func (o *OsuReader) Uleb128() uint64

Uleb128 reads an uleb128 int from the Reader.

type OsuWriteChain

type OsuWriteChain struct {
	binary.WriteChain
}

OsuWriteChain extends binary.WriteChain, providing methods related to the osu! binary format.

func NewWriter

func NewWriter() *OsuWriteChain

NewWriter creates a new OsuWriteChain.

func (*OsuWriteChain) BanchoString

func (o *OsuWriteChain) BanchoString(s string) *OsuWriteChain

BanchoString writes a string in the osu!db-format, as in an uleb128 int containing the length of the string and the string itself.

func (*OsuWriteChain) Bytes

func (o *OsuWriteChain) Bytes() []byte

Bytes retrieves the bytes written. This function may panic if the Writer does not satisfy the method `Bytes() []byte`.

func (*OsuWriteChain) Freemod

func (o *OsuWriteChain) Freemod(f Freemod) *OsuWriteChain

Freemod writes the freemod settings in the WriteChain.

func (*OsuWriteChain) Int32Slice

func (o *OsuWriteChain) Int32Slice(s []int32) *OsuWriteChain

Int32Slice writes a slice of int32s, in the osu! format.

func (*OsuWriteChain) Packet

func (o *OsuWriteChain) Packet(id uint16, data []byte) *OsuWriteChain

Packet writes a packet, in the standard form of

<uint16 PacketID>\x00<uint32 Length><[]byte Data>

func (*OsuWriteChain) Scorev2Portion

func (o *OsuWriteChain) Scorev2Portion(p Scorev2Portion) *OsuWriteChain

Scorev2Portion writes a Scorev2Portion. I'm not in the mood for descriptive comments today.

func (*OsuWriteChain) SpectateFrameSlice

func (o *OsuWriteChain) SpectateFrameSlice(fs []SpectateFrame) *OsuWriteChain

SpectateFrameSlice writes multiple SpectateFrames.

func (*OsuWriteChain) Uint32Slice

func (o *OsuWriteChain) Uint32Slice(s []uint32) *OsuWriteChain

Uint32Slice writes a slice of uint32s, in the osu! format.

func (*OsuWriteChain) Uleb128

func (o *OsuWriteChain) Uleb128(i uint64) *OsuWriteChain

Uleb128 writes an uleb128 int into the reader.

type Scorev2Portion

type Scorev2Portion struct {
	UsingScorev2 bool
	ComboPortion float64
	BonusPortion float64
}

Scorev2Portion is a part of a replay frame that has parts sent conditionally.

type SpectateFrame

type SpectateFrame struct {
	ButtonState byte
	MouseX      float32
	MouseY      float32
	Time        int32
}

SpectateFrame represents a single frame of a replay, or in this case, of the information sent to users through bancho.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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