feat(config): 添加超时空地图配置和时间地图查询功能 新增IsTimeSpace字段用于标识地图是否为超时空地图, 添加TimeMap API接口支持查询超时空地图配置 perf(socket): 优化XORDecryptU解密函数减少内存分配 基于bytebufferpool实现缓冲区池化,大幅降低高频调用下的 内存分配和GC压力,提升性能表现 refactor(utils): 优化packVal序列化函数提升性能和稳定性 减少反射开销,优化内存拷贝操作,改进错误处理机制, 替换panic为error返回,增强代码健壮性 docs(readme): 添加新的pprof性能分析地址配置 ```
This commit is contained in:
@@ -44,71 +44,40 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g.
|
||||
return nil
|
||||
}
|
||||
func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin {
|
||||
if !grand.Meet(1, 500) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm_enable(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret)
|
||||
var rets []model.ColorfulSkin
|
||||
var props []int
|
||||
|
||||
for _, v := range ret {
|
||||
rets = append(rets, v)
|
||||
props = append(props, int(v.ElfProbability))
|
||||
//print(v.ID)
|
||||
|
||||
id := v.ID
|
||||
|
||||
if grand.Meet(int(v.ElfProbability), 1000) {
|
||||
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("usage_count", 1)
|
||||
}
|
||||
|
||||
return &v
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
r, _ := utils.RandomByWeight(rets, props)
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("refresh_count", 1)
|
||||
}
|
||||
// for _, v := range ret {
|
||||
// //print(v.ID)
|
||||
|
||||
// id := v.ID
|
||||
|
||||
// if grand.Meet(int(v.ElfProbability), 1000) {
|
||||
|
||||
// if cool.Config.ServerInfo.IsVip == 0 {
|
||||
// m := cool.DBM(s.Model).Where("id", id)
|
||||
// m.Increment("refresh_count", 1)
|
||||
// }
|
||||
|
||||
// return &v
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
return &r
|
||||
r := model.GenerateRandomOffspringMatrix()
|
||||
var t data.GlowFilter
|
||||
var ret1 model.ColorfulSkin
|
||||
t.ColorMatrixFilter = r.Get()
|
||||
ret1.Color = t
|
||||
return &ret1
|
||||
}
|
||||
|
||||
// 强制随机
|
||||
func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm_enable(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret)
|
||||
if len(ret) == 0 {
|
||||
return nil
|
||||
}
|
||||
v := ret[grand.Intn(len(ret))]
|
||||
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", v.ID)
|
||||
m.Increment("usage_count", 1)
|
||||
}
|
||||
|
||||
return &v
|
||||
|
||||
}
|
||||
func (s *ShinyService) RandomByWeightShiny(id uint32) *model.ColorfulSkin {
|
||||
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
@@ -130,7 +99,7 @@ func (s *ShinyService) RandomByWeightShiny(id uint32) *model.ColorfulSkin {
|
||||
r, _ := utils.RandomByWeight(rets, props)
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", r.ID)
|
||||
m.Increment("usage_count", 1)
|
||||
m.Increment("refresh_count", 1)
|
||||
}
|
||||
|
||||
return &r
|
||||
|
||||
@@ -213,40 +213,19 @@ func (pet *PetInfo) Cure() {
|
||||
}
|
||||
}
|
||||
}
|
||||
func (pet *PetInfo) RandShiny() {
|
||||
|
||||
co := service.NewShinyService().RandShiny(pet.ID)
|
||||
if co != nil {
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, co.Color)
|
||||
}
|
||||
//o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get()
|
||||
//g.Dump(ttt.ShinyInfo)
|
||||
// ttt.Shiny = 0 //待确认是否刷新异色
|
||||
}
|
||||
|
||||
// 强制选色,这个是给熔炉用的
|
||||
func (pet *PetInfo) FixShiny() {
|
||||
|
||||
co := service.NewShinyService().FixShiny(pet.ID)
|
||||
if co != nil {
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, co.Color)
|
||||
} else {
|
||||
r := GenerateRandomOffspringMatrix()
|
||||
var t data.GlowFilter
|
||||
t.ColorMatrixFilter = r.Get()
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, t)
|
||||
|
||||
}
|
||||
|
||||
co := service.NewShinyService().RandShiny(pet.ID)
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, co.Color)
|
||||
}
|
||||
|
||||
// 比重融合
|
||||
func (pet *PetInfo) RandomByWeightShiny() {
|
||||
|
||||
co := service.NewShinyService().RandomByWeightShiny(pet.ID)
|
||||
if co != nil {
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, co.Color)
|
||||
}
|
||||
pet.ShinyInfo = append(pet.ShinyInfo, co.Color)
|
||||
|
||||
}
|
||||
func (pet *PetInfo) IsShiny() bool {
|
||||
|
||||
Reference in New Issue
Block a user