diff --git a/modules/library/comp_configure.go b/modules/library/comp_configure.go index 29e314f57..2e6608960 100644 --- a/modules/library/comp_configure.go +++ b/modules/library/comp_configure.go @@ -31,7 +31,7 @@ type configureComp struct { favorability map[string]*cfg.GameFavorabilityData favorLvExp map[string][]int32 // key 英雄id value 每级升级所需要的经验值 friend map[int64][]*cfg.GameFriendsData - heroFetter map[string][]int32 // key 英雄id value 羁绊id + heroFetter map[string]map[int32]int32 // key 英雄id value 羁绊id } @@ -72,12 +72,15 @@ func (this *configureComp) SetFriendData() { this.hlock.Lock() defer this.hlock.Unlock() this.friend = make(map[int64][]*cfg.GameFriendsData, 0) - this.heroFetter = make(map[string][]int32) + this.heroFetter = make(map[string]map[int32]int32) if _configure, ok := v.(*cfg.GameFriends); ok { for _, v1 := range _configure.GetDataList() { key := int64(v1.FriendId)<<8 + int64(v1.FriendsLv) this.friend[key] = append(this.friend[key], v1) - this.heroFetter[v1.Hid] = append(this.heroFetter[v1.Hid], v1.FriendId) + if _, ok := this.heroFetter[v1.Hid]; !ok { + this.heroFetter[v1.Hid] = make(map[int32]int32, 0) + } + this.heroFetter[v1.Hid][v1.FriendId] = 1 } } } else { @@ -92,7 +95,7 @@ func (this *configureComp) GetFriendData(id int32, lv int32) []*cfg.GameFriendsD } // 通过英雄获取当前英雄的所有羁绊ID -func (this *configureComp) GetHeroFetterID(hid string) []int32 { +func (this *configureComp) GetHeroFetterID(hid string) map[int32]int32 { return this.heroFetter[hid] } diff --git a/modules/library/module.go b/modules/library/module.go index af1c08aa6..181d7e355 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -118,7 +118,7 @@ func (this *Library) CheckFetter(uid string, hid string) (dbLibrary []*pb.DBLibr } else { // 有这条羁绊数据 if _, ok := list.Herofetter[hid]; !ok { - if _d := this.CheckHeroFetter(uid, hid); _d == nil { + if _d := this.CheckHeroFetter(uid, hid); _d != nil { list.Herofetter[hid] = _d.Id fetter = append(fetter, _d) } @@ -180,7 +180,7 @@ func (this *Library) CheckHeroFetter(uid string, hid string) (obj *pb.DBHeroFett } if !bFound { // 创建一条英雄数据 if obj, err = this.createHeroFetter(uid, hid); err != nil { - obj = nil + return } }