2024-06-23 05:05:57 +00:00
|
|
|
package teeworlds7
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/messages7"
|
|
|
|
"github.com/teeworlds-go/go-teeworlds-protocol/protocol7"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (client *Client) processSystem(netMsg messages7.NetMessage, response *protocol7.Packet) bool {
|
|
|
|
switch msg := netMsg.(type) {
|
|
|
|
case *messages7.MapChange:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysMapChange, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Println("got map change")
|
|
|
|
response.Messages = append(response.Messages, &messages7.Ready{})
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.MapData:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysMapData, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("got map chunk %x\n", msg.Data)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.ServerInfo:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysServerInfo, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("connected to server with name '%s'\n", msg.Name)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.ConReady:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysConReady, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Println("connected, sending info")
|
|
|
|
info := &messages7.ClStartInfo{
|
|
|
|
Name: client.Name,
|
|
|
|
Clan: client.Clan,
|
|
|
|
Country: client.Country,
|
|
|
|
Body: "greensward",
|
|
|
|
Marking: "duodonny",
|
|
|
|
Decoration: "",
|
|
|
|
Hands: "standard",
|
|
|
|
Feet: "standard",
|
|
|
|
Eyes: "standard",
|
|
|
|
CustomColorBody: false,
|
|
|
|
CustomColorMarking: false,
|
|
|
|
CustomColorDecoration: false,
|
|
|
|
CustomColorHands: false,
|
|
|
|
CustomColorFeet: false,
|
|
|
|
CustomColorEyes: false,
|
|
|
|
ColorBody: 0,
|
|
|
|
ColorMarking: 0,
|
|
|
|
ColorDecoration: 0,
|
|
|
|
ColorHands: 0,
|
|
|
|
ColorFeet: 0,
|
|
|
|
ColorEyes: 0,
|
|
|
|
}
|
|
|
|
response.Messages = append(response.Messages, info)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.Snap:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysSnap, msg, func() {
|
|
|
|
response.Messages = append(response.Messages, &messages7.CtrlKeepAlive{})
|
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.SnapSingle:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysSnapSingle, msg, func() {
|
|
|
|
response.Messages = append(response.Messages, &messages7.CtrlKeepAlive{})
|
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.SnapEmpty:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysSnapEmpty, msg, func() {
|
|
|
|
response.Messages = append(response.Messages, &messages7.CtrlKeepAlive{})
|
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.InputTiming:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysInputTiming, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("timing time left=%d\n", msg.TimeLeft)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.RconAuthOn:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysRconAuthOn, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Println("you are now authenticated in rcon")
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.RconAuthOff:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysRconAuthOff, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Println("you are no longer authenticated in rcon")
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.RconLine:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysRconLine, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("[rcon] %s\n", msg.Line)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.RconCmdAdd:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysRconCmdAdd, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("got rcon cmd=%s %s %s\n", msg.Name, msg.Params, msg.Help)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.RconCmdRem:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.SysRconCmdRem, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
fmt.Printf("removed cmd=%s\n", msg.Name)
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
case *messages7.Unknown:
|
2024-06-25 01:22:25 +00:00
|
|
|
userMsgCallback(client.Callbacks.MsgUnknown, msg, func() {
|
2024-06-23 05:05:57 +00:00
|
|
|
// TODO: msg id of unknown messages should not be -1
|
|
|
|
fmt.Println("TODO: why is the msg id -1???")
|
|
|
|
printUnknownMessage(msg, "unknown system")
|
2024-06-25 01:22:25 +00:00
|
|
|
})
|
2024-06-23 05:05:57 +00:00
|
|
|
default:
|
|
|
|
printUnknownMessage(netMsg, "unprocessed system")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|