diff --git a/common/cool/global.go b/common/cool/global.go index aa4f8581a..e1469b51d 100644 --- a/common/cool/global.go +++ b/common/cool/global.go @@ -5,6 +5,7 @@ import ( "context" "reflect" + "github.com/antlabs/cronex" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/util/gconv" "github.com/yitter/idgenerator-go/idgen" @@ -17,6 +18,8 @@ var ( CmdCache = &utils.SyncMap[uint32, reflect.Value]{} //命令缓存 Loger = glog.New() + Cron = cronex.New() //时间轮 + ) var Filter *sensitive.Manager @@ -39,7 +42,8 @@ func init() { sensitive.StoreOption{Type: sensitive.StoreMemory}, // 基于内存 sensitive.FilterOption{Type: sensitive.FilterDfa}, // 基于DFA算法 ) - + Cron.Start() + // if err != nil { // log.Fatalf("敏感词服务启动失败, err:%v", err) // return diff --git a/common/utils/cronex b/common/utils/cronex new file mode 160000 index 000000000..88109676e --- /dev/null +++ b/common/utils/cronex @@ -0,0 +1 @@ +Subproject commit 88109676e35b35288829f36cf2aa4184d7dbf233 diff --git a/go.work b/go.work index de9ca549c..cc6b4c722 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,6 @@ -go 1.19 +go 1.20 + +toolchain go1.21.4 use ( ./common @@ -8,13 +10,14 @@ use ( ./common/cool ./common/utils/bitset ./common/utils/bytearray + ./common/utils/cronex ./common/utils/event ./common/utils/go-jsonrpc + ./common/utils/go-sensitive-word-1.3.3 ./common/utils/goja ./common/utils/log ./common/utils/sturc ./common/utils/xml - ./common/utils/go-sensitive-word-1.3.3 ./logic ./login ./modules diff --git a/logic/controller/login.go b/logic/controller/login.go index f5f42125a..71b1b5b6b 100644 --- a/logic/controller/login.go +++ b/logic/controller/login.go @@ -60,13 +60,6 @@ func (h *Controller) Login(data *login.InInfo, c *player.Conn) (result *login.Ou }() } - if t.Info.MapID > 10000 { - t.Info.MapID = 1 - - } - if t.IsNewPlayer() { - t.Info.MapID = 515 - } t.CompleteLogin() //通知客户端登录成功 diff --git a/logic/go.mod b/logic/go.mod index 96ec848ad..9fe2b7c66 100644 --- a/logic/go.mod +++ b/logic/go.mod @@ -6,6 +6,9 @@ require github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543 require ( github.com/BurntSushi/toml v1.4.0 // indirect + github.com/antlabs/cronex v0.0.5 // indirect + github.com/antlabs/stl v0.0.2 // indirect + github.com/antlabs/timer v0.1.4 // indirect github.com/butoften/array v1.0.9 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect diff --git a/logic/go.sum b/logic/go.sum index 7c3d5b4ab..c2617fe24 100644 --- a/logic/go.sum +++ b/logic/go.sum @@ -1,5 +1,11 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/antlabs/cronex v0.0.5 h1:n8vE2QVNc7ghd3NZpcC0OpLFtJZcNCgtDNwwA354has= +github.com/antlabs/cronex v0.0.5/go.mod h1:g0KFeHNmsKMC6zhpiHKQcdSat93uAg5iIIrmncalyn8= +github.com/antlabs/stl v0.0.2 h1:sna1AXR5yIkNE9lWhCcKbheFJSVfCa3vugnGyakI79s= +github.com/antlabs/stl v0.0.2/go.mod h1:kKrO4xrn9cfS1mJVo+/BqePZjAYMXqD0amGF2Ouq7ac= +github.com/antlabs/timer v0.1.4 h1:MHdE00MDnNfhJCmqSOdLXs35uGNwfkMwfbynxrGmQ1c= +github.com/antlabs/timer v0.1.4/go.mod h1:mpw4zlD5KVjstEyUDp43DGLWsY076Mdo4bS78NTseRE= github.com/badu/bus v1.0.3 h1:MViRRyuFraixfaI2rfAqrkQao7ZilyFz6HacbmPk1aE= github.com/badu/bus v1.0.3/go.mod h1:77qc3Fi2qSUoakSR34PIWrTHB6gM2NJKceRsYUbx41Q= github.com/butoften/array v1.0.9 h1:/kPHAc+fHz72u5B23p2W1RzIoT2eOYvhsY0tKMvsHEc= diff --git a/logic/service/player/player.go b/logic/service/player/player.go index a8eddcc08..cdd0a938f 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -120,8 +120,6 @@ func WithConn(c *Conn) PlayerOption { } } - - func (p *Player) GetAction() { return @@ -316,7 +314,6 @@ func (p *Player) Save() { return } - //glog.Debug(context.Background(), p.Info.UserID, "断开连接") LeaveMap(p) close(p.StopChan) //停止刷怪 @@ -335,6 +332,12 @@ func (p *Player) Save() { } +// 是否可以获得经验 +func (p *Player) CanGetExp() bool { + ttt := p.Info.TimeLimit - p.Info.TimeToday + return (uint32(time.Now().Unix()) - uint32(p.Onlinetime)) <= ttt +} + // IsLoggedIn 检查是否已登录 func (lw *Player) IsLoggedIn() bool { lw.mu.Lock() @@ -389,7 +392,13 @@ func (lw *Player) WaitForLoginWithCtx(ctx context.Context) error { func (lw *Player) CompleteLogin() { lw.mu.Lock() defer lw.mu.Unlock() + if lw.Info.MapID > 10000 { //如果位于基地,就重置到传送仓 + lw.Info.MapID = 1 + } + if lw.IsNewPlayer() { //重置新手地图 + lw.Info.MapID = 515 + } if !lw.IsLogin { lw.IsLogin = true close(lw.loginChan) // 关闭通道以通知所有等待者