优化
This commit is contained in:
1 parent
12f2c96024
commit
346462b0fb
7 files changed
+45
-31
No files matched your search
@@ -561,18 +561,18 @@ func (k *KcpConnManager) closeAllKcpConn() {
|
||||
logger.Info("all conn has been force close")
|
||||
}
|
||||
|
||||
// 强制关闭指定连接
|
||||
func (k *KcpConnManager) forceCloseKcpConn(sessionId uint32, reason uint32) {
|
||||
// 关闭指定连接
|
||||
func (k *KcpConnManager) closeKcpConnBySessionId(sessionId uint32, reason uint32) {
|
||||
session := k.GetSession(sessionId)
|
||||
if session == nil {
|
||||
logger.Error("session not exist, sessionId: %v", sessionId)
|
||||
return
|
||||
}
|
||||
k.closeKcpConn(session, reason)
|
||||
logger.Info("conn has been force close, sessionId: %v", sessionId)
|
||||
logger.Info("conn has been close, sessionId: %v", sessionId)
|
||||
}
|
||||
|
||||
// 关闭指定连接
|
||||
// 关闭连接
|
||||
func (k *KcpConnManager) closeKcpConn(session *Session, enetType uint32) {
|
||||
if session.connState == ConnClose {
|
||||
return
|
||||
@@ -608,7 +608,7 @@ func (k *KcpConnManager) closeKcpConn(session *Session, enetType uint32) {
|
||||
EventId: mq.UserOfflineNotify,
|
||||
ConnCtrlMsg: connCtrlMsg,
|
||||
})
|
||||
logger.Info("send to gs user offline, SessionId: %v, UserId: %v", session.sessionId, connCtrlMsg.UserId)
|
||||
logger.Info("send to gs user offline, sessionId: %v, uid: %v", session.sessionId, connCtrlMsg.UserId)
|
||||
k.destroySessionChan <- session
|
||||
} else {
|
||||
k.messageQueue.SendToRobot(session.robotServerAppId, &mq.NetMsg{
|
||||
|
||||
+13
-21
@@ -71,16 +71,8 @@ func (k *KcpConnManager) forwardClientMsgToServerHandle(protoMsg *ProtoMsg, sess
|
||||
if session.connState != ConnActive {
|
||||
return
|
||||
}
|
||||
// 返回数据到客户端
|
||||
rsp := new(proto.PlayerForceExitRsp)
|
||||
msg := &ProtoMsg{
|
||||
SessionId: protoMsg.SessionId,
|
||||
CmdId: cmd.PlayerForceExitRsp,
|
||||
HeadMessage: k.getHeadMsg(protoMsg.HeadMessage.ClientSequenceId),
|
||||
PayloadMessage: rsp,
|
||||
}
|
||||
session.sendChan <- msg
|
||||
k.forceCloseKcpConn(protoMsg.SessionId, kcp.EnetClientClose)
|
||||
// 关闭连接
|
||||
k.closeKcpConnBySessionId(protoMsg.SessionId, kcp.EnetClientClose)
|
||||
case cmd.PlayerLoginReq:
|
||||
// GS登录包
|
||||
if session.connState != ConnWaitLogin {
|
||||
@@ -103,7 +95,7 @@ func (k *KcpConnManager) forwardClientMsgToServerHandle(protoMsg *ProtoMsg, sess
|
||||
})
|
||||
default:
|
||||
if session.connState != ConnActive {
|
||||
logger.Error("conn not active so drop packet, cmdId: %v, userId: %v, sessionId: %v",
|
||||
logger.Error("conn not active so drop packet, cmdId: %v, uid: %v, sessionId: %v",
|
||||
protoMsg.CmdId, session.userId, protoMsg.SessionId)
|
||||
return
|
||||
}
|
||||
@@ -204,7 +196,7 @@ func (k *KcpConnManager) gameMsgHandle(
|
||||
// 分发到每个连接具体的发送协程
|
||||
sessionId, exist := userIdSessionIdMap[gameMsg.UserId]
|
||||
if !exist {
|
||||
logger.Error("can not find sessionId by userId: %v, cmdId: %v", gameMsg.UserId, gameMsg.CmdId)
|
||||
logger.Error("can not find sessionId by uid: %v, cmdId: %v", gameMsg.UserId, gameMsg.CmdId)
|
||||
return
|
||||
}
|
||||
protoMsg := &ProtoMsg{
|
||||
@@ -221,11 +213,6 @@ func (k *KcpConnManager) gameMsgHandle(
|
||||
if session.connState == ConnClose {
|
||||
return
|
||||
}
|
||||
if len(session.sendChan) == SessionSendChanLen {
|
||||
logger.Error("session send chan is full, sessionId: %v", protoMsg.SessionId)
|
||||
k.forceCloseKcpConn(sessionId, kcp.EnetWaitSndMax)
|
||||
return
|
||||
}
|
||||
if protoMsg.CmdId == cmd.PlayerLoginRsp {
|
||||
rsp := protoMsg.PayloadMessage.(*proto.PlayerLoginRsp)
|
||||
if rsp.Retcode == 0 {
|
||||
@@ -243,6 +230,11 @@ func (k *KcpConnManager) gameMsgHandle(
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(session.sendChan) == SessionSendChanLen {
|
||||
logger.Error("session send chan is full, sessionId: %v", protoMsg.SessionId)
|
||||
k.closeKcpConnBySessionId(sessionId, kcp.EnetWaitSndMax)
|
||||
return
|
||||
}
|
||||
session.sendChan <- protoMsg
|
||||
}
|
||||
}
|
||||
@@ -256,10 +248,10 @@ func (k *KcpConnManager) connCtrlMsgHandle(
|
||||
case mq.KickPlayerNotify:
|
||||
sessionId, exist := userIdSessionIdMap[connCtrlMsg.KickUserId]
|
||||
if !exist {
|
||||
logger.Error("can not find sessionId by userId")
|
||||
logger.Error("can not find sessionId by uid: %v", connCtrlMsg.KickUserId)
|
||||
return
|
||||
}
|
||||
k.forceCloseKcpConn(sessionId, connCtrlMsg.KickReason)
|
||||
k.closeKcpConnBySessionId(sessionId, connCtrlMsg.KickReason)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +265,7 @@ func (k *KcpConnManager) serverMsgHandle(
|
||||
case mq.ServerUserGsChangeNotify:
|
||||
sessionId, exist := userIdSessionIdMap[serverMsg.UserId]
|
||||
if !exist {
|
||||
logger.Error("can not find sessionId by userId")
|
||||
logger.Error("can not find sessionId by uid: %v", serverMsg.UserId)
|
||||
return
|
||||
}
|
||||
session := sessionMap[sessionId]
|
||||
@@ -562,7 +554,7 @@ func (k *KcpConnManager) doGateLogin(req *proto.GetPlayerTokenReq, session *Sess
|
||||
oldSession := k.GetSessionByUserId(uid)
|
||||
if oldSession != nil {
|
||||
// 本地顶号
|
||||
k.forceCloseKcpConn(oldSession.sessionId, kcp.EnetServerRelogin)
|
||||
k.closeKcpConnBySessionId(oldSession.sessionId, kcp.EnetServerRelogin)
|
||||
} else {
|
||||
// 远程顶号
|
||||
connCtrlMsg := new(mq.ConnCtrlMsg)
|
||||
|
||||
@@ -261,7 +261,7 @@ func (c *CommandManager) JumpCommand(content *CommandContent) bool {
|
||||
})
|
||||
}
|
||||
|
||||
// 管理武器命令
|
||||
// 管理装备命令
|
||||
|
||||
func (c *CommandManager) NewEquipCommandController() *CommandController {
|
||||
return &CommandController{
|
||||
@@ -270,6 +270,7 @@ func (c *CommandManager) NewEquipCommandController() *CommandController {
|
||||
Description: "<color=#FFFFCC>{alias}</color> <color=#FFCC99>装备</color>",
|
||||
UsageList: []string{
|
||||
"{alias} add <武器ID/圣遗物ID/all> [等级] [突破] [精炼] 添加武器/圣遗物",
|
||||
"{alias} clear reliquary 清除全部圣遗物",
|
||||
},
|
||||
Perm: CommandPermNormal,
|
||||
Func: c.EquipCommand,
|
||||
@@ -330,6 +331,14 @@ func (c *CommandManager) EquipCommand(content *CommandContent) bool {
|
||||
default:
|
||||
return false
|
||||
}
|
||||
case "clear":
|
||||
switch param1 {
|
||||
case "reliquary":
|
||||
c.gmCmd.GMClearReliquary(content.AssignPlayer.PlayerId)
|
||||
content.SendSuccMessage(content.Executor, "已清除全部圣遗物,指定UID:%v。", content.AssignPlayer.PlayerId)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ func (g *GMCmd) GMClearPlayer(userId uint32) {
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
// GMClearItem 清除道具
|
||||
// GMClearItem 清除全部道具
|
||||
func (g *GMCmd) GMClearItem(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
@@ -440,7 +440,18 @@ func (g *GMCmd) GMClearItem(userId uint32) {
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
// GMClearQuest 清除任务
|
||||
// GMClearReliquary 清除全部圣遗物
|
||||
func (g *GMCmd) GMClearReliquary(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
player.DbReliquary = nil
|
||||
GAME.LogoutPlayer(userId)
|
||||
}
|
||||
|
||||
// GMClearQuest 清除全部任务
|
||||
func (g *GMCmd) GMClearQuest(userId uint32) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
|
||||
@@ -57,7 +57,7 @@ func (g *Game) ReliquaryUpgradeReq(player *model.Player, payloadMsg pb.Message)
|
||||
// TODO 暂时先瞎鸡巴强化
|
||||
reliquary.Level += 1
|
||||
reliquary.Exp += 100
|
||||
if reliquary.Level%5 == 0 {
|
||||
if reliquary.Level == 5 || reliquary.Level == 9 || reliquary.Level == 13 || reliquary.Level == 17 || reliquary.Level == 21 {
|
||||
g.AppendReliquaryProp(reliquary, 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -1176,6 +1176,7 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
||||
pos = g.GetPlayerPos(player)
|
||||
pos.X += random.GetRandomFloat64(1.0, 10.0)
|
||||
pos.Y += 1.0
|
||||
pos.Y = 0.0
|
||||
pos.Z += random.GetRandomFloat64(1.0, 10.0)
|
||||
}
|
||||
rot := new(model.Vector)
|
||||
@@ -1216,6 +1217,7 @@ func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId ui
|
||||
pos = g.GetPlayerPos(player)
|
||||
pos.X += random.GetRandomFloat64(1.0, 10.0)
|
||||
pos.Y += 1.0
|
||||
pos.Y = 0.0
|
||||
pos.Z += random.GetRandomFloat64(1.0, 10.0)
|
||||
}
|
||||
rot := new(model.Vector)
|
||||
|
||||
@@ -89,7 +89,7 @@ func (r *DbReliquary) AddReliquary(player *Player, itemId uint32, reliquaryId ui
|
||||
reliquary := &Reliquary{
|
||||
ReliquaryId: reliquaryId,
|
||||
ItemId: itemId,
|
||||
Level: 0,
|
||||
Level: 1,
|
||||
Exp: 0,
|
||||
Promote: 0,
|
||||
Lock: false,
|
||||
|
||||
Reference in new issue
Block a user