Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.5.0 fix & chatcommands in own thread #93

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 22 additions & 16 deletions process.go
Expand Up @@ -13,6 +13,15 @@ import (
func (cc *ClientConn) process(pkt mt.Pkt) {
srv := cc.server()

forward := func(pkt mt.Pkt) {
if srv == nil {
cc.Log("->", "no server")
return
}

srv.Send(pkt)
}

switch cmd := pkt.Cmd.(type) {
case *mt.ToSrvNil:
return
Expand All @@ -23,8 +32,8 @@ func (cc *ClientConn) process(pkt mt.Pkt) {
}

cc.setState(csInit)
if cmd.SerializeVer != latestSerializeVer {
cc.Log("<-", "invalid serializeVer")
if cmd.SerializeVer <= latestSerializeVer {
cc.Log("<-", "invalid serializeVer", cmd.SerializeVer)
ack, _ := cc.SendCmd(&mt.ToCltKick{Reason: mt.UnsupportedVer})

select {
Expand All @@ -36,8 +45,8 @@ func (cc *ClientConn) process(pkt mt.Pkt) {
return
}

if cmd.MaxProtoVer < latestProtoVer {
cc.Log("<-", "invalid protoVer")
if cmd.MaxProtoVer <= latestProtoVer {
cc.Log("<-", "invalid protoVer", cmd.MaxProtoVer)
ack, _ := cc.SendCmd(&mt.ToCltKick{Reason: mt.UnsupportedVer})

select {
Expand Down Expand Up @@ -432,22 +441,19 @@ func (cc *ClientConn) process(pkt mt.Pkt) {
srv.swapAOID(&cmd.Pointed.(*mt.PointedAO).ID)
}
case *mt.ToSrvChatMsg:
result, isCmd := onChatMsg(cc, cmd)
if !isCmd {
break
} else if result != "" {
cc.SendChatMsg(result)
}

return
}
go func() {
result, isCmd := onChatMsg(cc, cmd)
if !isCmd {
forward(pkt)
} else if result != "" {
cc.SendChatMsg(result)
}
}()

if srv == nil {
cc.Log("->", "no server")
return
}

srv.Send(pkt)
forward(pkt)
}

func (sc *ServerConn) process(pkt mt.Pkt) {
Expand Down
2 changes: 1 addition & 1 deletion proxy.go
Expand Up @@ -16,7 +16,7 @@ import (
const (
latestSerializeVer = 28
latestProtoVer = 39
versionString = "5.5.0-dev-83a7b48bb"
versionString = "5.4.1-dev-b2596eda3"
maxPlayerNameLen = 20
bytesPerMediaBunch = 5000
)
Expand Down