package main import ( "bytes" "encoding/gob" ) const ( AdminPacketAdminJoin uint8 = 0 AdminPacketAdminQuit AdminPacketAdminUpdateFrequency AdminPacketAdminPoll AdminPacketAdminChat AdminPacketAdminRCon AdminPacketAdminGamescript AdminPacketAdminPing AdminPacketServerFull = 100 AdminPacketServerBanned AdminPacketServerError AdminPacketServerProtocol AdminPacketServerWelcome AdminPacketServerNewgame AdminPacketServerShutdown AdminPacketServerDate AdminPacketServerClientJoin AdminPacketServerClientInfo AdminPacketServerClientUpdate AdminPacketServerClientQuit AdminPacketServerClientError AdminPacketServerCompanyNew AdminPacketServerCompanyInfo AdminPacketServerCompanyUpdate AdminPacketServerCompanyRemove AdminPacketServerCompanyEconomy AdminPacketServerCompanyStats AdminPacketServerChat AdminPacketServerRCon AdminPacketServerConsole AdminPacketServerCmdNames AdminPacketServerCmdLogging AdminPacketServerGamescript AdminPacketServerRConEnd AdminPacketServerPong InvalidAdminPacket = 0xFF ) type Packet struct { PLength uint16 PType uint8 } type PacketAdminJoin struct { Packet Password string AppName string AppVersion string } func (p *PacketAdminJoin) Bytes() []byte { buf := new(bytes.Buffer) enc := gob.NewEncoder(*buf) p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 3) err := enc.Encode(p) logErrorDebug(err, "enc.Encode") return buf.Bytes() }