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