判空&&调试日志
This commit is contained in:
1 parent
389210b12b
commit
bd12f6a8b7
8 files changed
+53
-8
No files matched your search
@@ -454,6 +454,10 @@ func (g *Game) SendToSceneACV(scene *Scene, cmdId uint16, seq uint32, msg pb.Mes
|
||||
otherWorldAvatarMap := aiWorldAoi.GetObjectListByPos(float32(SELF.Pos.X), float32(SELF.Pos.Y), float32(SELF.Pos.Z))
|
||||
for uid := range otherWorldAvatarMap {
|
||||
player := USER_MANAGER.GetOnlineUser(uint32(uid))
|
||||
if player == nil {
|
||||
logger.Error("player not exist, uid: %v, stack: %v", uid, logger.Stack())
|
||||
continue
|
||||
}
|
||||
if aecUid == player.PlayerId {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -586,3 +586,20 @@ func (g *GMCmd) ShowAvatarCollider(v bool) {
|
||||
engine := world.GetBulletPhysicsEngine()
|
||||
engine.ShowAvatarCollider()
|
||||
}
|
||||
|
||||
func (g *GMCmd) AiWorldAoiDebug(v bool) {
|
||||
aiWorld := WORLD_MANAGER.GetAiWorld()
|
||||
if aiWorld == nil {
|
||||
return
|
||||
}
|
||||
aiWorldAoi := aiWorld.GetAiWorldAoi()
|
||||
gridMap := aiWorldAoi.Debug()
|
||||
for _, grid := range gridMap {
|
||||
logger.Debug("================================================== GRID gid:%v ==================================================", grid.GetGid())
|
||||
objectMap := grid.GetObjectList()
|
||||
for objectId, object := range objectMap {
|
||||
wa := object.(*WorldAvatar)
|
||||
logger.Debug("uid: %v, wa.uid: %v, wa.avatarId: %v, wa.entityId: %v", objectId, wa.uid, wa.avatarId, wa.avatarEntityId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,7 +431,10 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
|
||||
// 老格子移除玩家
|
||||
aiWorldAoi.RemoveObjectFromGrid(int64(player.PlayerId), oldGid)
|
||||
ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(oldPos.X), float32(oldPos.Y), float32(oldPos.Z))
|
||||
if !ok {
|
||||
logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos)
|
||||
}
|
||||
// 处理消失的格子
|
||||
for _, delGridId := range delGridIdList {
|
||||
// 通知自己 老格子里的其它玩家消失
|
||||
@@ -478,7 +481,10 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
||||
}
|
||||
}
|
||||
// 新格子添加玩家
|
||||
aiWorldAoi.AddObjectToGrid(int64(player.PlayerId), activeWorldAvatar, newGid)
|
||||
ok = aiWorldAoi.AddObjectToGridByPos(int64(player.PlayerId), activeWorldAvatar, float32(newPos.X), float32(newPos.Y), float32(newPos.Z))
|
||||
if !ok {
|
||||
logger.Error("ai world aoi add player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos)
|
||||
}
|
||||
}
|
||||
// 消失和出现的场景实体
|
||||
oldVisionEntityMap := g.GetVisionEntity(scene, oldPos)
|
||||
|
||||
@@ -244,15 +244,20 @@ func (g *Game) PlayerApplyEnterWorld(player *model.Player, targetUid uint32) {
|
||||
return
|
||||
}
|
||||
targetWorld := WORLD_MANAGER.GetWorldById(targetPlayer.WorldId)
|
||||
if targetWorld == nil {
|
||||
logger.Error("target world is nil, target worldId: %v, uid: %v", targetPlayer.WorldId, player.PlayerId)
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
|
||||
return
|
||||
}
|
||||
if targetWorld.GetMultiplayer() && targetWorld.GetOwner().PlayerId != targetPlayer.PlayerId {
|
||||
// 向同一世界内的非房主玩家申请时直接拒绝
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_NOT_IN_PLAYER_WORLD)
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
|
||||
return
|
||||
}
|
||||
mpSetting := targetPlayer.PropertiesMap[constant.PLAYER_PROP_PLAYER_MP_SETTING_TYPE]
|
||||
if mpSetting == 0 {
|
||||
// 房主玩家没开权限
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_SCENE_CANNOT_ENTER)
|
||||
applyFailNotify(proto.PlayerApplyEnterMpResultNotify_PLAYER_CANNOT_ENTER_MP)
|
||||
return
|
||||
} else if mpSetting == 1 {
|
||||
g.PlayerDealEnterWorld(targetPlayer, player.PlayerId, true)
|
||||
@@ -445,7 +450,10 @@ func (g *Game) WorldRemovePlayer(world *World, player *model.Player) {
|
||||
|
||||
if WORLD_MANAGER.IsAiWorld(world) {
|
||||
aiWorldAoi := world.GetAiWorldAoi()
|
||||
aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
if !ok {
|
||||
logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos)
|
||||
}
|
||||
}
|
||||
|
||||
player.WorldId = 0
|
||||
|
||||
@@ -364,7 +364,7 @@ func (g *Game) PacketQuest(player *model.Player, questId uint32) *proto.Quest {
|
||||
}
|
||||
quest := dbQuest.GetQuestById(questId)
|
||||
if quest == nil {
|
||||
logger.Error("get quest is nil, questId: %v", quest.QuestId)
|
||||
logger.Error("get quest is nil, questId: %v", questId)
|
||||
return nil
|
||||
}
|
||||
pbQuest := &proto.Quest{
|
||||
|
||||
@@ -312,7 +312,10 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||
|
||||
if WORLD_MANAGER.IsAiWorld(world) {
|
||||
aiWorldAoi := world.GetAiWorldAoi()
|
||||
aiWorldAoi.AddObjectToGridByPos(int64(player.PlayerId), activeWorldAvatar, float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
ok := aiWorldAoi.AddObjectToGridByPos(int64(player.PlayerId), activeWorldAvatar, float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
if !ok {
|
||||
logger.Error("ai world aoi add player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos)
|
||||
}
|
||||
}
|
||||
|
||||
g.AddSceneEntityNotify(player, visionType, []uint32{activeWorldAvatar.GetAvatarEntityId()}, true, false)
|
||||
|
||||
@@ -697,7 +697,10 @@ func (g *Game) TeleportPlayer(
|
||||
|
||||
if WORLD_MANAGER.IsAiWorld(world) {
|
||||
aiWorldAoi := world.GetAiWorldAoi()
|
||||
aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
ok := aiWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerId), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||
if !ok {
|
||||
logger.Error("ai world aoi remove player fail, uid: %v, pos: %+v", player.PlayerId, player.Pos)
|
||||
}
|
||||
}
|
||||
|
||||
if jumpScene {
|
||||
|
||||
@@ -269,6 +269,10 @@ func (a *AoiManager) RemoveObjectFromGridByPos(objectId int64, x, y, z float32)
|
||||
return a.RemoveObjectFromGrid(objectId, gid)
|
||||
}
|
||||
|
||||
func (a *AoiManager) Debug() map[uint32]*Grid {
|
||||
return a.gridMap
|
||||
}
|
||||
|
||||
// Grid 地图格子
|
||||
type Grid struct {
|
||||
gid uint32 // 格子id
|
||||
|
||||
Reference in new issue
Block a user