diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 43aeda3e7..89815440c 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -35,7 +35,7 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options func (this *Worldtask) OnInstallComp() { this.ModuleBase.OnInstallComp() - event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) + event.RegisterGO(comm.EventBuriedComplete, this.TCondFinishNotify) this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) @@ -58,6 +58,10 @@ func (this *Worldtask) Start() (err error) { func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { session, ok := this.GetUserSession(uid) + defer func() { + session.Push() + this.PutUserSession(session) + }() if !ok { return } @@ -73,6 +77,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { var groupId, taskId int32 // 检索condId是否是世界任务的完成条件 finishedTaskIds := make(map[int32]int32) //达成的任务条件 + finishedCondIds := []int32{} for _, c := range this.worldtaskConf.GetDataList() { for _, v := range c.Completetask { for _, condId := range conids { @@ -83,6 +88,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { finishedTaskIds[c.Group] = c.Key groupId = c.Group taskId = c.Key + finishedCondIds = append(finishedCondIds, condId) } } break @@ -109,7 +115,14 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { for _, condId := range conids { if _, ok := utils.Findx(wt.CondiIds, condId); !ok { - wt.CondiIds = append(wt.CondiIds, condId) + condIds, err := this.ModuleBuried.CheckCondition(uid, condId) + if err != nil { + this.Error("完成条件校验错误", log.Field{Key: "condId", Value: condId}) + return + } + if len(condIds) == 1 && condIds[0] == condId { + wt.CondiIds = append(wt.CondiIds, condId) + } } } @@ -140,6 +153,7 @@ func (this *Worldtask) TCondFinishNotify(uid string, conids []int32) { this.modelWorldtask.taskFinish(session, groupId, taskId, userTask, curTaskConf) this.modelWorldtask.taskFinishPush(session, groupId, userTask, curTaskConf) } + return }