diff --git a/modules/academy/api_receive.go b/modules/academy/api_receive.go index ef332458c..4181f50f2 100644 --- a/modules/academy/api_receive.go +++ b/modules/academy/api_receive.go @@ -50,7 +50,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.AcademyReceiveRe } this.module.DispenseRes(session, level.Award, true) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype151, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype151, 1)) } session.SendMsg(string(this.module.GetType()), "receive", &pb.AcademyReceiveResp{Issucc: true}) return diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index 79762e106..ed7e27a97 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -40,7 +40,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge Tasks: record.Tasks, }}) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype130, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype130, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype130, 1)) } else { session.SendMsg(string(this.module.GetType()), "challenge", &pb.ArenaChallengeResp{Code: cd, Info: nil}) } diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index c321521a0..7abfb16f8 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -62,7 +62,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha bulestate = pb.BattleRecordState_DefendLost } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype131, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype131, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype131, 1)) } else { if req.Revengeid != "" { redstate = pb.BattleRecordState_RevengeFailed @@ -225,7 +225,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha code = pb.ErrorCode_DBError } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype128, red.Integral), comm.GettaskParam(comm.Rtype129, red.Dan)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype128, red.Integral), comm.GettaskParam(comm.Rtype129, red.Dan)) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype128, red.Integral) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype129, red.Dan) return diff --git a/modules/battle/module.go b/modules/battle/module.go index 55f9d66ef..ddfd2ea0f 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -139,7 +139,7 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE for _, v := range req.Format.Friendformat { if v != "" { // this.ModuleRtask.SendToRtask(session, comm.Rtype108, 1) - this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype108, 1)) + go this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype108, 1)) break } } @@ -249,7 +249,7 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP for _, v := range req.Format.Friendformat { if v != "" { // this.ModuleRtask.SendToRtask(session, comm.Rtype108, 1) - this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype108, 1)) + go this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype108, 1)) break } } @@ -378,7 +378,7 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt this.moonfantasy.Trigger(session, report) for _, v := range report.Completetask { // this.ModuleRtask.SendToRtask(session, comm.Rtype157, int32(report.Info.Ptype), v) - this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype157, int32(report.Info.Ptype), v)) + go this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype157, int32(report.Info.Ptype), v)) } return pb.ErrorCode_Success, true } diff --git a/modules/caravan/api_buyorsell.go b/modules/caravan/api_buyorsell.go index 50f8544cf..6cf52f6f8 100644 --- a/modules/caravan/api_buyorsell.go +++ b/modules/caravan/api_buyorsell.go @@ -21,6 +21,6 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype153, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype153, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype153, 1)) return } diff --git a/modules/chat/api_send.go b/modules/chat/api_send.go index 95286c0f3..427de0a6c 100644 --- a/modules/chat/api_send.go +++ b/modules/chat/api_send.go @@ -75,7 +75,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code } go this.module.modelChat.sendChatToWorld(msg, max_chat) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype62, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype62, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype62, 1)) //随机任务 // if _, err = this.service.AcrossClusterRpcGo( // context.Background(), @@ -117,7 +117,7 @@ func (this *apiComp) Send(session comm.IUserSession, req *pb.ChatSendReq) (code go this.module.modelChat.sendChatToCrossServer(msg, max_chat) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype106, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype106, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype106, 1)) break default: code = pb.ErrorCode_ReqParameterError diff --git a/modules/combat/api_challengereceive.go b/modules/combat/api_challengereceive.go index 4f841d654..f3c7481f9 100644 --- a/modules/combat/api_challengereceive.go +++ b/modules/combat/api_challengereceive.go @@ -91,7 +91,7 @@ func (this *apiComp) ChallengeReceive(session comm.IUserSession, req *pb.CombatC lv.Pass = true this.module.DispenseRes(session, level.Award, true) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, 1, level.Id) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype140, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype140, 1)) } lv.Progress = int32((float64(len(lv.Passmanster)+len(lv.Passdrop)) / float64(len(level.Passdroplist)+len(level.PassformatList))) * float64(100)) if err = this.module.modelCombat.updateInfo(info); err != nil { diff --git a/modules/combat/api_drop.go b/modules/combat/api_drop.go index 60222ca02..a144dad9d 100644 --- a/modules/combat/api_drop.go +++ b/modules/combat/api_drop.go @@ -100,7 +100,7 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (cod lv.Pass = true this.module.DispenseRes(session, level.Award, true) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype140, 1, level.Id) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype140, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype140, 1)) } lv.Progress = int32((float64(len(lv.Passmanster)+len(lv.Passdrop)) / float64(len(level.Passdroplist)+len(level.PassformatList))) * float64(100)) if err = this.module.modelCombat.updateInfo(info); err != nil { diff --git a/modules/equipment/api_ench.go b/modules/equipment/api_ench.go index 8095083b9..bf5540d43 100644 --- a/modules/equipment/api_ench.go +++ b/modules/equipment/api_ench.go @@ -90,7 +90,7 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) ( } } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype94, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype94, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype94, 1)) session.SendMsg(string(this.module.GetType()), "ench", &pb.EquipmentEnchResp{Issucc: true, Equipment: equip}) return } diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 8b5ef3648..532ebb4fe 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -191,7 +191,7 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) } if len(tasks) > 0 { - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment}) diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 1bdcf634c..2adb0e434 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -208,7 +208,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade // this.module.ModuleRtask.SendToRtask(session, comm.Rtype96, 1) } if len(tasks) > 0 { - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } session.SendMsg(string(this.module.GetType()), "upgrade", &pb.EquipmentUpgradeResp{IsSucc: issucc, Equipment: modifyequipments}) return diff --git a/modules/equipment/api_wash.go b/modules/equipment/api_wash.go index 3e885e02e..cdf202b69 100644 --- a/modules/equipment/api_wash.go +++ b/modules/equipment/api_wash.go @@ -67,7 +67,7 @@ func (this *apiComp) Wash(session comm.IUserSession, req *pb.EquipmentWashReq) ( } } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype95, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype95, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype95, 1)) session.SendMsg(string(this.module.GetType()), "wash", &pb.EquipmentWashResp{Eid: req.Eid, AdverbEntry: adverbEntry}) return } diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index 0afa1fa9d..34c6fb59c 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -135,7 +135,7 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma //异步出发任务启动 if len(tasks) > 0 { - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } if len(add) > 0 { diff --git a/modules/friend/api_cross_agree.go b/modules/friend/api_cross_agree.go index 321bd8390..46ffb2f10 100644 --- a/modules/friend/api_cross_agree.go +++ b/modules/friend/api_cross_agree.go @@ -135,7 +135,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c // 拥有xx个好友 // this.moduleFriend.ModuleRtask.SendToRtask(session, comm.Rtype10, int32(len(agreeIds))) - this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype10, int32(len(agreeIds)))) + go this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype10, int32(len(agreeIds)))) resp := &pb.FriendAgreeResp{ Num: optNum, } diff --git a/modules/friend/api_cross_assisthero.go b/modules/friend/api_cross_assisthero.go index 904896a73..164d1188d 100644 --- a/modules/friend/api_cross_assisthero.go +++ b/modules/friend/api_cross_assisthero.go @@ -98,6 +98,6 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth // 随机任务Rtype13 // this.moduleFriend.ModuleRtask.SendToRtask(session, comm.Rtype13, 1) - this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype13, 1)) + go this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype13, 1)) return } diff --git a/modules/friend/api_cross_zan.go b/modules/friend/api_cross_zan.go index c8476f319..13aa770d6 100644 --- a/modules/friend/api_cross_zan.go +++ b/modules/friend/api_cross_zan.go @@ -100,6 +100,6 @@ func (this *apiComp) Zan(session comm.IUserSession, req *pb.FriendZanReq) (code // 赠送X次友情点 // this.moduleFriend.ModuleRtask.SendToRtask(session, comm.Rtype11, 1) - this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype11, 1)) + go this.moduleFriend.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype11, 1)) return } diff --git a/modules/gourmet/api_createfood.go b/modules/gourmet/api_createfood.go index f860eeb44..64c3553a8 100644 --- a/modules/gourmet/api_createfood.go +++ b/modules/gourmet/api_createfood.go @@ -79,6 +79,6 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate Cid: curFood, FirstGet: bFirst, }) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype150, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype150, 1)) return } diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index 21478fe1f..14adf7e56 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -117,6 +117,6 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c } } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) return } diff --git a/modules/hero/api_buy.go b/modules/hero/api_buy.go index 287596e8c..68793866b 100644 --- a/modules/hero/api_buy.go +++ b/modules/hero/api_buy.go @@ -121,7 +121,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb tasks = append(tasks, comm.GettaskParam(comm.Rtype67, v.N, utils.ToInt32(v.T))) } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) session.SendMsg(string(this.module.GetType()), "buy", &pb.HeroBuyResp{ IsSucc: true, Onebuy: record.Onebuy + req.BuyCount, diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go index 657bc8010..979905ba6 100644 --- a/modules/hero/api_fusion.go +++ b/modules/hero/api_fusion.go @@ -86,6 +86,6 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c session.SendMsg(string(this.module.GetType()), HeroFusionResp, &pb.HeroFusionResp{Heroid: conf.Hero}) // 通过融合获得指定英雄 // this.module.ModuleRtask.SendToRtask(session, comm.Rtype139, utils.ToInt32(conf.Hero)) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype139, utils.ToInt32(conf.Hero))) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype139, utils.ToInt32(conf.Hero))) return } diff --git a/modules/hero/api_strengthenUpSkill.go b/modules/hero/api_strengthenUpSkill.go index 395dce76a..04bd8f7ff 100644 --- a/modules/hero/api_strengthenUpSkill.go +++ b/modules/hero/api_strengthenUpSkill.go @@ -137,6 +137,6 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt szTask = append(szTask, comm.GettaskParam(comm.Rtype55, 1, cfg.Color)) szTask = append(szTask, comm.GettaskParam(comm.Rtype56, 1, 1, cfg.Job)) } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) return } diff --git a/modules/hero/api_strengthenUpStar.go b/modules/hero/api_strengthenUpStar.go index f66b4b704..779a13611 100644 --- a/modules/hero/api_strengthenUpStar.go +++ b/modules/hero/api_strengthenUpStar.go @@ -96,7 +96,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr szTask = append(szTask, comm.GettaskParam(comm.Rtype28, 1)) } szTask = append(szTask, comm.GettaskParam(comm.Rtype115, utils.ToInt32(_hero.HeroID), _hero.Star)) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype115, utils.ToInt32(_hero.HeroID), _hero.Star) return } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 8806093f4..1f15f0cde 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -596,7 +596,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex } } szTask = append(szTask, comm.GettaskParam(comm.Rtype33, 1, 1, hero.Lv)) - this.moduleHero.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.moduleHero.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) //this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype33, 1, 1, hero.Lv) } } diff --git a/modules/hero/module.go b/modules/hero/module.go index 3a18bfdda..849b1e8b1 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -100,7 +100,7 @@ func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, szTask = append(szTask, comm.GettaskParam(comm.Rtype1, 1, utils.ToInt32(heroCfgId))) szTask = append(szTask, comm.GettaskParam(comm.Rtype30, 1, cfg.Color)) szTask = append(szTask, comm.GettaskParam(comm.Rtype31, 1, cfg.Color)) - this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) } return @@ -174,7 +174,7 @@ func (this *Hero) SendRdTask(session comm.IUserSession) { //this.ModuleRtask.SendToRtask(session, comm.Rtype46, v1, k1, k) } } - this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) } //英雄列表 @@ -759,7 +759,7 @@ func (this *Hero) SendTaskMsg(session comm.IUserSession, szStar []int32, drawCou } szTask = append(szTask, comm.GettaskParam(comm.Rtype89, drawCount)) - this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) } func (this *Hero) newCondition(heroRecord *pb.DBHeroRecord) (get bool, starIndex int32) { diff --git a/modules/hunting/api_challengeover.go b/modules/hunting/api_challengeover.go index 04cb6caa9..7e38912d1 100644 --- a/modules/hunting/api_challengeover.go +++ b/modules/hunting/api_challengeover.go @@ -140,6 +140,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha } } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) return } diff --git a/modules/items/api_useItem.go b/modules/items/api_useItem.go index 71d36e482..f9639abed 100644 --- a/modules/items/api_useItem.go +++ b/modules/items/api_useItem.go @@ -61,7 +61,7 @@ func (this *apiComp) Useitem(session comm.IUserSession, req *pb.ItemsUseItemReq) //随机任务 // this.module.ModuleRtask.SendToRtask(session, comm.Rtype21, 1) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype22, utils.ToInt32(sale.Prize[0].T)) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype21, 1), comm.GettaskParam(comm.Rtype22, utils.ToInt32(sale.Prize[0].T))) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype21, 1), comm.GettaskParam(comm.Rtype22, utils.ToInt32(sale.Prize[0].T))) case 4: //自选宝箱 if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil { diff --git a/modules/library/api_usegift.go b/modules/library/api_usegift.go index c03c4ffeb..3879be8f4 100644 --- a/modules/library/api_usegift.go +++ b/modules/library/api_usegift.go @@ -153,7 +153,7 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe } } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype134, utils.ToInt32(_heroObj.Heroid), upLv) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype134, utils.ToInt32(_heroObj.Heroid), upLv)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype134, utils.ToInt32(_heroObj.Heroid), upLv)) } return diff --git a/modules/mline/api_challengeover.go b/modules/mline/api_challengeover.go index 564963919..0642dc564 100644 --- a/modules/mline/api_challengeover.go +++ b/modules/mline/api_challengeover.go @@ -221,6 +221,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype160, allStar) tasks = append(tasks, comm.GettaskParam(comm.Rtype160, allStar)) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) return } diff --git a/modules/modulebase.go b/modules/modulebase.go index a07a7d3f6..5ee7e2470 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -44,12 +44,12 @@ type ModuleBase struct { ModuleTools comm.ITools //工具类 获取一些通用配置 } -//重构模块配置对象 +// 重构模块配置对象 func (this *ModuleBase) NewOptions() (options core.IModuleOptions) { return new(Options) } -//模块初始化接口 +// 模块初始化接口 func (this *ModuleBase) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { this.service = service.(base.IRPCXService) this.module = module @@ -59,7 +59,7 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options return } -//模块启动接口 +// 模块启动接口 func (this *ModuleBase) Start() (err error) { if err = this.ModuleBase.Start(); err != nil { return @@ -138,12 +138,12 @@ func (this *ModuleBase) Start() (err error) { return } -//判断当前环境是本服还还是跨服 +// 判断当前环境是本服还还是跨服 func (this *ModuleBase) IsCross() bool { return db.IsCross() } -//获取跨服标签 +// 获取跨服标签 func (this *ModuleBase) GetCrossTag() string { return db.CrossTag() } @@ -166,7 +166,7 @@ func (this *ModuleBase) PutUserSession(session comm.IUserSession) { return } -//向指定用户发送消息 +// 向指定用户发送消息 func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, uid string) (err error) { user := this.ModuleUser.GetUserSession(uid) if user == nil { @@ -180,7 +180,7 @@ func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Messag return } -//向多个用户发送消息 +// 向多个用户发送消息 func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, uids ...string) (err error) { var ( users map[string]*pb.CacheUser = make(map[string]*pb.CacheUser) @@ -226,7 +226,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa return } -//向多个用户发送消息 +// 向多个用户发送消息 func (this *ModuleBase) SendMsgToCUsers(mainType, subType string, msg proto.Message, users ...*pb.CacheUser) (err error) { var ( gateways map[string]map[string][]string = make(map[string]map[string][]string) @@ -262,7 +262,7 @@ func (this *ModuleBase) SendMsgToCUsers(mainType, subType string, msg proto.Mess return } -//向多个用户发送消息 +// 向多个用户发送消息 func (this *ModuleBase) SendMsgToSession(mainType, subType string, msg proto.Message, users ...comm.IUserSession) (err error) { var ( gateways map[string]map[string][]string = make(map[string]map[string][]string) @@ -335,7 +335,7 @@ func (this *ModuleBase) CheckRes(session comm.IUserSession, res []*cfg.Gameatn) return } -//消耗资源 +// 消耗资源 func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn, bPush bool) (code pb.ErrorCode) { var ( items map[string]int32 // 道具背包 批量处理 @@ -379,7 +379,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn this.Debug("消耗玩家资源", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "attrs", Value: attrs}) if count, ok := attrs[comm.ResDiamond]; ok { // this.ModuleRtask.SendToRtask(session, comm.Rtype104, -count) - this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype104, -count)) + go this.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype104, -count)) } } if len(items) > 0 { @@ -393,7 +393,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn return } -//发放资源 +// 发放资源 func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameatn, bPush bool) (code pb.ErrorCode) { var ( items map[string]int32 // 道具背包 批量处理 @@ -478,7 +478,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat return } -//跨服对象获取数据操作对象 +// 跨服对象获取数据操作对象 func (this *ModuleBase) GetDBNodule(session comm.IUserSession, tableName string, expired time.Duration) (model *db.DBModel, err error) { var conn *db.DBConn if session.GetServiecTag() == this.service.GetTag() { @@ -494,7 +494,7 @@ func (this *ModuleBase) GetDBNodule(session comm.IUserSession, tableName string, return } -//跨服对象获取数据操作对象 +// 跨服对象获取数据操作对象 func (this *ModuleBase) GetCrossDBModel(tableName string, expired time.Duration) (model *db.DBModel, err error) { var ( conn *db.DBConn @@ -512,7 +512,7 @@ func (this *ModuleBase) GetCrossDBModel(tableName string, expired time.Duration) return } -//跨服对象获取数据操作对象 +// 跨服对象获取数据操作对象 func (this *ModuleBase) GetDBModelByUid(uid, tableName string, expired time.Duration) (model *db.DBModel, err error) { var ( stag string @@ -534,7 +534,7 @@ func (this *ModuleBase) GetDBModelByUid(uid, tableName string, expired time.Dura return } -//日志接口 +// 日志接口 func (this *ModuleBase) Debug(msg string, args ...log.Field) { this.options.GetLog().Debug(msg, args...) } @@ -623,7 +623,7 @@ func (this *ModuleBase) PanicWithField(msg string, fields ...log.Field) { } -//发放资源 +// 发放资源 func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gameatn, bPush bool) (code pb.ErrorCode, atno []*pb.UserAtno) { var ( items map[string]int32 // 道具背包 批量处理 diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index afedda2fd..052564c13 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -47,7 +47,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle }, }) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype88, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype88, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype88, 1)) } else { session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{Code: cd}) } diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go index 38723916c..bfc3d3b6e 100644 --- a/modules/moonfantasy/modelDream.go +++ b/modules/moonfantasy/modelDream.go @@ -135,7 +135,7 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) { this.module.modelDream.noticeuserfriend(session, mdata.Id, chat) session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerPush{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster}) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype87, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype87, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype87, 1)) return } @@ -189,7 +189,7 @@ func (this *modelDreamComp) triggerbyid(session comm.IUserSession, boosid string this.module.modelDream.noticeuserfriend(session, mdata.Id, chat) session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerPush{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster}) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype87, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype87, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype87, 1)) return } diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 14edc6c0a..0c240ab7c 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -155,6 +155,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal // this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype58, 1), comm.GettaskParam(comm.Rtype59, pagoda.PagodaId)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype58, 1), comm.GettaskParam(comm.Rtype59, pagoda.PagodaId)) return } diff --git a/modules/parkour/api_invitehandle.go b/modules/parkour/api_invitehandle.go index 1a6198a1f..6faadbc21 100644 --- a/modules/parkour/api_invitehandle.go +++ b/modules/parkour/api_invitehandle.go @@ -42,10 +42,10 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi code = pb.ErrorCode_ParkourMemberFull return } - if req.State == 1 { + if req.State == 3 { ok = false for i, v := range tean.Invite { - if v.Uid == session.GetUserId() && !configure.Now().Before(time.Unix(v.Expired, 0)) { //邀请未过期 + if v.Uid == session.GetUserId() && configure.Now().Before(time.Unix(v.Expired, 0)) { //邀请未过期 invite = v index = int32(i) ok = true @@ -64,6 +64,7 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi code = pb.ErrorCode_ConfigNoFound return } + users = append(users, invite.Uid) member = &pb.DBRaceMember{Uid: invite.Uid, Name: invite.Name, Avatar: invite.Avatar, Lv: invite.Lv, Mount: info.Dfmount, Hp: mount.Hp} tean.Captainid = tean.Uid tean.State = pb.RaceTeamState_teaming @@ -93,6 +94,6 @@ func (this *apiComp) InviteHandle(session comm.IUserSession, req *pb.ParkourInvi &pb.ParkourInviteNoticePush{Team: tean, State: 3}, tean.Captainid) } - session.SendMsg(string(this.module.GetType()), "invite", &pb.ParkourInviteHandleResp{IsSucc: true}) + session.SendMsg(string(this.module.GetType()), "invitehandle", &pb.ParkourInviteHandleResp{IsSucc: true}) return } diff --git a/modules/parkour/api_jointeam.go b/modules/parkour/api_jointeam.go index daf9d08f7..7f06d5a07 100644 --- a/modules/parkour/api_jointeam.go +++ b/modules/parkour/api_jointeam.go @@ -8,6 +8,10 @@ import ( //参数校验 func (this *apiComp) JoinTeamCheck(session comm.IUserSession, req *pb.ParkourJoinTeamReq) (code pb.ErrorCode) { + if session.GetUserId() == req.Uid { + code = pb.ErrorCode_ReqParameterError + } + return } @@ -36,7 +40,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam } if len(info.Member) > 3 { - code = pb.ErrorCode_ReqParameterError + code = pb.ErrorCode_ParkourMemberFull return } if tean, err = this.module.parkourComp.queryinfo(req.Uid); err != nil { @@ -58,7 +62,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam code = pb.ErrorCode_ConfigNoFound return } - member = &pb.DBRaceMember{Uid: session.GetUserId(), Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: tean.Dfmount, Hp: mount.Hp} + member = &pb.DBRaceMember{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: tean.Dfmount, Hp: mount.Hp} tean.Captainid = tean.Uid tean.State = pb.RaceTeamState_teaming tean.Member = append(tean.Member, member) @@ -71,7 +75,7 @@ func (this *apiComp) JoinTeam(session comm.IUserSession, req *pb.ParkourJoinTeam return } user := this.module.ModuleUser.GetUser(session.GetUserId()) - member = &pb.DBRaceMember{Uid: session.GetUserId(), Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: info.Dfmount, Hp: mount.Hp} + member = &pb.DBRaceMember{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv, Mount: info.Dfmount, Hp: mount.Hp} tean.Member = append(tean.Member, member) if err = this.module.parkourComp.Change(session.GetUserId(), map[string]interface{}{ "state": tean.State, diff --git a/modules/parkour/api_racematch.go b/modules/parkour/api_racematch.go index 18400c836..6246c336f 100644 --- a/modules/parkour/api_racematch.go +++ b/modules/parkour/api_racematch.go @@ -3,6 +3,7 @@ package parkour import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" ) //参数校验 @@ -17,6 +18,8 @@ func (this *apiComp) RaceMatchCheck(session comm.IUserSession, req *pb.ParkourRa func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMatchReq) (code pb.ErrorCode, data *pb.ErrorData) { var ( team *pb.DBParkour + tuser *pb.DBUser + mount *cfg.GameBuzkashiMountData users []string err error ) @@ -27,10 +30,31 @@ func (this *apiComp) RaceMatch(session comm.IUserSession, req *pb.ParkourRaceMat code = pb.ErrorCode_DBError return } - if team.Captainid != session.GetUserId() { + if team.Captainid != "" && team.Captainid != session.GetUserId() { code = pb.ErrorCode_ReqParameterError return } + if team.Captainid == "" { //为组队情况 + team.Captainid = team.Uid + team.State = pb.RaceTeamState_teaming + if tuser = this.module.ModuleUser.GetUser(session.GetUserId()); tuser == nil { + code = pb.ErrorCode_SystemError + return + } + if mount, err = this.module.configure.getGameBuzkashiMount(team.Dfmount); err != nil { + code = pb.ErrorCode_ConfigNoFound + return + } + team.Member = append(team.Member, &pb.DBRaceMember{Uid: tuser.Uid, Name: tuser.Name, Avatar: tuser.Avatar, Lv: tuser.Lv, Mount: team.Dfmount, Hp: mount.Hp}) + if err = this.module.parkourComp.Change(team.Captainid, map[string]interface{}{ + "state": team.State, + "captainid": team.Captainid, + "member": team.Member, + }); err != nil { + code = pb.ErrorCode_DBError + return + } + } if err = this.module.match(team); err != nil { code = pb.ErrorCode_DBError diff --git a/modules/parkour/api_viewplayer.go b/modules/parkour/api_viewplayer.go index 350088c11..df8a1d9fe 100644 --- a/modules/parkour/api_viewplayer.go +++ b/modules/parkour/api_viewplayer.go @@ -18,7 +18,9 @@ func (this *apiComp) ViewPlayer(session comm.IUserSession, req *pb.ParkourViewPl if code = this.ViewPlayerCheck(session, req); code != pb.ErrorCode_Success { return } - + resp = &pb.ParkourViewPlayerResp{ + Player: make([]*pb.ParkourData, 0), + } for _, uid := range req.Uid { if u := this.module.ModuleUser.GetUser(uid); u != nil { { diff --git a/modules/parkour/module.go b/modules/parkour/module.go index 276af9215..ed423ec99 100644 --- a/modules/parkour/module.go +++ b/modules/parkour/module.go @@ -148,11 +148,12 @@ func (this *Parkour) createbattle(ctx context.Context, req *pb.RPCParkourMatchSu v.Ready = true } } + battle.BuleMember = req.Bule + for _, v := range battle.Session { sessions = append(sessions, v) } - battle.BuleMember = req.Bule if err = this.raceComp.addrace(race); err != nil { return } @@ -406,17 +407,6 @@ func (this *Parkour) useroffline(uid, sessionid string) { } if info.State == pb.RaceTeamState_teaming { if info.Captainid == uid { - info.Invite = info.Invite[:0] - info.Member = info.Member[:0] - if err = this.parkourComp.Change(uid, map[string]interface{}{ - "captainid": "", - "state": 0, - "Invite": info.Invite, - "member": info.Member, - }); err != nil { - this.Error("用户离线! 处理数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) - return - } users = make([]string, 0) for _, v := range info.Member { if v.Uid != uid && !v.Isai { @@ -430,6 +420,17 @@ func (this *Parkour) useroffline(uid, sessionid string) { } } } + info.Invite = info.Invite[:0] + info.Member = info.Member[:0] + if err = this.parkourComp.Change(uid, map[string]interface{}{ + "captainid": "", + "state": 0, + "Invite": info.Invite, + "member": info.Member, + }); err != nil { + this.Error("用户离线! 处理数据", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) + return + } if len(users) > 0 { if err = this.SendMsgToUsers(string(comm.ModulePvp), "teamdisbandnotice", &pb.ParkourTeamDisbandNoticePush{}, users...); err != nil { this.Errorln(err) diff --git a/modules/practice/api_practice.go b/modules/practice/api_practice.go index fd46dda40..55b274102 100644 --- a/modules/practice/api_practice.go +++ b/modules/practice/api_practice.go @@ -102,7 +102,7 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.PracticePractic "knapsack": room.Knapsack, filed: pillar, }) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype149, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype149, 1)) session.SendMsg(string(this.module.GetType()), "practice", &pb.PracticePracticeResp{Pillar: pillar}) return } diff --git a/modules/practice/api_receive.go b/modules/practice/api_receive.go index 18dbacf6c..1cafb3e25 100644 --- a/modules/practice/api_receive.go +++ b/modules/practice/api_receive.go @@ -246,7 +246,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.PracticeReceiveR this.module.PutUserSession(_session) } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype135, minutes)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype135, minutes)) session.SendMsg(string(this.module.GetType()), "receive", &pb.PracticeReceiveResp{Pillar: pillar, Knapsack: room.Knapsack}) return } diff --git a/modules/practice/api_unLock.go b/modules/practice/api_unLock.go index fa6f01b96..57a308784 100644 --- a/modules/practice/api_unLock.go +++ b/modules/practice/api_unLock.go @@ -61,7 +61,7 @@ func (this *apiComp) UnLock(session comm.IUserSession, req *pb.PracticeUnLockReq filed: pillar, "pillarf": room.Pillarf, }) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype152, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype152, 1)) session.SendMsg(string(this.module.GetType()), "unlock", &pb.PracticeUnLockResp{Info: room}) return } diff --git a/modules/rtask/model_record.go b/modules/rtask/model_record.go index e016d35b0..0503a1689 100644 --- a/modules/rtask/model_record.go +++ b/modules/rtask/model_record.go @@ -16,6 +16,7 @@ type ModelRtaskRecord struct { modules.MCompModel moduleRtask *ModuleRtask service core.IService + record *pb.DBRtaskRecord } func (this *ModelRtaskRecord) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { diff --git a/modules/rtask/model_rtask.go b/modules/rtask/model_rtask.go index 1bcbc318f..eaf4b0f37 100644 --- a/modules/rtask/model_rtask.go +++ b/modules/rtask/model_rtask.go @@ -89,7 +89,7 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo } //验证限定条件 - var condi *rtaskCondi + var condi *rtaskCondHandle cond, ok := this.moduleRtask.handleMap.Load(condiId) if !ok { rcs := this.moduleRtask.getHandle(comm.TaskType(conf.Type)) @@ -100,7 +100,7 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo } } - if condi, ok = cond.(*rtaskCondi); !ok { + if condi, ok = cond.(*rtaskCondHandle); !ok { err = fmt.Errorf("condiType err") return } diff --git a/modules/rtask/module.go b/modules/rtask/module.go index b9b9e5534..f8904c104 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -12,18 +12,21 @@ import ( "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "go_dreamfactory/utils" "sync" "github.com/pkg/errors" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" ) var _ comm.IRtask = (*ModuleRtask)(nil) // 限定条件 -type rtaskCondi struct { +type rtaskCondHandle struct { condId int32 //任务条件配置ID verify verifyHandle //校验任务条件 find condiFindHandle //检索任务条件 @@ -71,15 +74,15 @@ func (this *ModuleRtask) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondi) { +func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHandle) { this.handleMap.Store(condiId, condi) } -func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { +func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondHandle) { for _, v := range this.configure.getRtaskCondis(int32(tt)) { switch tt { case comm.Rtype1: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verfiyRtype1, @@ -88,7 +91,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype2: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype2, @@ -97,7 +100,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype3: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype3, @@ -106,7 +109,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype4: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype4, @@ -115,7 +118,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype5: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype5, @@ -124,7 +127,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype6: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype6, @@ -133,7 +136,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype8: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verfiyRtype8, @@ -142,7 +145,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype9: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verfiyRtype9, @@ -151,7 +154,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype10: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verfiyRtype10, @@ -160,7 +163,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype11, comm.Rtype84, comm.Rtype85: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.lessEqualFirstParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, @@ -170,7 +173,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype18: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.greatEqualFirstParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, @@ -187,7 +190,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { comm.Rtype96, comm.Rtype105, comm.Rtype128, comm.Rtype130, comm.Rtype131, comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, comm.Rtype147, comm.Rtype149, comm.Rtype153, comm.Rtype154, comm.Rtype155, comm.Rtype156: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.lessEqualFirstParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, @@ -196,7 +199,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype50, comm.Rtype73: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.lessEqualFirstParam, verify: this.modelRtaskRecord.verifyFromDb, @@ -205,7 +208,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype20: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype20, @@ -215,7 +218,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype22, comm.Rtype109: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtaskRecord.verifyFirstEqualParam, @@ -225,7 +228,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { condis = append(condis, condi) this.registerVerifyHandle(v.Id, condi) case comm.Rtype63: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalFirstParam, verify: this.modelRtask.verifyRtype63, @@ -236,7 +239,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { case comm.Rtype16, comm.Rtype17, comm.Rtype35, comm.Rtype44, comm.Rtype59, comm.Rtype61: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.equalParams, verify: this.modelRtaskRecord.verifyFromDb, @@ -251,7 +254,7 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { comm.Rtype46, comm.Rtype47, comm.Rtype48, comm.Rtype49, comm.Rtype52, comm.Rtype55, comm.Rtype56, comm.Rtype65, comm.Rtype66, comm.Rtype67, comm.Rtype68, comm.Rtype70, comm.Rtype140: - condi := &rtaskCondi{ + condi := &rtaskCondHandle{ condId: v.Id, find: this.modelRtaskRecord.lessThanParams, verify: this.modelRtaskRecord.verifyFromDb, @@ -269,7 +272,8 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) { // 处理触发的任务 func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { uid := session.GetUserId() - var condis []*rtaskCondi + + var handles []*rtaskCondHandle if this.IsCross() { //随机任务 @@ -285,18 +289,18 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com return } - condis = this.getHandle(rtaskType) + handles = this.getHandle(rtaskType) // update - for _, v := range condis { - conf, err := this.configure.getRtaskTypeById(v.condId) + for _, handle := range handles { + conf, err := this.configure.getRtaskTypeById(handle.condId) if err != nil { - log.Debug("任务配置未找到", log.Field{Key: "condId", Value: v.condId}) + log.Debug("任务配置未找到", log.Field{Key: "condId", Value: handle.condId}) code = pb.ErrorCode_RtaskCondiNoFound return } - if v.update != nil { - if err := v.update(uid, conf, params...); err != nil { + if handle.update != nil { + if err := handle.update(uid, conf, params...); err != nil { log.Errorf("update task:%v", err) code = pb.ErrorCode_DBError return @@ -349,9 +353,6 @@ func (this *ModuleRtask) processOneTask(session comm.IUserSession, rtaskType com } func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) { - this.Debug("任务处理", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "params", Value: taskParams}) session, ok := this.GetUserSession(uid) if !ok { return @@ -363,13 +364,40 @@ func (this *ModuleRtask) TriggerTask(uid string, taskParams ...*comm.TaskParam) this.Error("TriggerTask userlock err!", log.Field{Key: "err", Value: err.Error()}) } defer lock.Unlock() - for _, tp := range taskParams { - if code := this.processOneTask(session, tp.TT, tp.Params...); code != pb.ErrorCode_Success { + record := &pb.DBRtaskRecord{Uid: uid} + if err := this.modelRtaskRecord.Get(uid, record); err != nil { + if err == mongo.ErrNoDocuments { + record.Id = primitive.NewObjectID().Hex() + record.Ctime = configure.Now().Unix() + if err := this.modelRtaskRecord.Add(uid, record); err != nil { + return + } } + } + + this.modelRtaskRecord.record = record + + for _, tp := range taskParams { + // this.Debug("任务触发", + // log.Field{Key: "uid", Value: uid}, + // log.Field{Key: "type", Value: tp.TT}, + // log.Field{Key: "params", Value: tp.Params}) + + if code := this.processOneTask(session, tp.TT, tp.Params...); code != pb.ErrorCode_Success { + // this.Error("任务处理", log.Field{Key: "uid", Value: uid}, log.Field{Key: "code", Value: code}) + } + session.Push() comm.PuttaskParam(tp) } + + update := map[string]interface{}{ + "vals": record.Vals, + } + + this.modelRtaskRecord.Change(uid, update) + this.PutUserSession(session) return } diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index d598854f2..30cd56045 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -2,14 +2,9 @@ package rtask import ( - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" - - "github.com/pkg/errors" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" ) // 覆盖更新 @@ -19,93 +14,79 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond return err } - record := &pb.DBRtaskRecord{Uid: uid} - if err := this.Get(uid, record); err != nil { - if err == mongo.ErrNoDocuments { - record.Id = primitive.NewObjectID().Hex() - record.Ctime = configure.Now().Unix() - if err := this.Add(uid, record); err != nil { - return errors.Wrapf(err, "创建玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) - } - } else { - return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) - } + // record := &pb.DBRtaskRecord{Uid: uid} + // if err := this.Get(uid, record); err != nil { + // if err == mongo.ErrNoDocuments { + // record.Id = primitive.NewObjectID().Hex() + // record.Ctime = configure.Now().Unix() + // if err := this.Add(uid, record); err != nil { + // return errors.Wrapf(err, "创建玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + // } + // } else { + // return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + // } + // } + + if this.record.Vals == nil { + this.record.Vals = make(map[int32]*pb.RtaskData) } - if record.Vals == nil { - record.Vals = make(map[int32]*pb.RtaskData) - } - - if v, ok := record.Vals[cfg.Id]; ok { - this.moduleRtask.Debug("覆盖更新前", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "v", Value: v}, - log.Field{Key: "paramLen", Value: paramLen}, - log.Field{Key: "vals", Value: vals}, - log.Field{Key: "cfgId", Value: cfg.Id}, - ) + if v, ok := this.record.Vals[cfg.Id]; ok { v.Data = hasUpdateData(paramLen, v, vals...) - this.moduleRtask.Debug("覆盖更新后", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "v", Value: v.Data}, - log.Field{Key: "paramLen", Value: paramLen}, - log.Field{Key: "vals", Value: vals}, - log.Field{Key: "cfgId", Value: cfg.Id}, - ) - if len(v.Data) > 0 { - update := map[string]interface{}{ - "vals": record.Vals, - } - if err = this.Change(uid, update); err != nil { - this.moduleRtask.Error("更新失败", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "update", Value: update}) - return - } - } + // if len(v.Data) > 0 { + // update := map[string]interface{}{ + // "vals": record.Vals, + // } + // if err = this.Change(uid, update); err != nil { + // this.moduleRtask.Error("更新失败", + // log.Field{Key: "uid", Value: uid}, + // log.Field{Key: "update", Value: update}) + // return + // } + // } } else { data := &pb.RtaskData{ Rtype: cfg.Type, Data: toMap(vals...), Timestamp: configure.Now().Unix(), } - record.Vals[cfg.Id] = data + this.record.Vals[cfg.Id] = data - update := map[string]interface{}{ - "vals": record.Vals, - } + // update := map[string]interface{}{ + // "vals": record.Vals, + // } - if err = this.Change(uid, update); err != nil { - this.moduleRtask.Error("更新失败", - log.Field{Key: "uid", Value: uid}, - log.Field{Key: "update", Value: update}) - return - } + // if err = this.Change(uid, update); err != nil { + // this.moduleRtask.Error("更新失败", + // log.Field{Key: "uid", Value: uid}, + // log.Field{Key: "update", Value: update}) + // return + // } } return } // 累计更新 - 招募等 func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) { - record := &pb.DBRtaskRecord{Uid: uid} - err = this.Get(uid, record) - if err != nil { - if err == mongo.ErrNoDocuments { - record.Id = primitive.NewObjectID().Hex() - record.Ctime = configure.Now().Unix() - if err := this.Add(uid, record); err != nil { - return errors.Wrapf(err, "创建玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) - } - } else { - return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) - } - } + // record := &pb.DBRtaskRecord{Uid: uid} + // err = this.Get(uid, record) + // if err != nil { + // if err == mongo.ErrNoDocuments { + // record.Id = primitive.NewObjectID().Hex() + // record.Ctime = configure.Now().Unix() + // if err := this.Add(uid, record); err != nil { + // return errors.Wrapf(err, "创建玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + // } + // } else { + // return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + // } + // } - if record.Vals == nil { - record.Vals = make(map[int32]*pb.RtaskData) + if this.record.Vals == nil { + this.record.Vals = make(map[int32]*pb.RtaskData) } //查找任务数据 - if v, ok := record.Vals[cfg.Id]; ok { + if v, ok := this.record.Vals[cfg.Id]; ok { newArr := make([]int32, len(vals)) copy(newArr, vals) srcCount := v.Data[0] @@ -113,20 +94,20 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData v.Data = toMap(newArr...) v.Timestamp = configure.Now().Unix() - update := map[string]interface{}{ - "vals": record.Vals, - } - err = this.Change(uid, update) + // update := map[string]interface{}{ + // "vals": record.Vals, + // } + // err = this.Change(uid, update) } else { - record.Vals[cfg.Id] = &pb.RtaskData{ + this.record.Vals[cfg.Id] = &pb.RtaskData{ Data: toMap(vals...), Rtype: cfg.Type, Timestamp: configure.Now().Unix(), } - update := map[string]interface{}{ - "vals": record.Vals, - } - err = this.Change(uid, update) + // update := map[string]interface{}{ + // "vals": record.Vals, + // } + // err = this.Change(uid, update) } return } diff --git a/modules/shop/api_buy.go b/modules/shop/api_buy.go index f765f6b93..9d473f9ba 100644 --- a/modules/shop/api_buy.go +++ b/modules/shop/api_buy.go @@ -133,7 +133,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb } } if len(tasks) > 0 { - this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...) } session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{IsSucc: true}) diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index 6185b7e7e..831d6509a 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -157,7 +157,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) } } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype105, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype105, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype105, 1)) this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{"refreshnumgoldShop": shopData.RefreshnumgoldShop, "refreshtimegoldShop": shopData.RefreshtimegoldShop, filed: sdata}) } else if !req.IsManualRefresh { // refresh := int(this.module.privilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType2)) @@ -200,7 +200,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) goods = transGoods(items, sdata) this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: sdata}) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype105, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype105, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype105, 1)) } else { //返回以前的商品列表 if items, err = this.module.configure.GetShopItemsConfigureByIds(sdata.Items...); err != nil { code = pb.ErrorCode_SystemError diff --git a/modules/sociaty/api_cross_agree.go b/modules/sociaty/api_cross_agree.go index f3b0d2d6e..0a7c7569b 100644 --- a/modules/sociaty/api_cross_agree.go +++ b/modules/sociaty/api_cross_agree.go @@ -55,7 +55,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( // 触发任务条件 // this.module.ModuleRtask.SendToRtask(session, comm.Rtype109, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype109, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype109, 1)) // 发邮件 if err := this.module.modelSociaty.sendMail("GuildApproved", []string{sociaty.Name}, []string{req.Uid}); err != nil { this.module.Error("发送邮件 模板ID:GuildApproved", diff --git a/modules/sociaty/api_cross_apply.go b/modules/sociaty/api_cross_apply.go index 144aa4655..c8f52495e 100644 --- a/modules/sociaty/api_cross_apply.go +++ b/modules/sociaty/api_cross_apply.go @@ -96,7 +96,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( if !isCheck { // 触发任务条件 // this.module.ModuleRtask.SendToRtask(session, comm.Rtype109, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype109, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype109, 1)) } rsp := &pb.SociatyApplyResp{ Uid: uid, diff --git a/modules/timer/parkour.go b/modules/timer/parkour.go index 3a479595a..010bbfba9 100644 --- a/modules/timer/parkour.go +++ b/modules/timer/parkour.go @@ -197,6 +197,7 @@ func (this *ParkourComp) cancel(ctx context.Context, req *pb.RPCParkourCancelMat //定时匹配处理 func (this *ParkourComp) timer() { + this.module.Errorf("捕羊大赛 定时匹配,%d", this.total) if this.total == 0 { return } @@ -338,7 +339,7 @@ func (this *ParkourComp) timer() { reduser = append(reduser, this.teams[v]...) } for _, v := range bule { - buleuser = append(reduser, this.teams[v]...) + buleuser = append(buleuser, this.teams[v]...) } if len(users)+rednum+bulenum < 6 { @@ -357,6 +358,7 @@ func (this *ParkourComp) timer() { } else { v.Name = user.Name v.Avatar = user.Avatar + v.Lv = user.Lv } } } @@ -372,6 +374,7 @@ func (this *ParkourComp) timer() { } else { v.Name = user.Name v.Avatar = user.Avatar + v.Lv = user.Lv } } } diff --git a/modules/troll/api_buyorsell.go b/modules/troll/api_buyorsell.go index 15c8b4add..63d8088a7 100644 --- a/modules/troll/api_buyorsell.go +++ b/modules/troll/api_buyorsell.go @@ -169,6 +169,6 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell } // this.module.ModuleRtask.SendToRtask(session, comm.Rtype153, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype153, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype153, 1)) return } diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 3a72330a2..49f7ccc93 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -121,7 +121,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c } if req.Figure != 0 { - this.module.ModuleRtask.TriggerTask(uid, comm.GettaskParam(comm.Rtype72, 1)) + go this.module.ModuleRtask.TriggerTask(uid, comm.GettaskParam(comm.Rtype72, 1)) } this.mail.SendMailByCid(session, comm.Welcomemail, nil) diff --git a/modules/user/api_login.go b/modules/user/api_login.go index cc59cc9ea..df0ecebd6 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -133,7 +133,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod this.module.RecoverUserPsStart(user.Uid) // 日常登录任务 // this.module.ModuleRtask.SendToRtask(session, comm.Rtype8, 1) - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype8, 1)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype8, 1)) this.module.ModulePrivilege.CheckDailyPrivilegeMail(session) rsp.Data = user diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index c0484b966..34dfd2b75 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -152,6 +152,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal } } } - this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), szTask...) return } diff --git a/modules/worldtask/api_battlefinish.go b/modules/worldtask/api_battlefinish.go index 9bb14f0c3..d43937161 100644 --- a/modules/worldtask/api_battlefinish.go +++ b/modules/worldtask/api_battlefinish.go @@ -11,7 +11,7 @@ import ( // 战斗结束的请求 func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) { - if req.GroupId <= 0 || req.CondiId <= 0 || req.BattleConfId <= 0 || req.TaskId <= 0 || req.Report == nil { + if req.GroupId <= 0 || req.BattleConfId <= 0 || req.TaskId <= 0 || req.Report == nil { this.module.Error("世界任务战斗结束参数错误", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "params", Value: req.String()}, @@ -70,7 +70,6 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa if ibattle, ok := battleModule.(comm.IBattle); ok { var isWin bool if code, isWin = ibattle.CheckBattleReport(session, req.Report); code == pb.ErrorCode_Success { - if isWin { if battleConf, ok := this.module.worldBattleConf.GetDataMap()[req.BattleConfId]; ok { if code := this.module.DispenseRes(session, []*cfg.Gameatn{battleConf.Playexp}, true); code != pb.ErrorCode_Success { @@ -80,17 +79,18 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa ) } else { //触发任务 - this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype70, 1, req.BattleConfId)) + go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype70, 1, req.BattleConfId)) } } } if userTask.CurrentTask == nil { userTask.CurrentTask = make(map[int32]*pb.Worldtask) } + if _, ok := utils.Findx(userTask.CurrentTask[req.GroupId].CondiIds, req.CondiId); !ok { userTask.CurrentTask[req.GroupId].CondiIds = append(userTask.CurrentTask[req.GroupId].CondiIds, req.CondiId) } - + update := map[string]interface{}{ "currentTask": userTask.CurrentTask, } @@ -105,6 +105,7 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa TaskId: req.TaskId, CondiIds: userTask.CurrentTask[req.GroupId].CondiIds, }) + } this.module.Debug("校验战报", log.Field{Key: "uid", Value: session.GetUserId()},