This commit is contained in:
@@ -35,9 +35,7 @@ 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)
|
||||
if grand.Meet(int(data1.EggNum), 100) {
|
||||
newPet.RandShiny()
|
||||
}
|
||||
newPet.RandShiny()
|
||||
c.Service.Pet.PetAdd(newPet)
|
||||
|
||||
result.HadTime = newPet.CatchTime
|
||||
|
||||
@@ -117,11 +117,7 @@ func (Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, p *playe
|
||||
if bc.BossCatchable == 1 {
|
||||
canCapture = xmlres.PetMAP[int(monster.ID)].CatchRate
|
||||
|
||||
if grand.Meet(1, 100) {
|
||||
r := monsterInfo.PetList[0]
|
||||
r.RandShiny()
|
||||
monsterInfo.PetList[0] = r
|
||||
}
|
||||
monsterInfo.PetList[0].RandShiny()
|
||||
|
||||
}
|
||||
monsterInfo.Nick = bc.Name //xmlres.PetMAP[int(monster.ID)].DefName
|
||||
@@ -182,9 +178,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
refPet.ShinyInfo, -1)
|
||||
monster.CatchMap = p.Info.MapID //设置当前地图
|
||||
if refPet.Ext != 0 {
|
||||
if grand.Meet(2, 1000) {
|
||||
monster.RandShiny()
|
||||
}
|
||||
monster.RandShiny()
|
||||
}
|
||||
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -25,15 +26,37 @@ import (
|
||||
)
|
||||
|
||||
// PprofWeb 启动pprof性能分析web服务
|
||||
// PprofWeb 启动pprof web服务,仅重试2个端口保证监听成功
|
||||
func PprofWeb() {
|
||||
runtime.SetMutexProfileFraction(1) // (非必需)开启对锁调用的跟踪
|
||||
runtime.SetBlockProfileRate(1) // (非必需)开启对阻塞操作的跟踪
|
||||
err := http.ListenAndServe(":9909", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
// 开启pprof跟踪
|
||||
runtime.SetMutexProfileFraction(1)
|
||||
runtime.SetBlockProfileRate(1)
|
||||
|
||||
// 定义2个重试端口:主端口9909 + 备用端口9910
|
||||
ports := []int{9909, 9910}
|
||||
|
||||
// 遍历端口尝试监听
|
||||
for _, port := range ports {
|
||||
addr := ":" + strconv.Itoa(port)
|
||||
fmt.Printf("[INFO] 尝试启动pprof服务,监听端口: %d\n", port)
|
||||
|
||||
// 尝试监听并处理错误
|
||||
err := http.ListenAndServe(addr, nil)
|
||||
// 只有端口被占用等致命错误才重试下一个端口
|
||||
if err != nil {
|
||||
fmt.Printf("[WARN] 端口%d监听失败: %v\n", port, err)
|
||||
continue
|
||||
}
|
||||
// 监听成功则直接返回
|
||||
return
|
||||
}
|
||||
|
||||
// 所有端口都失败时的兜底
|
||||
errMsg := fmt.Sprintf("[FATAL] 端口9909/9910均监听失败,pprof服务启动失败")
|
||||
fmt.Println(errMsg)
|
||||
// 可选:根据业务需求决定是否panic
|
||||
// panic(errMsg)
|
||||
}
|
||||
func cleanup() {
|
||||
fmt.Println("执行优雅清理资源...")
|
||||
|
||||
@@ -75,10 +98,11 @@ func main() {
|
||||
// }
|
||||
// 解析命令行参数
|
||||
cool.Config.GameOnlineID = gcmd.GetOpt("id", "1").Uint16()
|
||||
go Start() //注入service
|
||||
if cool.Config.GameOnlineID == 2 { //只分析1服务器的
|
||||
go PprofWeb()
|
||||
}
|
||||
go Start() //注入service
|
||||
// if cool.Config.GameOnlineID == 2 { //只分析1服务器的
|
||||
// go PprofWeb()
|
||||
// }
|
||||
go PprofWeb()
|
||||
//go PprofWeb()
|
||||
go monitorMemAndQuit()
|
||||
fmt.Println("Process start, pid:", os.Getpid())
|
||||
|
||||
@@ -3,6 +3,7 @@ package player
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -25,6 +26,11 @@ func (p *Player) GenMonster() {
|
||||
if atomic.LoadUint32(&p.Canmon) == 0 { //已经进入地图或者没在战斗中,就可以刷新怪
|
||||
return
|
||||
}
|
||||
|
||||
mapinfo := service.NewMapService().GetData(p.Info.MapID)
|
||||
if mapinfo == nil {
|
||||
return
|
||||
}
|
||||
var oldnum, newNum int
|
||||
var replce []int
|
||||
p.monsters, oldnum, newNum = replaceOneNumber(p.monsters)
|
||||
@@ -40,7 +46,7 @@ func (p *Player) GenMonster() {
|
||||
mapss, ok := xmlres.MonsterMap[gconv.Int(p.Info.MapID)]
|
||||
|
||||
if ok && mapss.Monsters != nil {
|
||||
ok, _, _ := p.PlayerCaptureContext.Roll(mapss.Monsters.WildBonusProb, mapss.Monsters.WildBonusTotalProb)
|
||||
ok := grand.Meet(3, 10)
|
||||
for i, m := range mapss.Monsters.Monsters { //这里是9个
|
||||
|
||||
_, rok := lo.Find(replce, func(it int) bool {
|
||||
@@ -77,12 +83,12 @@ func (p *Player) GenMonster() {
|
||||
if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色
|
||||
p.OgreInfo.Data[i].RandomByWeightShiny()
|
||||
}
|
||||
if xmlres.PetMAP[int(p.OgreInfo.Data[i].ID)].CatchRate != 0 && grand.Meet(1, 500) {
|
||||
if xmlres.PetMAP[int(p.OgreInfo.Data[i].ID)].CatchRate != 0 {
|
||||
p.OgreInfo.Data[i].RandSHiny()
|
||||
}
|
||||
if ok {
|
||||
|
||||
p.OgreInfo.Data[i].Item = int64(mapss.Monsters.ItemBonusID)
|
||||
p.OgreInfo.Data[i].Item = int64(mapinfo.DropItemIds[grand.Intn(len(mapinfo.DropItemIds))])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (w *WsCodec) Upgrade(c gnet.Conn) (ok bool, action gnet.Action) {
|
||||
}
|
||||
tmpReader := bytes.NewReader(buf.Bytes())
|
||||
oldLen := tmpReader.Len()
|
||||
logging.Infof("do Upgrade")
|
||||
//logging.Infof("do Upgrade")
|
||||
|
||||
hs, err := ws.Upgrade(readWrite{tmpReader, c})
|
||||
skipN := oldLen - tmpReader.Len()
|
||||
|
||||
Reference in New Issue
Block a user