修复未在队伍角色无法更换时装的问题

顺便给获取scene的都判断了下nil
This commit is contained in:
UnKownOwO
2023-02-15 19:39:44 +08:00
parent 2e2159f309
commit 76b417f3f4
11 changed files with 136 additions and 7 deletions

View File

@@ -81,6 +81,10 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
player.SceneJump = jumpScene
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
oldScene := world.GetSceneById(oldSceneId)
if oldScene == nil {
logger.Error("old scene is nil, sceneId: %v", oldSceneId)
return
}
activeAvatarId := world.GetPlayerActiveAvatarId(player)
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_REMOVE, []uint32{world.GetPlayerWorldAvatarEntityId(player, activeAvatarId)})
if jumpScene {
@@ -90,6 +94,10 @@ func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, s
oldScene.RemovePlayer(player)
player.SceneId = newSceneId
newScene := world.GetSceneById(newSceneId)
if newScene == nil {
logger.Error("new scene is nil, sceneId: %v", newSceneId)
return
}
newScene.AddPlayer(player)
}
player.SceneLoadState = model.SceneNone