``` refactor(socket): 重构客户端数据处理逻辑,优化玩家信息校验和包处理流程

This commit is contained in:
1
2025-10-30 01:37:53 +00:00
parent bb48f01e94
commit ac75275dff
6 changed files with 78 additions and 78 deletions

View File

@@ -53,8 +53,18 @@ func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Play
result1 := maps.NewOutInfo()
copier.CopyWithOption(result1, player.GetInfo(), copier.Option{DeepCopy: true})
result.Player = append(result.Player, *result1)
result.Player=LastFourElements(result.Player)
})
c.Canmon = true //可以刷怪
return
}
func LastFourElements[T any](s []T) []T {
n := len(s)
if n <= 30 {
// 切片长度小于等于4时返回整个切片
return s
}
// 切片长度大于4时返回最后4个元素从n-4索引到末尾
return s[n-4:]
}