From 56fe04cbf7080f83a10593814e3c52f4d19c8e57 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 16 Mar 2023 15:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96=20=E5=87=8F=E5=B0=91=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=AC=A1=E6=95=B0=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/equipment/api_equip.go | 2 +- modules/hero/api_strengthenUpStar.go | 2 +- modules/hero/model_hero.go | 2 +- modules/hero/module.go | 30 ++++++++++++++++------------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 8fbcece0d..71ec0907e 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -169,7 +169,7 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) code = pb.ErrorCode_SystemError return } - tasks = append(tasks, comm.GettaskParam(comm.Rtype5, 1, utils.ToInt32(hero.HeroID), equipNum)) + tasks = append(tasks, comm.GettaskParam(comm.Rtype5, 1, equipNum, utils.ToInt32(hero.HeroID))) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum) for k, v := range equipStr { tasks = append(tasks, comm.GettaskParam(comm.Rtype41, 1, utils.ToInt32(hero.HeroID), v, k)) diff --git a/modules/hero/api_strengthenUpStar.go b/modules/hero/api_strengthenUpStar.go index c83f3f09a..f434a9174 100644 --- a/modules/hero/api_strengthenUpStar.go +++ b/modules/hero/api_strengthenUpStar.go @@ -86,7 +86,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr // 推送 世界任务消息 var szTask []*comm.TaskParam - szTask = append(szTask, comm.GettaskParam(comm.Rtype6, utils.ToInt32(_hero.HeroID), _hero.Star)) + szTask = append(szTask, comm.GettaskParam(comm.Rtype6, _hero.Star, utils.ToInt32(_hero.HeroID))) szTask = append(szTask, comm.GettaskParam(comm.Rtype25, 1, utils.ToInt32(_hero.HeroID), _hero.Star)) if _hero.Star == 4 { diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index ded2e0639..83082d5cd 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -576,7 +576,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex var szTask []*comm.TaskParam szTask = append(szTask, comm.GettaskParam(comm.Rtype147, utils.ToInt32(hero.HeroID), curLv-preLv)) szTask = append(szTask, comm.GettaskParam(comm.Rtype113, utils.ToInt32(hero.HeroID), curLv-preLv)) - szTask = append(szTask, comm.GettaskParam(comm.Rtype4, utils.ToInt32(hero.HeroID), hero.Lv)) + szTask = append(szTask, comm.GettaskParam(comm.Rtype4, hero.Lv, utils.ToInt32(hero.HeroID))) szTask = append(szTask, comm.GettaskParam(comm.Rtype23, 1, hero.Star, hero.Lv)) szTask = append(szTask, comm.GettaskParam(comm.Rtype24, 1)) szTask = append(szTask, comm.GettaskParam(comm.Rtype29, 1, hero.Lv, utils.ToInt32(hero.HeroID))) diff --git a/modules/hero/module.go b/modules/hero/module.go index 89a1647eb..fa07f2299 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -1,6 +1,7 @@ package hero import ( + "context" "crypto/rand" "go_dreamfactory/comm" "go_dreamfactory/lego/core" @@ -944,31 +945,34 @@ func (this *Hero) QueryCrossMultipleHeroinfo(oid []string) (hero []*pb.DBHero, e if err1 != nil { continue } + result := make([]bson.M, 0) + for _, v := range oid { - sr := conn.Mgo.FindOne(comm.TableHero, bson.M{ - "_id": v, - }) + result = append(result, bson.M{"_id": v}) + } + sr, _ := conn.Mgo.Find(comm.TableHero, bson.M{"$or": result}) + for sr.Next(context.TODO()) { _hero := &pb.DBHero{} if err = sr.Decode(_hero); err != nil { this.modelHero.moduleHero.Errorf("find hero error: %v", err) } hero = append(hero, _hero) } - return } } else { // 不是跨服就查本服 注意 这个接口是给跨服玩法调用 理论上这个分支是不会执行的 + + result := make([]bson.M, 0) for _, v := range oid { - if res := this.modelHero.DB.FindOne(comm.TableHero, bson.M{ - "_id": v, - }); res == nil { - _hero := &pb.DBHero{} - if err = res.Decode(_hero); err != nil { - this.modelHero.moduleHero.Errorf("find hero error: %v", err) - return - } - hero = append(hero, _hero) + result = append(result, bson.M{"_id": v}) + } + sr, _ := this.modelHero.DB.Find(comm.TableHero, bson.M{"$or": result}) + for sr.Next(context.TODO()) { + _hero := &pb.DBHero{} + if err = sr.Decode(_hero); err != nil { + this.modelHero.moduleHero.Errorf("find hero error: %v", err) } + hero = append(hero, _hero) } }