This commit is contained in:
hahwu 2026-04-02 10:42:53 +08:00
parent 97b764367a
commit 557dec4612
2 changed files with 15 additions and 0 deletions

View File

@ -75,6 +75,10 @@ func (r *ActivityMgr) GetActivityList() []ActivityCfg {
interval := (now - v.Startime) / v.Interval
v.Startime += interval * v.Interval
v.Endtime += interval * v.Interval
if now > v.Endtime {
v.Startime += v.Interval
v.Endtime += v.Interval
}
}
v.Id = int(v.Startime) //活动id用开始时间表示方便客户端排序
}
@ -130,6 +134,12 @@ func (r *ActivityMgr) Reload() error {
log.Debug("load activity cfg: %v", cfg)
data.List[v.Id] = cfg
}
go func() {
actList := r.GetActivityList()
for _, v := range actList {
log.Debug("activity load success: type :%d, id :%d, startTime :%s, endTime :%s", v.Type, v.Id, GoUtil.FormatTime(v.Startime), GoUtil.FormatTime(v.Endtime))
}
}()
G_GameLogicPtr.NotifyAll(&Msg.Msg{Type: Msg.HANDLE_TYPE_ACTIVITY_RELOAD})
return nil
}

View File

@ -178,3 +178,8 @@ func IsFirstDayOfMonth() bool {
func NowMonth() int {
return int(time.Now().Month())
}
func FormatTime(timestamp int64) string {
t := time.Unix(timestamp, 0)
return t.Format("2006-01-02 15:04:05")
}