This commit is contained in:
shoopea 2020-06-15 10:45:18 +02:00
parent e94dc950c1
commit 456c479a41

View File

@ -117,9 +117,32 @@ func (p *PacketAdminServerWelcome) Read(b []byte) {
p.MapY = binary.LittleEndian.Uint16(bs[11:])
}
func (p *AdminPacketServerProtocol) Read(b []byte) {
r := bufio.NewReader(bytes.NewReader(b))
r.Discard(3)
c, _ = r.ReadByte()
p.ProtocolVersion = uint8(c)
c, _ = r.ReadByte()
if c > 0 {
p.FurtherData = true
} else {
p.FurtherData = false
}
bs := make([]byte, 13)
_, _ = r.Read(bs)
p.UpdatePacketType = binary.LittleEndian.Uint16(bs[0:])
p.FrequenciesAllowed = binary.LittleEndian.Uint16(bs[2:])
}
func handlePacket(p Packet, b []byte) {
switch p.PType {
case AdminPacketServerProtocol:
logInfoDebug("AdminPacketServerProtocol Raw : %v", b)
sp := AdminPacketServerProtocol{
Packet: p,
}
sp.Read(b)
logInfoDebug("AdminPacketServerProtocol :\n- ProtocolVersion: %v\n- FurtherData: %v\n- UpdatePacketType: %v\n- FrequenciesAllowed: %b", sp.ProtocolVersion, sp.FurtherData, sp.UpdatePacketType, sp.FrequenciesAllowed)
case AdminPacketServerWelcome:
logInfoDebug("AdminPacketServerWelcome Raw : %v", b)
sp := PacketAdminServerWelcome{