From bc9beea374c8745a8b7243d1b2041dcf66f7591f Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 15 Jun 2020 12:42:02 +0200 Subject: [PATCH] test --- main.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 664c2f1..9bd5c9d 100644 --- a/main.go +++ b/main.go @@ -61,9 +61,30 @@ func main() { } - logInfoDebug("Packet fully read : len : %d / type : %d", p.PLength, p.PType) + switch p.PType { + case AdminPacketServerProtocol: + sp := PacketAdminServerProtocol{ + Packet: p, + } + sp.Read(b[:p.PLength]) + logInfoDebug("AdminPacketServerProtocol :\n- ProtocolVersion: %v\n- FurtherData: %v\n- UpdatePacketType: %v\n- FrequenciesAllowed: %b", sp.ProtocolVersion, sp.FurtherData, sp.UpdatePacketType, sp.FrequenciesAllowed) + case AdminPacketServerWelcome: + sp := PacketAdminServerWelcome{ + Packet: p, + } + sp.Read(b[:p.PLength]) + logInfoDebug("AdminPacketServerWelcome :\n- ServerName: %v\n- OpenTTDVersion: %v\n- Dedicated: %v\n- MapSeed: %x\n- MapLandscape: %v\n- MapStartDate: %v\n- Size: %v x %v", sp.ServerName, sp.OpenTTDVersion, sp.Dedicated, sp.MapSeed, sp.MapLandscape, sp.MapStartDate, sp.MapX, sp.MapY) + px := PacketAdminUpdateFrequency{ + Packet: Packet{PType: AdminPacketAdminUpdateFrequency}, + UpdateType: AdminUpdateDate, + UpdateFrequency: AdminFrequencyDaily, + } + _, err = conn.Write(p.Bytes()) + default: + logInfoDebug("Packet fully read : len : %d / type : %d", p.PLength, p.PType) + } - handlePacket(p, b[:p.PLength]) + readPacket(p, b[:p.PLength]) c := make([]byte, 0xFFFF) copy(c, b[p.PLength:])