feat(item): 优化购买金币商品逻辑并完善宠物属性计算 - 购买金币商品时增加失败回滚机制,确保扣除金币与实际获得物品一致 - 使用 `CalculatePetPane` 替代 `Update` 方法以正确刷新宠物面板数据 - 精简地图热度统计逻辑,移除并发安全库依赖,改用普通 map 配合原子操作 - 移除 Space 结构体中冗余的 SuperValue 字段,直接通过 map 统计地图人数 - 更新地图配置文件中的怪物分布信息,调整部分怪物等级和数量配置 ```
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package space
|
|
|
|
import (
|
|
"golang.org/x/sync/singleflight"
|
|
)
|
|
|
|
var requestGroup singleflight.Group // SingleFlight 实例
|
|
// MapHotInfo 表示地图热度信息
|
|
type MapHotInfo struct {
|
|
MapID uint32 `json:"mapId"` // 地图ID
|
|
Count int32 `struc:"uint32" json:"count"` // 地图里的人数
|
|
}
|
|
|
|
var maphot = make(map[uint32]*int32, 0)
|
|
|
|
func GetMapHot() []MapHotInfo {
|
|
ret := make([]MapHotInfo, 0)
|
|
for k, v := range maphot {
|
|
ret = append(ret, MapHotInfo{
|
|
MapID: k,
|
|
Count: *v,
|
|
})
|
|
|
|
}
|
|
|
|
return ret
|
|
// 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)).User.Count())
|
|
|
|
// } else {
|
|
// tt[uint32(v.Super)] = uint32(GetSpace(uint32(v.ID)).User.Count())
|
|
// }
|
|
|
|
// }
|
|
// var result = make([]MapHotInfo, 0)
|
|
// for k, v := range tt {
|
|
|
|
// result = append(result, MapHotInfo{
|
|
// MapID: uint32(k),
|
|
// Count: uint32(v),
|
|
// })
|
|
|
|
// }
|
|
// return result, nil
|
|
// })
|
|
|
|
}
|