2020-06-14 16:27:57 +02:00
|
|
|
package main
|
|
|
|
|
2020-06-14 16:45:07 +02:00
|
|
|
import (
|
|
|
|
"bytes"
|
2020-06-14 17:13:42 +02:00
|
|
|
"encoding/gob"
|
2020-06-14 16:45:07 +02:00
|
|
|
)
|
2020-06-14 16:27:57 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
)
|
2020-06-14 16:45:07 +02:00
|
|
|
|
|
|
|
type Packet struct {
|
|
|
|
PLength uint16
|
|
|
|
PType uint8
|
|
|
|
}
|
|
|
|
|
|
|
|
type PacketAdminJoin struct {
|
|
|
|
Packet
|
2020-06-14 17:12:58 +02:00
|
|
|
Password string
|
|
|
|
AppName string
|
|
|
|
AppVersion string
|
2020-06-14 16:45:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PacketAdminJoin) Bytes() []byte {
|
|
|
|
buf := new(bytes.Buffer)
|
2020-06-14 17:16:26 +02:00
|
|
|
enc := gob.NewEncoder(buf)
|
2020-06-14 17:12:58 +02:00
|
|
|
|
|
|
|
p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 3)
|
|
|
|
err := enc.Encode(p)
|
|
|
|
logErrorDebug(err, "enc.Encode")
|
|
|
|
|
2020-06-14 16:45:07 +02:00
|
|
|
return buf.Bytes()
|
|
|
|
}
|