mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
优化
This commit is contained in:
@@ -124,12 +124,12 @@ func NewHandle(messageQueue *mq.MessageQueue) (r *Handle) {
|
|||||||
r = new(Handle)
|
r = new(Handle)
|
||||||
r.messageQueue = messageQueue
|
r.messageQueue = messageQueue
|
||||||
r.playerAcCtxMap = make(map[uint32]*AnticheatContext)
|
r.playerAcCtxMap = make(map[uint32]*AnticheatContext)
|
||||||
r.run()
|
go r.run()
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) run() {
|
func (h *Handle) run() {
|
||||||
go func() {
|
logger.Info("start handle")
|
||||||
for {
|
for {
|
||||||
netMsg := <-h.messageQueue.GetNetMsg()
|
netMsg := <-h.messageQueue.GetNetMsg()
|
||||||
switch netMsg.MsgType {
|
switch netMsg.MsgType {
|
||||||
@@ -151,6 +151,7 @@ func (h *Handle) run() {
|
|||||||
serverMsg := netMsg.ServerMsg
|
serverMsg := netMsg.ServerMsg
|
||||||
switch netMsg.EventId {
|
switch netMsg.EventId {
|
||||||
case mq.ServerUserOnlineStateChangeNotify:
|
case mq.ServerUserOnlineStateChangeNotify:
|
||||||
|
logger.Info("player online state change, state: %v, uid: %v", serverMsg.IsOnline, serverMsg.UserId)
|
||||||
if serverMsg.IsOnline {
|
if serverMsg.IsOnline {
|
||||||
h.AddPlayerAcCtx(serverMsg.UserId)
|
h.AddPlayerAcCtx(serverMsg.UserId)
|
||||||
} else {
|
} else {
|
||||||
@@ -159,7 +160,6 @@ func (h *Handle) run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) CombatInvocationsNotify(userId uint32, gateAppId string, payloadMsg pb.Message) {
|
func (h *Handle) CombatInvocationsNotify(userId uint32, gateAppId string, payloadMsg pb.Message) {
|
||||||
@@ -170,12 +170,13 @@ func (h *Handle) CombatInvocationsNotify(userId uint32, gateAppId string, payloa
|
|||||||
entityMoveInfo := new(proto.EntityMoveInfo)
|
entityMoveInfo := new(proto.EntityMoveInfo)
|
||||||
err := pb.Unmarshal(entry.CombatData, entityMoveInfo)
|
err := pb.Unmarshal(entry.CombatData, entityMoveInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error("parse EntityMoveInfo error: %v, uid: %v", err, userId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if GetEntityType(entityMoveInfo.EntityId) != constant.ENTITY_TYPE_AVATAR {
|
if GetEntityType(entityMoveInfo.EntityId) != constant.ENTITY_TYPE_AVATAR {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entityMoveInfo.MotionInfo.Pos != nil {
|
if entityMoveInfo.MotionInfo.Pos == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 玩家超速移动检测
|
// 玩家超速移动检测
|
||||||
@@ -209,6 +210,7 @@ func (h *Handle) ToTheMoonEnterSceneReq(userId uint32, gateAppId string, payload
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.sceneId = req.SceneId
|
ctx.sceneId = req.SceneId
|
||||||
|
logger.Info("player enter scene: %v, uid: %v", req.SceneId, userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetEntityType(entityId uint32) int {
|
func GetEntityType(entityId uint32) int {
|
||||||
|
|||||||
Reference in New Issue
Block a user