From eea2e8777f033a11648f7b597e5340e00cbac01d Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 23 Feb 2026 15:06:45 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20to?= =?UTF-8?q?wer=5F110.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/config/model/tower_110.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config/model/tower_110.go b/modules/config/model/tower_110.go index 504e5d8bb..dc7bb9b32 100644 --- a/modules/config/model/tower_110.go +++ b/modules/config/model/tower_110.go @@ -18,7 +18,7 @@ type BaseTowerConfig struct { // ItemGift []ItemGift `orm:"with:item_id=id"` // 核心必填字段(所有塔类型通用) TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数(唯一标识每层配置)'" json:"tower_level" description:"塔层数"` - BossIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定BOSS ID数组,关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"` + BossIds []uint32 `gorm:"not null;type:jsonb;default:'[]';comment:'绑定BOSS ID数组,关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"` } // NewBaseTowerConfig 创建基础塔配置实例(所有塔类型共用) From 215ce98c22a9136ebe9d631eb7f92743b6b63e0e Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 23 Feb 2026 15:08:20 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20to?= =?UTF-8?q?wer=5F110.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/config/model/tower_110.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/config/model/tower_110.go b/modules/config/model/tower_110.go index dc7bb9b32..9509eb4fe 100644 --- a/modules/config/model/tower_110.go +++ b/modules/config/model/tower_110.go @@ -14,9 +14,7 @@ const ( // -------------------------- 核心基类:所有塔配置的通用结构 -------------------------- type BaseTowerConfig struct { *BaseConfig - Name string `gorm:"size:32;default:'';comment:'塔层名称'" json:"name" description:"塔层名称"` - // ItemGift []ItemGift `orm:"with:item_id=id"` - // 核心必填字段(所有塔类型通用) + TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数(唯一标识每层配置)'" json:"tower_level" description:"塔层数"` BossIds []uint32 `gorm:"not null;type:jsonb;default:'[]';comment:'绑定BOSS ID数组,关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"` } From 50a19b2ff9e9cf42c72a3dc254ec242ee6f7fe72 Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 23 Feb 2026 21:42:36 +0800 Subject: [PATCH 03/14] 1 --- common/socket/ServerEvent.go | 5 +---- logic/service/player/pack.go | 3 ++- modules/player/service/pet.go | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index ed3d7b227..5874a3992 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -192,10 +192,7 @@ func (s *Server) handleTCP(conn gnet.Conn) (action gnet.Action) { conn.Context().(*player.ClientData).IsCrossDomain.Do(func() { //跨域检测 handle(conn) }) - // 1. 检查最小可读长度(避免无效 Peek) - if conn.InboundBuffered() < 17 { - return gnet.None - } + // handle(c) // 先读取4字节的包长度 lenBuf, err := conn.Peek(4) diff --git a/logic/service/player/pack.go b/logic/service/player/pack.go index e69d8f3de..171208660 100644 --- a/logic/service/player/pack.go +++ b/logic/service/player/pack.go @@ -5,6 +5,7 @@ import ( "blazing/cool" "blazing/logic/service/common" "encoding/binary" + "encoding/hex" "sync" "time" @@ -152,7 +153,7 @@ func (h *ClientData) OnEvent(data common.TomeeHeader) { } if err != nil { - cool.Logger.Error(context.Background(), data.UserID, data.CMD, "解包失败,", err, data.Data) + cool.Logger.Error(context.Background(), data.UserID, data.CMD, "解包失败,", err, hex.EncodeToString(data.Data)) //fmt.Println(data.UserID, data.CMD, "解包失败,", hex.EncodeToString(data.Data)) data.Result = uint32(errorcode.ErrorCodes.ErrSystemProcessingError) playerconn.SendPack(data.Pack(nil)) diff --git a/modules/player/service/pet.go b/modules/player/service/pet.go index 9c9abf732..b992b9590 100644 --- a/modules/player/service/pet.go +++ b/modules/player/service/pet.go @@ -106,9 +106,9 @@ func (s *PetService) Pet_LEVEL_all() []model.Pet { } // 精灵真正添加后的捕捉时间才是真正的时间 -func (s *PetService) PetAdd(y *model.PetInfo) { +func (s *PetService) PetAdd(y *model.PetInfo) uint32 { if y == nil { - return + return 0 } sql := fmt.Sprintf(` UPDATE %s @@ -136,7 +136,7 @@ RETURNING max_ts; if err != nil { panic(err) } - + return y.CatchTime } // func (s *PetService) ModifyBefore(ctx context.Context, method string, param map[string]interface{}) (err error) { From b260fff8e8543682d46b883e999152b58a762eac Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 23 Feb 2026 21:50:57 +0800 Subject: [PATCH 04/14] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E4=BF=A1=E6=81=AF=E5=A4=84=E7=90=86=E5=92=8C=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除不必要的IsReg方法,简化玩家信息获取流程 调整抢先服玩家登录时间检查逻辑 --- logic/service/fight/loop.go | 2 +- modules/base/controller/admin/base_sys_user.go | 10 +++++----- modules/player/service/info.go | 9 --------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index b2ece9c2e..1d5b355c6 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -310,7 +310,7 @@ func (f *FightC) resolveRound(p1Action, p2Action action.BattleActionI) { } // handleActiveSwitchAction 处理主动切换精灵动作 -func (f *FightC) handleActiveSwitchAction(switchAction *action.ActiveSwitchAction, otherAction action.BattleActionI) { +func (f *FightC) handleActiveSwitchAction(_ *action.ActiveSwitchAction, otherAction action.BattleActionI) { if skillAction, ok := otherAction.(*action.SelectSkillAction); ok { if skillAction.SkillEntity != nil && skillAction.CD != nil { diff --git a/modules/base/controller/admin/base_sys_user.go b/modules/base/controller/admin/base_sys_user.go index fdb95897e..79e13f20b 100644 --- a/modules/base/controller/admin/base_sys_user.go +++ b/modules/base/controller/admin/base_sys_user.go @@ -61,16 +61,16 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) } res = &SessionRes{} - + t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId)) res.UserID = int(t1.ID) - playerinfo := blazing.NewUserService(uint32(t1.ID)) - if playerinfo.Info.IsReg() { + playerinfo := blazing.NewUserService(uint32(t1.ID)).Info.Person(uint32(t1.ID)) + if playerinfo != nil { res.IsReg = 1 if t1.DepartmentID == 35 { ///抢先服玩家,3天没登录衰退 - r := playerinfo.Info.Person(uint32(t1.ID)) - if r.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) { + + if playerinfo.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) { t1.DepartmentID = 1 service.NewBaseSysUserService().SetdepartmentId(uint32(t1.ID), 1) } diff --git a/modules/player/service/info.go b/modules/player/service/info.go index a2f141cc8..9b73d54e9 100644 --- a/modules/player/service/info.go +++ b/modules/player/service/info.go @@ -20,15 +20,6 @@ import ( csmap "github.com/mhmtszr/concurrent-swiss-map" ) -func (s *InfoService) IsReg() bool { - - m := s.dbm_fix(s.Model) - - record, _ := m.Exist() - - return record -} - // 是否注册,如果注册过,那么就会产生用户player信息 // 实现注册,id+昵称+颜色 From 25c9ecdad6e96d8d9034fcffbd15b3ac11341a8e Mon Sep 17 00:00:00 2001 From: xinian Date: Mon, 23 Feb 2026 22:28:40 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20ac?= =?UTF-8?q?tion.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/action.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/logic/service/fight/action.go b/logic/service/fight/action.go index 0c49f5592..a20e67826 100644 --- a/logic/service/fight/action.go +++ b/logic/service/fight/action.go @@ -78,7 +78,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { case f.actionChan <- ret: // 发送成功,可选记录日志 // log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id) - case <-time.After(time.Second * 10): + case <-time.After(time.Second * 60): // 通道满时的降级处理 cool.Logger.Printf(context.Background(), "actionChan is full, failed to send skill, userID: %d, skillID: %d", c.GetInfo().UserID, id) @@ -120,7 +120,7 @@ func (f *FightC) UseSkill(c common.PlayerI, id uint32) { case f.actionChan <- ret: // 发送成功,可选记录日志 // log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id) - case <-time.After(time.Second * 10): + case <-time.After(time.Second * 60): // 通道满时的降级处理 cool.Logger.Printf(context.Background(), "actionChan is full, failed to send skill, userID: %d, skillID: %d", c.GetInfo().UserID, id) @@ -137,7 +137,7 @@ func (f *FightC) Capture(c common.PlayerI, id uint32) { case f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: id}: // 发送成功,可选记录日志 // log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id) - case <-time.After(time.Second * 10): + case <-time.After(time.Second * 60): // 通道满时的降级处理 cool.Logger.Printf(context.Background(), "actionChan is full, failed to send Capture, userID: %d ", c.GetInfo().UserID) @@ -155,7 +155,7 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) { case f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid}: // 发送成功,可选记录日志 // log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id) - case <-time.After(time.Second * 10): + case <-time.After(time.Second * 60): // 通道满时的降级处理 cool.Logger.Printf(context.Background(), "actionChan is full, failed to send UseItem, userID: %d, skillID: %d", c.GetInfo().UserID, cacthid) From 467890a60b497b89a6ac83e3898a3c4c504cccfd Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 00:12:50 +0800 Subject: [PATCH 06/14] 1 --- logic/controller/fight_base.go | 5 +++++ logic/service/space/space.go | 36 ++++++---------------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index 6dbc1f1d2..e51589082 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -76,6 +76,11 @@ func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c * if err := h.checkFightStatus(c); err != 0 { return nil, err } + if c.GetSpace().IsTime { + if data.ItemId < 300009 { + return nil, errorcode.ErrorCodes.ErrCannotPerformAction + } + } defer c.FightC.UseItem(c, data.CatchTime, data.ItemId) return nil, -1 } diff --git a/logic/service/space/space.go b/logic/service/space/space.go index 674e774bc..01d102a67 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -33,6 +33,7 @@ type Space struct { info.MapBossInfo TimeBoss info.S2C_2022 Weather uint32 + IsTime bool //CanWeather uint32 } @@ -40,36 +41,8 @@ type Space struct { func NewSpace() *Space { ret := &Space{ - User: csmap.New[uint32, common.PlayerI]( - // set the number of map shards. the default value is 32. - csmap.WithShardCount[uint32, common.PlayerI](32), - - // // if don't set custom hasher, use the built-in maphash. - csmap.WithCustomHasher[uint32, common.PlayerI](func(key uint32) uint64 { - - return uint64(key) - }), - - // set the total capacity, every shard map has total capacity/shard count capacity. the default value is 0. - // csmap.WithSize[string, int](1000), - ), - UserInfo: csmap.New[uint32, info.SimpleInfo]( - // set the number of map shards. the default value is 32. - csmap.WithShardCount[uint32, info.SimpleInfo](32), - csmap.WithCustomHasher[uint32, info.SimpleInfo](func(key uint32) uint64 { - - return uint64(key) - }), - // // if don't set custom hasher, use the built-in maphash. - // csmap.WithCustomHasher[string, int](func(key string) uint64 { - // hash := fnv.New64a() - // hash.Write([]byte(key)) - // return hash.Sum64() - // }), - - // set the total capacity, every shard map has total capacity/shard count capacity. the default value is 0. - // csmap.WithSize[string, int](1000), - ), + User: csmap.New[uint32, common.PlayerI](), + UserInfo: csmap.New[uint32, info.SimpleInfo](), } return ret @@ -111,6 +84,9 @@ func GetSpace(id uint32) *Space { r := service.NewMapService().GetData(ret.ID) if r != nil { + if r.IsTimeSpace != 0 { + ret.IsTime = true + } if len(r.WeatherType) > 1 { // ret.CanWeather = 1 cool.Cron.CustomFunc(ret, func() { From 68ff96ae84f1605b6c4848a69555d8c3a47c263f Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 00:27:17 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20fi?= =?UTF-8?q?ght=5Fbase.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_base.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index e51589082..6ff1974b2 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -58,6 +58,11 @@ func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Playe if err := h.checkFightStatus(c); err != 0 { return nil, err } + if c.GetSpace().IsTime { + if data.ItemId < 300009 { + return nil, errorcode.ErrorCodes.ErrCannotPerformAction + } + } defer c.FightC.Capture(c, data.CapsuleId) return nil, -1 } From 62b7c33d33af1d8f28a9d924e247587e902bbfc4 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 00:28:40 +0800 Subject: [PATCH 08/14] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E6=80=AA=E7=89=A9=E6=97=B6=E8=83=B6=E5=9B=8AID?= =?UTF-8?q?=E7=9A=84=E6=A3=80=E6=9F=A5=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_base.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index 6ff1974b2..6acaba318 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -59,7 +59,7 @@ func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Playe return nil, err } if c.GetSpace().IsTime { - if data.ItemId < 300009 { + if data.CapsuleId < 300009 { return nil, errorcode.ErrorCodes.ErrCannotPerformAction } } From a5627e6ba12336073ca06b3471c61026bf8436eb Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 00:36:41 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20fi?= =?UTF-8?q?ght=5Fbase.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_base.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index 6acaba318..7b40d7b3d 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -21,7 +21,7 @@ func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *playe if err := h.checkFightStatus(c); err != 0 { return nil, err } - defer c.FightC.ReadyFight(c) + c.FightC.ReadyFight(c) return nil, -1 } @@ -30,7 +30,7 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu if err := h.checkFightStatus(c); err != 0 { return nil, err } - defer c.FightC.UseSkill(c, data.SkillId) + c.FightC.UseSkill(c, data.SkillId) return nil, 0 } @@ -40,7 +40,7 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) return nil, err } - defer c.FightC.Over(c, info.BattleOverReason.PlayerEscape) + c.FightC.Over(c, info.BattleOverReason.PlayerEscape) return nil, 0 } @@ -49,7 +49,7 @@ func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player if err := h.checkFightStatus(c); err != 0 { return nil, err } - defer c.FightC.ChangePet(c, data.CatchTime) + c.FightC.ChangePet(c, data.CatchTime) return nil, -1 } @@ -63,7 +63,7 @@ func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Playe return nil, errorcode.ErrorCodes.ErrCannotPerformAction } } - defer c.FightC.Capture(c, data.CapsuleId) + c.FightC.Capture(c, data.CapsuleId) return nil, -1 } @@ -72,7 +72,7 @@ func (h Controller) LoadPercent(data *fight.LoadPercentInboundInfo, c *player.Pl if c.FightC == nil { return nil, -1 } - defer c.FightC.LoadPercent(c, int32(data.Percent)) + c.FightC.LoadPercent(c, int32(data.Percent)) return nil, -1 } @@ -86,7 +86,7 @@ func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c * return nil, errorcode.ErrorCodes.ErrCannotPerformAction } } - defer c.FightC.UseItem(c, data.CatchTime, data.ItemId) + c.FightC.UseItem(c, data.CatchTime, data.ItemId) return nil, -1 } @@ -95,6 +95,6 @@ func (h Controller) FightChat(data *fight.ChatInfo, c *player.Player) (result *f if err := h.checkFightStatus(c); err != 0 { return nil, err } - defer c.FightC.Chat(c, data.Message) + c.FightC.Chat(c, data.Message) return nil, -1 } From 0f1adffdd50b71f71028dfd9dfcd4da66d1921f6 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 03:51:25 +0800 Subject: [PATCH 10/14] =?UTF-8?q?refactor:=20=E5=B0=86=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E4=BB=8E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B1=A0=E6=8F=90=E4=BA=A4=E6=94=B9=E4=B8=BA=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=B0=83=E7=94=A8OnEvent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/socket/ServerEvent.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index 5874a3992..98333666d 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -281,10 +281,10 @@ func (s *Server) onevent(c gnet.Conn, v []byte) { } else { header.Data = nil // 避免空切片分配 } - - s.workerPool.Submit(func() { - t.LF.Producer().Write(header) - }) + t.OnEvent(header) + // s.workerPool.Submit(func() { + // t.LF.Producer().Write(header) + // }) } } From 3ac8ab20863f6ec3292ae72d94ab867c711548f5 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 03:52:32 +0800 Subject: [PATCH 11/14] 1 --- logic/controller/fight_base.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index 7b40d7b3d..7ece8026c 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -21,7 +21,7 @@ func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *playe if err := h.checkFightStatus(c); err != 0 { return nil, err } - c.FightC.ReadyFight(c) + go c.FightC.ReadyFight(c) return nil, -1 } @@ -30,7 +30,7 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu if err := h.checkFightStatus(c); err != 0 { return nil, err } - c.FightC.UseSkill(c, data.SkillId) + go c.FightC.UseSkill(c, data.SkillId) return nil, 0 } @@ -40,7 +40,7 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player) return nil, err } - c.FightC.Over(c, info.BattleOverReason.PlayerEscape) + go c.FightC.Over(c, info.BattleOverReason.PlayerEscape) return nil, 0 } @@ -49,7 +49,7 @@ func (h Controller) ChangePet(data *fight.ChangePetInboundInfo, c *player.Player if err := h.checkFightStatus(c); err != 0 { return nil, err } - c.FightC.ChangePet(c, data.CatchTime) + go c.FightC.ChangePet(c, data.CatchTime) return nil, -1 } @@ -63,7 +63,7 @@ func (h Controller) Capture(data *fight.CatchMonsterInboundInfo, c *player.Playe return nil, errorcode.ErrorCodes.ErrCannotPerformAction } } - c.FightC.Capture(c, data.CapsuleId) + go c.FightC.Capture(c, data.CapsuleId) return nil, -1 } @@ -72,7 +72,7 @@ func (h Controller) LoadPercent(data *fight.LoadPercentInboundInfo, c *player.Pl if c.FightC == nil { return nil, -1 } - c.FightC.LoadPercent(c, int32(data.Percent)) + go c.FightC.LoadPercent(c, int32(data.Percent)) return nil, -1 } @@ -86,7 +86,7 @@ func (h Controller) UsePetItemInboundInfo(data *fight.UsePetItemInboundInfo, c * return nil, errorcode.ErrorCodes.ErrCannotPerformAction } } - c.FightC.UseItem(c, data.CatchTime, data.ItemId) + go c.FightC.UseItem(c, data.CatchTime, data.ItemId) return nil, -1 } @@ -95,6 +95,6 @@ func (h Controller) FightChat(data *fight.ChatInfo, c *player.Player) (result *f if err := h.checkFightStatus(c); err != 0 { return nil, err } - c.FightC.Chat(c, data.Message) + go c.FightC.Chat(c, data.Message) return nil, -1 } From 05a1900d6013b2c669922991af5bd35e55217c2f Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 04:22:02 +0800 Subject: [PATCH 12/14] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84lockfree=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/socket/ServerEvent.go | 2 +- logic/service/player/pack.go | 50 +++++++++++++++++------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index 98333666d..d1354617b 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -86,7 +86,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) { //logging.Infof("conn[%v] disconnected", c.RemoteAddr().String()) v, _ := c.Context().(*player.ClientData) - v.LF.Close() + //v.LF.Close() if v.Player != nil { v.Player.Save() //保存玩家数据 diff --git a/logic/service/player/pack.go b/logic/service/player/pack.go index 171208660..395583595 100644 --- a/logic/service/player/pack.go +++ b/logic/service/player/pack.go @@ -7,7 +7,6 @@ import ( "encoding/binary" "encoding/hex" "sync" - "time" "context" @@ -15,7 +14,6 @@ import ( "fmt" "reflect" - "github.com/bruceshao/lockfree" "github.com/gobwas/ws" "github.com/gobwas/ws/wsutil" "github.com/gogf/gf/v2/os/glog" @@ -91,23 +89,23 @@ func XORDecryptU(encryptedData []byte, key uint32) []byte { // 遍历结构体方法并执行RECV_cmd func (h *ClientData) OnEvent(data common.TomeeHeader) { - defer func() { - if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值 - // 1. 打印错误信息 - if h.Player != nil { - if h.Player.Info != nil { - cool.Logger.Error(context.TODO(), "panic 错误:", cool.Config.ServerInfo.OnlineID, h.Player.Info.UserID, err) - } else { - cool.Logger.Error(context.TODO(), "panic 错误:", cool.Config.ServerInfo.OnlineID, err) + // defer func() { + // if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值 + // // 1. 打印错误信息 + // if h.Player != nil { + // if h.Player.Info != nil { + // cool.Logger.Error(context.TODO(), "panic 错误:", cool.Config.ServerInfo.OnlineID, h.Player.Info.UserID, err) + // } else { + // cool.Logger.Error(context.TODO(), "panic 错误:", cool.Config.ServerInfo.OnlineID, err) - } + // } - } else { - cool.Logger.Error(context.TODO(), "panic 错误:", err) - } + // } else { + // cool.Logger.Error(context.TODO(), "panic 错误:", err) + // } - } - }() + // } + // }() if data.CMD > 1001 { if h.Player == nil { @@ -212,7 +210,7 @@ type ClientData struct { ERROR_CONNUT int Wsmsg *WsCodec Conn gnet.Conn - LF *lockfree.Lockfree[common.TomeeHeader] + //LF *lockfree.Lockfree[common.TomeeHeader] //SaveL sync.Once //保存锁 //SaveDone chan struct{} @@ -227,19 +225,19 @@ func NewClientData(c gnet.Conn) *ClientData { Conn: c, Wsmsg: &WsCodec{}, } - cd.LF = lockfree.NewLockfree( - 8, - cd, - lockfree.NewSleepBlockStrategy(time.Millisecond), - ) - // 启动Lockfree - if err := cd.LF.Start(); err != nil { - panic(err) - } + // cd.LF = lockfree.NewLockfree( + // 8, + // cd, + // lockfree.NewSleepBlockStrategy(time.Millisecond), + // ) // // 启动Lockfree // if err := cd.LF.Start(); err != nil { // panic(err) // } + // // // 启动Lockfree + // // if err := cd.LF.Start(); err != nil { + // // panic(err) + // // } return cd } From 571c941ae82f1d9b3169f1453b5035bc8fcace79 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 07:31:21 +0800 Subject: [PATCH 13/14] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=B8=A2?= =?UTF-8?q?=E4=BA=BA=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E4=BF=A1=E6=81=AF=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将踢人超时时间从3秒调整为10秒,并在超时处理中保存玩家信息 --- logic/service/player/player.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 7f2b7e15d..8917de8a5 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -259,11 +259,12 @@ func (player1 *Player) Kick(isquit bool) { // --- 新增超时机制核心代码 --- // 设定超时时间(可根据业务需求调整,这里以3秒为例) - const kickTimeout = 3 * time.Second + const kickTimeout = 10 * time.Second select { case <-CloseChan: // 正常流程:连接关闭回调已执行,CloseChan 被关闭 case <-time.After(kickTimeout): + player1.Service.Info.Save(*player1.Info) service.NewBaseSysLogService().RecordKick(uint32(player1.Info.UserID), fmt.Errorf("踢人操作超时(超时时间:%v)", kickTimeout).Error()) // 超时处理:避免永久阻塞,可添加日志便于排查问题 // 注意:这里不会中断 CloseWithCallback 的执行,仅解除当前协程的阻塞 From b2189d9501ea75e34c0514f4632908c36c7e8ac1 Mon Sep 17 00:00:00 2001 From: xinian Date: Tue, 24 Feb 2026 08:54:21 +0800 Subject: [PATCH 14/14] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3NPC=E6=88=98?= =?UTF-8?q?=E6=96=97=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=8A=80=E8=83=BD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/loop.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index 1d5b355c6..6ab6e2a6e 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -267,7 +267,7 @@ func (f *FightC) handleTimeout(ourID, oppID uint32, actions map[uint32]action.Ba if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC { // f.WinnerId = 0 - go f.Our.GetAction() //boss出手后获取出招 + go f.UseSkill(f.Our.Player, 0) //boss出手后获取出招 return false } else { var pid uint32