优化玩家管理器

This commit is contained in:
huangxiaolei
2022-12-10 22:42:20 +08:00
parent edd8a98f92
commit d17f687d74
12 changed files with 183 additions and 135 deletions

View File

@@ -11,6 +11,7 @@ import (
"hk4e/pkg/reflection"
"hk4e/protocol/cmd"
"hk4e/protocol/proto"
"time"
)
var GAME_MANAGER *GameManager = nil
@@ -69,8 +70,10 @@ func (g *GameManager) Start() {
func (g *GameManager) Stop() {
// 保存玩家数据
USER_MANAGER.SaveUser()
LOCAL_EVENT_MANAGER.localEventChan <- &LocalEvent{
EventId: RunUserCopyAndSave,
}
time.Sleep(time.Second * 5)
//g.worldManager.worldStatic.SaveTerrain()
}
@@ -115,6 +118,18 @@ func (g *GameManager) CommonRetError(cmdId uint16, player *model.Player, rsp pb.
g.SendMsg(cmdId, player.PlayerID, player.ClientSeq, rsp)
}
// CommonRetSucc 通用返回成功
func (g *GameManager) CommonRetSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
if rsp == nil {
return
}
ok := reflection.SetStructFieldValue(rsp, "Retcode", int32(proto.Retcode_RET_SUCC))
if !ok {
return
}
g.SendMsg(cmdId, player.PlayerID, player.ClientSeq, rsp)
}
func (g *GameManager) ReconnectPlayer(userId uint32) {
g.SendMsg(cmd.ClientReconnectNotify, userId, 0, new(proto.ClientReconnectNotify))
}