配置锁
This commit is contained in:
parent
904e59475d
commit
3f9eace9d8
@ -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,8 +40,8 @@ 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
|
||||
|
||||
starMap map[int64]*cfg.GameHeroStarupData
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
|
Loading…
Reference in New Issue
Block a user