修复重连导致的新用户注册失败

This commit is contained in:
UnKownOwO
2022-12-03 18:48:34 +08:00
parent b55f52932d
commit ae61ddd3f3
3 changed files with 3 additions and 11 deletions

View File

@@ -362,10 +362,8 @@ func (f *ForwardManager) recvNetMsgFromGameServer() {
protoMsg.HeadMessage = f.getHeadMsg(netMsg.ClientSeq) protoMsg.HeadMessage = f.getHeadMsg(netMsg.ClientSeq)
protoMsg.PayloadMessage = netMsg.PayloadMessage protoMsg.PayloadMessage = netMsg.PayloadMessage
f.protoMsgInput <- protoMsg f.protoMsgInput <- protoMsg
continue
} else { } else {
logger.LOG.Error("recv unknown event from game server, event id: %v", netMsg.EventId) logger.LOG.Error("recv unknown event from game server, event id: %v", netMsg.EventId)
continue
} }
} }
} }
@@ -500,7 +498,7 @@ func (f *ForwardManager) ChangeGateOpenState(isOpen bool) bool {
return true return true
} }
// 剔除玩家下线 // 踢出玩家下线
func (f *ForwardManager) KickPlayer(info *gm.KickPlayerInfo) bool { func (f *ForwardManager) KickPlayer(info *gm.KickPlayerInfo) bool {
if info == nil { if info == nil {
return false return false

View File

@@ -1,6 +1,7 @@
package game package game
import ( import (
pb "google.golang.org/protobuf/proto"
"hk4e/gate/entity/gm" "hk4e/gate/entity/gm"
"hk4e/gate/kcp" "hk4e/gate/kcp"
"hk4e/gs/dao" "hk4e/gs/dao"
@@ -8,8 +9,6 @@ import (
"hk4e/pkg/logger" "hk4e/pkg/logger"
"hk4e/protocol/cmd" "hk4e/protocol/cmd"
"hk4e/protocol/proto" "hk4e/protocol/proto"
pb "google.golang.org/protobuf/proto"
) )
type GameManager struct { type GameManager struct {
@@ -74,11 +73,6 @@ func (g *GameManager) Stop() {
// 保存玩家数据 // 保存玩家数据
g.userManager.SaveUser() g.userManager.SaveUser()
// 踢出所有在线玩家
for userId := range g.userManager.GetAllOnlineUserList() {
g.DisconnectPlayer(userId)
}
//g.worldManager.worldStatic.SaveTerrain() //g.worldManager.worldStatic.SaveTerrain()
} }
@@ -110,6 +104,7 @@ func (g *GameManager) DisconnectPlayer(userId uint32) {
g.SendMsg(cmd.ServerDisconnectClientNotify, userId, 0, new(proto.ServerDisconnectClientNotify)) g.SendMsg(cmd.ServerDisconnectClientNotify, userId, 0, new(proto.ServerDisconnectClientNotify))
} }
// 踢出玩家
func (g *GameManager) KickPlayer(userId uint32) { func (g *GameManager) KickPlayer(userId uint32) {
info := new(gm.KickPlayerInfo) info := new(gm.KickPlayerInfo)
info.UserId = userId info.UserId = userId

View File

@@ -38,7 +38,6 @@ func (r *RouteManager) doRoute(cmdId uint16, userId uint32, clientSeq uint32, pa
player := r.gameManager.userManager.GetOnlineUser(userId) player := r.gameManager.userManager.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
r.gameManager.ReconnectPlayer(userId)
return return
} }
player.ClientSeq = clientSeq player.ClientSeq = clientSeq