好友搜索优化

This commit is contained in:
hahwu 2025-03-27 19:09:37 +08:00
parent 4de86e2d61
commit 9e3d8e5f39

View File

@ -1411,8 +1411,19 @@ func ReqSearchPlayer(player *Player, buf []byte) error {
list = append(list, SearchPlayer)
}
// list 列表去重
l := make(map[int]*msg.ResPlayerSimple)
for _, v := range list {
if _, ok := l[int(v.Uid)]; !ok {
l[int(v.Uid)] = v
}
}
l2 := make([]*msg.ResPlayerSimple, 0)
for _, v := range l {
l2 = append(l2, v)
}
player.PushClientRes(&msg.ResSearchPlayer{
List: list,
List: l2,
})
return nil