mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 17:02:26 +08:00
修复
This commit is contained in:
@@ -92,6 +92,9 @@ func (t *TickManager) onUserTickMinute(userId uint32, now int64) {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
return
|
||||
}
|
||||
if userId < PlayerBaseUid {
|
||||
return
|
||||
}
|
||||
if uint32(now/1000)-player.LastKeepaliveTime > 60 {
|
||||
logger.Error("remove keepalive timeout user, uid: %v", userId)
|
||||
GAME.OnUserOffline(userId, &ChangeGsInfo{
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"time"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gate/kcp"
|
||||
"hk4e/gs/model"
|
||||
"hk4e/pkg/logger"
|
||||
"hk4e/protocol/cmd"
|
||||
@@ -58,7 +57,6 @@ func (g *Game) ClientTimeNotify(userId uint32, clientTime uint32) {
|
||||
now := uint32(time.Now().Unix())
|
||||
// 客户端与服务器时间相差太过严重
|
||||
if math.Abs(float64(now-player.ClientTime)) > 60.0 {
|
||||
g.KickPlayer(player.PlayerID, kcp.EnetServerKick)
|
||||
logger.Error("abs of client time and server time above 60s, uid: %v", userId)
|
||||
}
|
||||
player.LastKeepaliveTime = now
|
||||
|
||||
@@ -30,6 +30,7 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message)
|
||||
logger.Error("player is already born, uid: %v", player.PlayerID)
|
||||
return
|
||||
}
|
||||
player.IsBorn = true
|
||||
|
||||
mainCharAvatarId := req.AvatarId
|
||||
if mainCharAvatarId != 10000005 && mainCharAvatarId != 10000007 {
|
||||
@@ -63,6 +64,14 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message)
|
||||
|
||||
g.LoginNotify(player.PlayerID, player.ClientSeq, player)
|
||||
|
||||
// 创建世界
|
||||
world := WORLD_MANAGER.CreateWorld(player)
|
||||
world.AddPlayer(player, player.SceneId)
|
||||
player.WorldId = world.GetId()
|
||||
// 进入场景
|
||||
player.SceneJump = true
|
||||
player.SceneLoadState = model.SceneNone
|
||||
|
||||
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
||||
}
|
||||
|
||||
@@ -105,29 +114,24 @@ func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, player
|
||||
|
||||
if player.IsBorn {
|
||||
g.LoginNotify(userId, clientSeq, player)
|
||||
}
|
||||
|
||||
if joinHostUserId != 0 {
|
||||
hostPlayer := USER_MANAGER.GetOnlineUser(joinHostUserId)
|
||||
if hostPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", joinHostUserId)
|
||||
if joinHostUserId != 0 {
|
||||
hostPlayer := USER_MANAGER.GetOnlineUser(joinHostUserId)
|
||||
if hostPlayer == nil {
|
||||
logger.Error("player is nil, uid: %v", joinHostUserId)
|
||||
} else {
|
||||
g.JoinOtherWorld(player, hostPlayer)
|
||||
}
|
||||
} else {
|
||||
g.JoinOtherWorld(player, hostPlayer)
|
||||
}
|
||||
} else {
|
||||
// 创建世界
|
||||
world := WORLD_MANAGER.CreateWorld(player)
|
||||
world.AddPlayer(player, player.SceneId)
|
||||
player.WorldId = world.GetId()
|
||||
// 进入场景
|
||||
player.SceneJump = true
|
||||
player.SceneLoadState = model.SceneNone
|
||||
if player.IsBorn {
|
||||
// 创建世界
|
||||
world := WORLD_MANAGER.CreateWorld(player)
|
||||
world.AddPlayer(player, player.SceneId)
|
||||
player.WorldId = world.GetId()
|
||||
// 进入场景
|
||||
player.SceneJump = true
|
||||
player.SceneLoadState = model.SceneNone
|
||||
g.SendMsg(cmd.PlayerEnterSceneNotify, userId, clientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
||||
}
|
||||
}
|
||||
|
||||
if !player.IsBorn {
|
||||
} else {
|
||||
g.SendMsg(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, new(proto.DoSetPlayerBornDataNotify))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user