From 3f9eace9d8d7d15266f37ede31a1fca033df7e14 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 6 Feb 2023 16:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/configure_comp.go | 13 +++++++++---- modules/mline/comp_configure.go | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 1e1bfd404..d49e8ff80 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" + "sync" "go_dreamfactory/lego/core" "go_dreamfactory/utils" @@ -39,9 +40,9 @@ const ( ///配置管理组件 type configureComp struct { modules.MCompConfigure + hlock sync.RWMutex drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级 - //map["base_pool1"]map[3]*cfg.Game_drawCardData - awakenMap map[int64]*cfg.GameHeroAwakenData + awakenMap map[int64]*cfg.GameHeroAwakenData starMap map[int64]*cfg.GameHeroStarupData module *Hero @@ -76,6 +77,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this.awakenMap = make(map[int64]*cfg.GameHeroAwakenData, 0) configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, func() { if v, err := this.GetConfigure(hero_awaken); err == nil { + this.hlock.Lock() + defer this.hlock.Unlock() if _configure, ok := v.(*cfg.GameHeroAwaken); ok { for _, v := range _configure.GetDataList() { this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v @@ -93,6 +96,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp configure.RegisterConfigure(hero_starup, cfg.NewGameHeroStarup, func() { if v, err := this.GetConfigure(hero_starup); err == nil { if _configure, ok := v.(*cfg.GameHeroStarup); ok { + this.hlock.Lock() + defer this.hlock.Unlock() for _, v := range _configure.GetDataList() { this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v } @@ -115,8 +120,8 @@ func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.Game // 获取当前英雄最高星级 func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 { var star int32 - for star = curStar; ; star++ { - if _, ok := this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)]; !ok { + for star = curStar; star < 100; star++ { + if _, ok := this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star+1)]; !ok { return star } } diff --git a/modules/mline/comp_configure.go b/modules/mline/comp_configure.go index 6d71dc235..d89060acb 100644 --- a/modules/mline/comp_configure.go +++ b/modules/mline/comp_configure.go @@ -5,7 +5,6 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" - "sync" ) const ( @@ -18,7 +17,6 @@ const ( type configureComp struct { modules.MCompConfigure module *Mline - hlock sync.RWMutex } //组件初始化接口