This commit is contained in:
aozhiwei 2024-04-15 16:32:13 +08:00
parent a1ec14faaf
commit e21483a6a3

View File

@ -33,6 +33,8 @@ type playerMgr struct {
pendingLoginHash map[string]*pendingLoginRequest
socketCloseEventHash map[f5.WspCliConn]*q5.ListHead
currReqId int64
recommendHumans []*player
lastRefreshRecommendTick int64
}
func (this *playerMgr) Init() {
@ -359,4 +361,15 @@ func (this *playerMgr) traverseHumans(cb func(*player) bool) {
}
func (this *playerMgr) GetRecommendPlayers(excludeHums map[string]int32, outHums map[string]int32, num int32) {
if len(this.accountIdHash) < 50 ||
q5.GetTickCount() - this.lastRefreshRecommendTick > 1000 * 60 {
this.recommendHumans = []*player{}
this.traverseHumans(
func (hum *player) bool {
if _, ok := excludeHums[hum.GetAccountId()]; !ok {
q5.AppendSlice(&this.recommendHumans, hum)
}
return true
})
}
}