- 简化 ClientData 结构体,移除不必要的方法 - 优化 Player 结构体,调整 Conn 类型 - 更新 wscodec.go 中的 Conn 结构体 - 删除未使用的 XML 相关文件和代码 - 调整 ServerEvent 和 controller 中的相关逻辑
46 lines
915 B
Go
46 lines
915 B
Go
package space
|
|
|
|
import (
|
|
"blazing/common/data/xmlres"
|
|
|
|
"golang.org/x/sync/singleflight"
|
|
)
|
|
|
|
var requestGroup singleflight.Group // SingleFlight 实例
|
|
// MapHotInfo 表示地图热度信息
|
|
type MapHotInfo struct {
|
|
MapID uint32 `json:"mapId"` // 地图ID
|
|
Count uint32 `json:"count"` // 地图里的人数
|
|
}
|
|
|
|
func GetMapHot() []MapHotInfo {
|
|
|
|
result1, _, _ := requestGroup.Do("map_hot", func() (interface{}, error) {
|
|
|
|
tt := make(map[uint32]uint32)
|
|
|
|
for _, v := range xmlres.MapConfig.Maps {
|
|
|
|
t1, ok := tt[uint32(v.Super)]
|
|
if ok {
|
|
tt[uint32(v.Super)] = uint32(int(t1) + GetSpace(uint32(v.ID)).Len())
|
|
|
|
} else {
|
|
tt[uint32(v.Super)] = uint32(GetSpace(uint32(v.ID)).Len())
|
|
}
|
|
|
|
}
|
|
var result = make([]MapHotInfo, 0)
|
|
for k, v := range tt {
|
|
|
|
result = append(result, MapHotInfo{
|
|
MapID: uint32(k),
|
|
Count: uint32(v),
|
|
})
|
|
|
|
}
|
|
return result, nil
|
|
})
|
|
return result1.([]MapHotInfo)
|
|
}
|