This commit is contained in:
aozhiwei 2021-01-14 15:12:40 +08:00
parent c7ef4d6d23
commit 577345080d
2 changed files with 24 additions and 24 deletions

View File

@ -17,8 +17,8 @@ type GameConf struct {
sceneWhiteList map[string]int32
sceneWhiteListMutex sync.RWMutex
launchBlackList map[string]int32
launchBlackListMutex sync.RWMutex
launchWhiteList map[string]int32
launchWhiteListMutex sync.RWMutex
totalPassTimes int64
totalBlockTimes int64
@ -30,8 +30,8 @@ type GameConf struct {
totalSafeZonePassTimes int64
safeZonePassTimes int64
totalLaunchBlackListBlockTimes int64
launchBlackListBlockTimes int64
totalLaunchWhiteListBlockTimes int64
launchWhiteListBlockTimes int64
totalUnSafeZoneBlockTimes int64
unSafeZoneBlockTimes int64
}
@ -42,9 +42,9 @@ func (this *GameConf) IsPass(remoteAddr string, launchInfo string, responseStr*
atomic.AddInt64(&this.sceneWhiteListPassTimes, 1)
return true
}
if this.InLaunchBlackList(launchInfo) {
atomic.AddInt64(&this.totalLaunchBlackListBlockTimes, 1)
atomic.AddInt64(&this.launchBlackListBlockTimes, 1)
if this.InLaunchWhiteList(launchInfo) {
atomic.AddInt64(&this.totalLaunchWhiteListBlockTimes, 1)
atomic.AddInt64(&this.launchWhiteListBlockTimes, 1)
return false
}
@ -60,34 +60,34 @@ func (this *GameConf) IsPass(remoteAddr string, launchInfo string, responseStr*
return false
}
func (this* GameConf) InLaunchWhiteList(launchInfo string) bool {
func (this* GameConf) InSceneWhiteList(launchInfo string) bool {
this.sceneWhiteListMutex.Lock()
defer this.sceneWhiteListMutex.Unlock()
_, ok := this.sceneWhiteList[launchInfo]
return ok
}
func (this* GameConf) InLaunchBlackList(launchInfo string) bool {
this.launchBlackListMutex.Lock()
defer this.launchBlackListMutex.Unlock()
_, ok := this.launchBlackList[launchInfo]
func (this* GameConf) InLaunchWhiteList(launchInfo string) bool {
this.launchWhiteListMutex.Lock()
defer this.launchWhiteListMutex.Unlock()
_, ok := this.launchWhiteList[launchInfo]
return ok
}
func (this* GameConf) Init() {
this.sceneWhiteListMutex.Lock()
this.launchBlackListMutex.Lock()
this.launchWhiteListMutex.Lock()
defer this.sceneWhiteListMutex.Unlock()
defer this.launchBlackListMutex.Unlock()
defer this.launchWhiteListMutex.Unlock()
this.sceneWhiteList = make(map[string]int32)
this.launchBlackList = make(map[string]int32)
this.launchWhiteList = make(map[string]int32)
for _, val := range G.MetaMgr.GetSceneWhiteList().GetList() {
this.sceneWhiteList[val] = 1
}
for _, val := range G.MetaMgr.GetLaunchBlackList().GetList() {
this.launchBlackList[val] = 1
for _, val := range G.MetaMgr.GetLaunchWhiteList().GetList() {
this.launchWhiteList[val] = 1
}
this.lastActiveTime = f5.App.NowUnix()
f5.App.AddIMMsg(IM_GAMECONF_CREATE, new(q5.XParams).Init(func (params* q5.XParams) {
@ -98,9 +98,9 @@ func (this* GameConf) Init() {
func (this* GameConf) GetConfObj() *q5.XObject {
this.sceneWhiteListMutex.Lock()
this.launchBlackListMutex.Lock()
this.launchWhiteListMutex.Lock()
defer this.sceneWhiteListMutex.Unlock()
defer this.launchBlackListMutex.Unlock()
defer this.launchWhiteListMutex.Unlock()
fillRespObj := func(respObj* q5.MutableXObject, attrName string, mapObj* map[string]int32) {
list := q5.NewMxoArray()
@ -112,7 +112,7 @@ func (this* GameConf) GetConfObj() *q5.XObject {
respObj := q5.NewMxoObject()
fillRespObj(respObj, "scene_white_list", &this.sceneWhiteList)
fillRespObj(respObj, "launch_black_list", &this.launchBlackList)
fillRespObj(respObj, "launch_white_list", &this.launchWhiteList)
return respObj.AsXObject()
}
@ -127,8 +127,8 @@ func (this* GameConf) GetPassObj() *q5.XObject {
func (this* GameConf) GetBlockObj() *q5.XObject {
blockObj := q5.NewMxoObject()
blockObj.SetXValue("total_black_launch_times", q5.NewXInt64(this.totalLaunchBlackListBlockTimes))
blockObj.SetXValue("curr_black_launch_times", q5.NewXInt64(this.launchBlackListBlockTimes))
blockObj.SetXValue("total_white_launch_times", q5.NewXInt64(this.totalLaunchWhiteListBlockTimes))
blockObj.SetXValue("curr_white_launch_times", q5.NewXInt64(this.launchWhiteListBlockTimes))
blockObj.SetXValue("total_unsafezone_times", q5.NewXInt64(this.totalUnSafeZoneBlockTimes))
blockObj.SetXValue("curr_unsafezone_times", q5.NewXInt64(this.unSafeZoneBlockTimes))
return blockObj.AsXObject()
@ -140,7 +140,7 @@ func (this* GameConf) Active() {
atomic.StoreInt64(&this.blockTimes, 0)
atomic.StoreInt64(&this.sceneWhiteListPassTimes, 0)
atomic.StoreInt64(&this.safeZonePassTimes, 0)
atomic.StoreInt64(&this.launchBlackListBlockTimes, 0)
atomic.StoreInt64(&this.launchWhiteListBlockTimes, 0)
atomic.StoreInt64(&this.unSafeZoneBlockTimes, 0)
}
this.lastActiveTime = f5.App.NowUnix()

View File

@ -117,7 +117,7 @@ func (this *MetaMgr) GetSceneWhiteList() *MtwSceneWhiteList {
}
}
func (this *MetaMgr) GetLaunchBlackList() *MtwLaunchWhiteList {
func (this *MetaMgr) GetLaunchWhiteList() *MtwLaunchWhiteList {
v, ok := this.MetaMgr.GetMetaById(MT_LAUNCH_WHITE_LIST, 1).(*MtwLaunchWhiteList)
if ok {
return v