2025-08-16 03:36:13 +00:00
|
|
|
package space
|
|
|
|
|
|
2026-04-02 22:38:02 +08:00
|
|
|
import "sync"
|
|
|
|
|
|
2025-08-16 03:36:13 +00:00
|
|
|
// MapHotInfo 表示地图热度信息
|
|
|
|
|
type MapHotInfo struct {
|
2025-11-16 11:56:57 +08:00
|
|
|
MapID uint32 `json:"mapId"` // 地图ID
|
|
|
|
|
Count int32 `struc:"uint32" json:"count"` // 地图里的人数
|
2025-08-16 03:36:13 +00:00
|
|
|
}
|
2026-03-01 10:44:31 +08:00
|
|
|
type MapTip struct {
|
2026-04-02 22:38:02 +08:00
|
|
|
mu sync.RWMutex
|
2026-03-01 10:44:31 +08:00
|
|
|
Count int `struc:"uint32" json:"count"` // 地图里的人数
|
|
|
|
|
TipInfoS map[uint32]*TipInfo `json:"tipInfoS"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type TipInfo struct {
|
|
|
|
|
Talk []uint32 `json:"talk"` //矿物
|
|
|
|
|
Boss []uint32 `json:"boss"` //boss
|
|
|
|
|
Pet []uint32 `json:"pet"` //宠物
|
|
|
|
|
Diao []uint32 `json:"diao"` //掉落
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-02 22:38:02 +08:00
|
|
|
func (m *MapTip) ChangeCount(delta int) int {
|
|
|
|
|
m.mu.Lock()
|
|
|
|
|
defer m.mu.Unlock()
|
2026-03-01 10:44:31 +08:00
|
|
|
|
2026-04-02 22:38:02 +08:00
|
|
|
if delta != 0 {
|
|
|
|
|
m.Count += delta
|
|
|
|
|
if m.Count < 0 {
|
|
|
|
|
m.Count = 0
|
2026-03-01 10:44:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m.Count
|
|
|
|
|
}
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2026-04-02 22:38:02 +08:00
|
|
|
func (m *MapTip) CountValue() int {
|
|
|
|
|
m.mu.RLock()
|
|
|
|
|
defer m.mu.RUnlock()
|
|
|
|
|
|
|
|
|
|
return m.Count
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-01 10:44:31 +08:00
|
|
|
var maphot = make(map[uint32]*MapTip, 0)
|
2025-11-16 11:56:57 +08:00
|
|
|
|
2025-08-16 03:36:13 +00:00
|
|
|
func GetMapHot() []MapHotInfo {
|
2025-11-16 11:56:57 +08:00
|
|
|
ret := make([]MapHotInfo, 0)
|
2025-11-25 21:10:52 +08:00
|
|
|
for k, v := range maphot {
|
2025-11-16 11:56:57 +08:00
|
|
|
ret = append(ret, MapHotInfo{
|
2025-11-25 21:10:52 +08:00
|
|
|
MapID: k,
|
2026-04-02 22:38:02 +08:00
|
|
|
Count: int32(v.CountValue()),
|
2025-11-16 11:56:57 +08:00
|
|
|
})
|
|
|
|
|
|
2025-11-25 21:10:52 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
return ret
|
|
|
|
|
// result1, _, _ := requestGroup.Do("map_hot", func() (interface{}, error) {
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// tt := make(map[uint32]uint32)
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// for _, v := range xmlres.MapConfig.Maps {
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// t1, ok := tt[uint32(v.Super)]
|
|
|
|
|
// if ok {
|
|
|
|
|
// tt[uint32(v.Super)] = uint32(int(t1) + GetSpace(uint32(v.ID)).User.Count())
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// } else {
|
|
|
|
|
// tt[uint32(v.Super)] = uint32(GetSpace(uint32(v.ID)).User.Count())
|
|
|
|
|
// }
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// }
|
|
|
|
|
// var result = make([]MapHotInfo, 0)
|
|
|
|
|
// for k, v := range tt {
|
2025-08-17 21:55:15 +08:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// result = append(result, MapHotInfo{
|
|
|
|
|
// MapID: uint32(k),
|
|
|
|
|
// Count: uint32(v),
|
|
|
|
|
// })
|
2025-08-16 03:36:13 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
// }
|
|
|
|
|
// return result, nil
|
|
|
|
|
// })
|
2025-08-28 23:23:24 +00:00
|
|
|
|
2025-08-16 03:36:13 +00:00
|
|
|
}
|