Fix chat messages not arriving at the MT server
parent
5a4e6fb740
commit
2b8d7ed330
10
chat.go
10
chat.go
|
@ -56,11 +56,11 @@ func RegisterOnServerChatMessage(function func(*Conn, string) bool) {
|
|||
onServerChatMsg = append(onServerChatMsg, function)
|
||||
}
|
||||
|
||||
func processChatMessage(c *Conn, pkt rudp.Pkt) bool {
|
||||
r := ByteReader(pkt)
|
||||
func processChatMessage(c *Conn, r *bytes.Reader) bool {
|
||||
r.Seek(2, io.SeekCurrent)
|
||||
|
||||
wstr := make([]byte, r.Len()-4)
|
||||
r.ReadAt(wstr, 4)
|
||||
wstr := make([]byte, r.Len())
|
||||
r.Read(wstr)
|
||||
|
||||
s := string(narrow(wstr))
|
||||
if strings.HasPrefix(s, ChatCommandPrefix) {
|
||||
|
@ -68,6 +68,8 @@ func processChatMessage(c *Conn, pkt rudp.Pkt) bool {
|
|||
s = strings.Replace(s, ChatCommandPrefix, "", 1)
|
||||
params := strings.Split(s, " ")
|
||||
|
||||
log.Print(c.Username(), " issued command: ", s)
|
||||
|
||||
// Priv check
|
||||
allow, err := c.CheckPrivs(chatCommands[params[0]].privs)
|
||||
if err != nil {
|
||||
|
|
|
@ -317,7 +317,7 @@ func processPktCommand(src, dst *Conn, pkt *rudp.Pkt) bool {
|
|||
} else {
|
||||
switch cmd := binary.BigEndian.Uint16(cmdBytes); cmd {
|
||||
case ToServerChatMessage:
|
||||
return processChatMessage(src, *pkt)
|
||||
return processChatMessage(src, r)
|
||||
case ToServerFirstSRP:
|
||||
if src.sudoMode {
|
||||
src.sudoMode = false
|
||||
|
|
|
@ -128,7 +128,7 @@ func initCurses(l *Logger) {
|
|||
consoleInput = []rune{}
|
||||
|
||||
if chatCommands[params[0]].function == nil {
|
||||
log.Print("Unknown command " + params[0] + ".")
|
||||
log.Print("Unknown command ", params[0])
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue