feat(config): 添加超时空地图配置和时间地图查询功能 新增IsTimeSpace字段用于标识地图是否为超时空地图, 添加TimeMap API接口支持查询超时空地图配置 perf(socket): 优化XORDecryptU解密函数减少内存分配 基于bytebufferpool实现缓冲区池化,大幅降低高频调用下的 内存分配和GC压力,提升性能表现 refactor(utils): 优化packVal序列化函数提升性能和稳定性 减少反射开销,优化内存拷贝操作,改进错误处理机制, 替换panic为error返回,增强代码健壮性 docs(readme): 添加新的pprof性能分析地址配置 ```
This commit is contained in:
@@ -35,7 +35,10 @@ func (h Controller) EggGamePlay(data1 *egg.C2S_EGG_GAME_PLAY, c *player.Player)
|
||||
if grand.Meet(int(data1.EggNum), 100) {
|
||||
r := service.NewPetRewardService().GetEgg()
|
||||
newPet := model.GenPetInfo(int(r.MonID), int(r.DV), int(r.Nature), int(r.Effect), int(r.Lv), nil, 0)
|
||||
newPet.RandShiny()
|
||||
if grand.Meet(1, 500) {
|
||||
newPet.RandomByWeightShiny()
|
||||
}
|
||||
|
||||
c.Service.Pet.PetAdd(newPet)
|
||||
|
||||
result.HadTime = newPet.CatchTime
|
||||
|
||||
@@ -116,8 +116,9 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe
|
||||
}
|
||||
if bc.BossCatchable == 1 {
|
||||
canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
|
||||
|
||||
monsterInfo.PetList[0].RandShiny()
|
||||
if grand.Meet(1, 500) {
|
||||
monsterInfo.PetList[0].RandomByWeightShiny()
|
||||
}
|
||||
|
||||
}
|
||||
monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName
|
||||
@@ -178,7 +179,9 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
refPet.ShinyInfo, -1)
|
||||
monster.CatchMap = p.Info.MapID //设置当前地图
|
||||
if refPet.Ext != 0 {
|
||||
monster.RandShiny()
|
||||
if grand.Meet(1, 500) {
|
||||
monster.RandomByWeightShiny()
|
||||
}
|
||||
}
|
||||
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
|
||||
@@ -81,10 +81,10 @@ func (p *Player) GenMonster() {
|
||||
|
||||
}
|
||||
if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色
|
||||
p.OgreInfo.Data[i].RandomByWeightShiny()
|
||||
p.OgreInfo.Data[i].FixSHiny()
|
||||
}
|
||||
if xmlres.PetMAP[int(p.OgreInfo.Data[i].ID)].CatchRate != 0 {
|
||||
p.OgreInfo.Data[i].RandSHiny()
|
||||
p.OgreInfo.Data[i].RandomByWeightShiny()
|
||||
}
|
||||
if ok && len(mapinfo.DropItemIds) > 0 {
|
||||
|
||||
|
||||
@@ -38,23 +38,11 @@ type OgrePetInfo struct {
|
||||
Ext uint32 `struc:"skip"` //是否变尼尔尼奥
|
||||
}
|
||||
|
||||
func (o *OgrePetInfo) RandSHiny() {
|
||||
var co *model.ColorfulSkin
|
||||
if o.Ext == 0 {
|
||||
|
||||
co = config.NewShinyService().RandShiny(o.ID)
|
||||
}
|
||||
|
||||
if co != nil && len(o.ShinyInfo) == 0 {
|
||||
o.ShinyInfo = append(o.ShinyInfo, co.Color)
|
||||
}
|
||||
|
||||
}
|
||||
func (o *OgrePetInfo) FixSHiny() {
|
||||
var co *model.ColorfulSkin
|
||||
if o.Ext == 0 {
|
||||
|
||||
co = config.NewShinyService().FixShiny(o.ID)
|
||||
co = config.NewShinyService().RandShiny(o.ID)
|
||||
}
|
||||
|
||||
if co != nil && len(o.ShinyInfo) == 0 {
|
||||
|
||||
@@ -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