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
- type Freemod
- type OsuReader
- func (o *OsuReader) BanchoString() string
- func (o *OsuReader) Freemod() Freemod
- func (o *OsuReader) Int32Slice() []int32
- func (o *OsuReader) Packet() (uint16, []byte, error)
- func (o *OsuReader) Scorev2Portion() Scorev2Portion
- func (o *OsuReader) SpectateFrameSlice() []SpectateFrame
- func (o *OsuReader) Uint32Slice() []uint32
- func (o *OsuReader) Uleb128() uint64
- type OsuWriteChain
- func (o *OsuWriteChain) BanchoString(s string) *OsuWriteChain
- func (o *OsuWriteChain) Bytes() []byte
- func (o *OsuWriteChain) Freemod(f Freemod) *OsuWriteChain
- func (o *OsuWriteChain) Int32Slice(s []int32) *OsuWriteChain
- func (o *OsuWriteChain) Packet(id uint16, data []byte) *OsuWriteChain
- func (o *OsuWriteChain) Scorev2Portion(p Scorev2Portion) *OsuWriteChain
- func (o *OsuWriteChain) SpectateFrameSlice(fs []SpectateFrame) *OsuWriteChain
- func (o *OsuWriteChain) Uint32Slice(s []uint32) *OsuWriteChain
- func (o *OsuWriteChain) Uleb128(i uint64) *OsuWriteChain
- type Scorev2Portion
- type SpectateFrame
Constants ¶
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 OsuReader ¶
OsuReader extends binary.Reader, providing methods related to the osu! binary format.
func NewReaderFromBytes ¶
NewReaderFromBytes calls NewReader automatically creating an io.Reader from a []byte
func (*OsuReader) BanchoString ¶
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) Int32Slice ¶
Int32Slice gets a slice of int32s, in the osu! format.
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 ¶
Uint32Slice gets a slice of uint32s, in the osu! format.
type OsuWriteChain ¶
type OsuWriteChain struct {
binary.WriteChain
}
OsuWriteChain extends binary.WriteChain, providing methods related to the osu! binary format.
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 ¶
Scorev2Portion is a part of a replay frame that has parts sent conditionally.