增加日志

This commit is contained in:
hahwu 2026-03-30 16:14:26 +08:00
parent 578213ee50
commit 22e29b7564

View File

@ -2,6 +2,7 @@ package game
import (
"fmt"
"maps"
"math"
avatarCfg "server/conf/avatar"
@ -136,9 +137,7 @@ func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
data.ZeroTime = GoUtil.ZeroTimestamp()
// 深拷贝 map避免多个协程持有同一个 map 引用导致并发读写
oldRank := make(map[int][]*ChampshipRank, len(data.Rank))
for k, v := range data.Rank {
oldRank[k] = v
}
maps.Copy(oldRank, data.Rank)
oldRobot := make(map[int]*ChampshipRobot, len(data.Robot))
for k, v := range data.Robot {
oldRobot[k] = v
@ -162,11 +161,15 @@ func (c *ChampshipMgr) ZeroUpdate() (interface{}, error) {
c.SetRankCache(k)
}
data.mu.Unlock()
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
timeDuration := GoUtil.NextZeroTimestampDuration()
if timeDuration <= 0 {
log.Error("championship zero update error")
timeDuration = 24 * 3600
}
c.mDispatr.AfterFunc(time.Duration(timeDuration)*time.Second, func() {
c.ZeroUpdate()
})
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration()+1800)*time.Second, func() {
c.mDispatr.AfterFunc(time.Duration(timeDuration+1800)*time.Second, func() {
c.ZeroNotifyAll()
})
// 在锁外通知玩家,避免在持有锁时调用外部函数