MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / VarInt

Method VarInt

protocol/net/io/encoding/reader.go:110–140  ·  view source on GitHub ↗
(value *int32)

Source from the content-addressed store, hash-verified

108}
109
110func (r Reader) VarInt(value *int32) (i int, err error) {
111 var (
112 position int32
113 currentByte byte
114 CONTINUE_BIT byte = 128
115 SEGMENT_BITS byte = 127
116
117 size int
118 )
119
120 for {
121 if err := r.Ubyte(&currentByte); err != nil {
122 return size, err
123 }
124
125 *value |= int32((currentByte & SEGMENT_BITS)) << position
126 size++
127
128 if (currentByte & CONTINUE_BIT) == 0 {
129 break
130 }
131
132 position += 7
133
134 if position >= 32 {
135 return size, fmt.Errorf("VarInt is too big")
136 }
137 }
138
139 return size, nil
140}
141
142func (r Reader) VarLong(value *int64) error {
143 var (

Callers 15

StringMethod · 0.95
BitSetMethod · 0.95
ByteArrayMethod · 0.95
ReadPacketMethod · 0.45
decodeFunction · 0.45
EncodeMethod · 0.45
DecodeMethod · 0.45
EncodeMethod · 0.45
EncodeMethod · 0.45
DecodeMethod · 0.45
EncodeMethod · 0.45
DecodeMethod · 0.45

Calls 1

UbyteMethod · 0.95

Tested by

no test coverage detected