From 4370238f94d334e85701270df6ee2adcd75558aa Mon Sep 17 00:00:00 2001 From: hahwu <31872165+hahwu@users.noreply.github.com> Date: Thu, 16 Apr 2026 15:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=A6=E6=A0=87=E8=B5=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/game/activity_func.go | 7 ++++++ src/server/game/activity_mgr.go | 3 +++ src/server/game/champship_mgr.go | 42 ++++++++++++++++++++++---------- src/server/game/player_data.go | 2 -- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/server/game/activity_func.go b/src/server/game/activity_func.go index feffdf5a..9c4e2bef 100644 --- a/src/server/game/activity_func.go +++ b/src/server/game/activity_func.go @@ -102,6 +102,8 @@ func (p *Player) ActivityLogin() { // 猫猫回礼登录 p.CatReturnGiftLogin() + // 赛季活动登录 + p.ChampionshipLogin() } // 发送活动邮件 @@ -185,6 +187,11 @@ func (p *Player) CatReturnGiftLogin() { p.CatReturnGiftZeroUpdate() } +func (p *Player) ChampionshipLogin() { + p.ChampionshipZeroUpdate() + p.BackChampship() +} + // 猫猫回礼0点更新 func (p *Player) CatReturnGiftZeroUpdate() { activityInfo := p.GetActivityInfo(activity.ACT_TYPE_CAT_RETURN_GIFT) diff --git a/src/server/game/activity_mgr.go b/src/server/game/activity_mgr.go index 9120aafb..5971b01a 100644 --- a/src/server/game/activity_mgr.go +++ b/src/server/game/activity_mgr.go @@ -196,6 +196,9 @@ func (r *ActivityMgr) Reload() error { } }() G_GameLogicPtr.NotifyAll(&Msg.Msg{Type: Msg.HANDLE_TYPE_ACTIVITY_RELOAD}) + if G_GameLogicPtr.ChampshipMgr != nil { + G_GameLogicPtr.ChampshipMgr.ReloadActivity() + } return nil } diff --git a/src/server/game/champship_mgr.go b/src/server/game/champship_mgr.go index 380c11c0..72a3336a 100644 --- a/src/server/game/champship_mgr.go +++ b/src/server/game/champship_mgr.go @@ -20,6 +20,7 @@ import ( "time" "gitea.bywaystudios.com/pet_home/leaf/log" + "gitea.bywaystudios.com/pet_home/leaf/timer" ) const ( @@ -30,6 +31,8 @@ type ChampshipMgr struct { *ServerMod } +var dispterTimer map[string]*timer.Timer + type ChampshipData struct { mu sync.RWMutex AutoId int @@ -103,20 +106,18 @@ func (c *ChampshipMgr) Init() { c.version() now := GoUtil.Now() zeroTime := GoUtil.ZeroTimestamp() - if c.getData().ZeroTime != zeroTime { + activityCfg := G_GameLogicPtr.ActivityMgr.GetActivityListByType(activity.ACT_TYPE_CHAMPION) + t := c.mDispatr.AfterFunc(time.Duration(activityCfg.Endtime-now)*time.Second, func() { c.ZeroUpdate() - } else { - c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() { - c.ZeroUpdate() - }) - } + }) + dispterTimer["zero"] = t + remain := now - zeroTime remain1 := 1800 - remain%1800 c.mDispatr.AfterFunc(time.Duration(remain1)*time.Second, func() { // 30分钟后重新分组 c.group() }) - c.mDispatr.AfterFunc(time.Duration(60)*time.Second, func() { c.ai() }) @@ -181,6 +182,24 @@ func (c *ChampshipMgr) ZeroNotifyAll() (interface{}, error) { return nil, nil } +func (c *ChampshipMgr) ReloadActivity() { + log.Debug("ChampshipMgr ReloadActivity") + activityCfg := G_GameLogicPtr.ActivityMgr.GetActivityListByType(activity.ACT_TYPE_CHAMPION) + if activityCfg.AId == 0 { + log.Debug("championship reload activity failed, no active, aid:%d", activityCfg.AId) + return + } + t := dispterTimer["zero"] + if t != nil { + t.Stop() + } + timeDuration := activityCfg.Endtime - GoUtil.Now() + t = c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() { + c.ZeroUpdate() + }) + dispterTimer["zero"] = t +} + func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) { log.Debug("ChampshipMgr ZeroUpdate") data := c.getData() @@ -221,14 +240,11 @@ func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) { c.SetRankCache(k) } data.mu.Unlock() - timeDuration := GoUtil.NextZeroTimestampDuration() - if timeDuration <= 0 { - log.Error("championship zero update error") - timeDuration = 24 * 3600 - } - c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() { + timeDuration := activityCfg.Endtime - GoUtil.Now() + t := c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() { c.ZeroUpdate() }) + dispterTimer["zero"] = t c.mDispatr.AfterFunc(time.Duration(timeDuration+1800)*time.Second, func() { c.ZeroNotifyAll() }) diff --git a/src/server/game/player_data.go b/src/server/game/player_data.go index 4b2a4074..5c14de8d 100644 --- a/src/server/game/player_data.go +++ b/src/server/game/player_data.go @@ -420,8 +420,6 @@ func (p *Player) ZeroUpdate(a []interface{}) { PlayroomMod.ResetWeeklyDiscount() } p.PlayroomBackData() - p.ChampionshipZeroUpdate() - p.BackChampship() // p.InitActivity() // p.ActivityZeroUpdate()