mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
tcp socket协议分割解析优化
This commit is contained in:
@@ -333,6 +333,9 @@ func (s *Scene) RemoveGroupSuite(groupId uint32, suiteId uint8) {
|
||||
s.DestroyEntity(entity.id)
|
||||
}
|
||||
delete(group.suiteMap, suiteId)
|
||||
if len(group.suiteMap) == 0 {
|
||||
delete(s.groupMap, groupId)
|
||||
}
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
|
||||
@@ -258,8 +258,25 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
||||
}
|
||||
// 旧有新没有的group即为卸载的
|
||||
if !world.GetMultiplayer() {
|
||||
// 处理多人世界不同玩家不同位置的group卸载情况
|
||||
// 单人世界直接卸载group
|
||||
g.RemoveSceneGroup(player, scene, groupConfig)
|
||||
} else {
|
||||
// 多人世界group附近没有任何玩家则卸载
|
||||
remove := true
|
||||
for _, otherPlayer := range scene.GetAllPlayer() {
|
||||
for otherPlayerGroupId := range g.GetNeighborGroup(otherPlayer.SceneId, otherPlayer.Pos) {
|
||||
if otherPlayerGroupId == groupId {
|
||||
remove = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if !remove {
|
||||
break
|
||||
}
|
||||
}
|
||||
if remove {
|
||||
g.RemoveSceneGroup(player, scene, groupConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
for groupId, groupConfig := range newNeighborGroupMap {
|
||||
|
||||
@@ -56,10 +56,27 @@ func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
||||
}
|
||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||
// 卸载旧位置附近的group
|
||||
for _, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
||||
for groupId, groupConfig := range g.GetNeighborGroup(ctx.OldSceneId, ctx.OldPos) {
|
||||
if !world.GetMultiplayer() {
|
||||
// 处理多人世界不同玩家不同位置的group卸载情况
|
||||
// 单人世界直接卸载group
|
||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||
} else {
|
||||
// 多人世界group附近没有任何玩家则卸载
|
||||
remove := true
|
||||
for _, otherPlayer := range oldScene.GetAllPlayer() {
|
||||
for otherPlayerGroupId := range g.GetNeighborGroup(otherPlayer.SceneId, otherPlayer.Pos) {
|
||||
if otherPlayerGroupId == groupId {
|
||||
remove = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if !remove {
|
||||
break
|
||||
}
|
||||
}
|
||||
if remove {
|
||||
g.RemoveSceneGroup(player, oldScene, groupConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user