代码优化
This commit is contained in:
parent
a822e21524
commit
64a1df39c5
|
|
@ -16,19 +16,7 @@ import (
|
|||
"mongo.games.com/game/srvdata"
|
||||
)
|
||||
|
||||
// 查看背包
|
||||
type CSBagInfoPacketFactory struct {
|
||||
}
|
||||
|
||||
type CSBagInfoHandler struct {
|
||||
}
|
||||
|
||||
func (this *CSBagInfoPacketFactory) CreatePacket() interface{} {
|
||||
pack := &bag.CSBagInfo{}
|
||||
return pack
|
||||
}
|
||||
|
||||
func (this *CSBagInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
func CSBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
logger.Logger.Trace("CSBagInfoHandler Process recv ", data)
|
||||
if msg, ok := data.(*bag.CSBagInfo); ok {
|
||||
p := PlayerMgrSington.GetPlayer(sid)
|
||||
|
|
@ -62,19 +50,7 @@ func (this *CSBagInfoHandler) Process(s *netlib.Session, packetid int, data inte
|
|||
return nil
|
||||
}
|
||||
|
||||
// 使用/获取道具 PS严格来说客户端只存在消耗道具 服务器增加 上线要禁止该接口增加道具
|
||||
type CSUpBagInfoPacketFactory struct {
|
||||
}
|
||||
|
||||
type CSUpBagInfoHandler struct {
|
||||
}
|
||||
|
||||
func (this *CSUpBagInfoPacketFactory) CreatePacket() interface{} {
|
||||
pack := &bag.CSUpBagInfo{}
|
||||
return pack
|
||||
}
|
||||
|
||||
func (this *CSUpBagInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
func CSUpBagInfo(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
logger.Logger.Trace("CSUpBagInfoHandler Process recv ", data)
|
||||
msg, ok := data.(*bag.CSUpBagInfo)
|
||||
if !ok {
|
||||
|
|
@ -428,11 +404,9 @@ func CSPropExchange(s *netlib.Session, packetid int, data interface{}, sid int64
|
|||
|
||||
func init() {
|
||||
// 查看背包
|
||||
common.RegisterHandler(int(bag.SPacketID_PACKET_ALL_BAG_INFO), &CSBagInfoHandler{})
|
||||
netlib.RegisterFactory(int(bag.SPacketID_PACKET_ALL_BAG_INFO), &CSBagInfoPacketFactory{})
|
||||
// 道具操作(赠送,出售...)
|
||||
common.RegisterHandler(int(bag.SPacketID_PACKET_ALL_BAG_USE), &CSUpBagInfoHandler{})
|
||||
netlib.RegisterFactory(int(bag.SPacketID_PACKET_ALL_BAG_USE), &CSUpBagInfoPacketFactory{})
|
||||
common.Register(int(bag.SPacketID_PACKET_ALL_BAG_INFO), &bag.CSBagInfo{}, CSBagInfo)
|
||||
// 道具操作
|
||||
common.Register(int(bag.SPacketID_PACKET_ALL_BAG_USE), &bag.CSUpBagInfo{}, CSUpBagInfo)
|
||||
// 兑换列表
|
||||
common.Register(int(bag.SPacketID_PACKET_ExchangeList), &bag.CSExchangeList{}, CSExchangeList)
|
||||
// 道具兑换
|
||||
|
|
|
|||
|
|
@ -20,12 +20,6 @@ var BlackListMgrSington = &BlackListMgr{
|
|||
BlackList: make(map[int32]*BlackInfo),
|
||||
}
|
||||
|
||||
//type BlackListObserver interface {
|
||||
// OnAddBlackInfo(blackinfo *BlackInfo)
|
||||
// OnEditBlackInfo(blackinfo *BlackInfo)
|
||||
// OnRemoveBlackInfo(blackinfo *BlackInfo)
|
||||
//}
|
||||
|
||||
type BlackListMgr struct {
|
||||
BlackList map[int32]*BlackInfo
|
||||
BlackListByPlatform [BlackState_Max]map[string]map[int32]*BlackInfo
|
||||
|
|
@ -36,7 +30,6 @@ type BlackListMgr struct {
|
|||
IpNetByPlatform [BlackState_Max]map[string][]*BlackInfo
|
||||
PackageTagByPlatform [BlackState_Max]map[string]*BlackInfo
|
||||
DeviceByPlatform [BlackState_Max]map[string]map[string]*BlackInfo
|
||||
//Observers []BlackListObserver
|
||||
}
|
||||
|
||||
type BlackInfo struct {
|
||||
|
|
@ -51,6 +44,7 @@ type BlackInfo struct {
|
|||
DeviceId string //设备ID
|
||||
ipNet *net.IPNet
|
||||
}
|
||||
|
||||
type BlackInfoApi struct {
|
||||
Id int32
|
||||
Space int32
|
||||
|
|
@ -68,32 +62,6 @@ type BlackInfoApi struct {
|
|||
DeviceId string //设备ID
|
||||
}
|
||||
|
||||
//func (this *BlackListMgr) RegisterObserver(observer BlackListObserver) {
|
||||
// for _, ob := range this.Observers {
|
||||
// if ob == observer {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// this.Observers = append(this.Observers, observer)
|
||||
//}
|
||||
//
|
||||
//func (this *BlackListMgr) UnregisterObserver(observer BlackListObserver) {
|
||||
// for i, ob := range this.Observers {
|
||||
// if ob == observer {
|
||||
// count := len(this.Observers)
|
||||
// if i == 0 {
|
||||
// this.Observers = this.Observers[1:]
|
||||
// } else if i == count-1 {
|
||||
// this.Observers = this.Observers[:count-1]
|
||||
// } else {
|
||||
// arr := this.Observers[:i]
|
||||
// arr = append(arr, this.Observers[i+1:]...)
|
||||
// this.Observers = arr
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
func (this *BlackListMgr) Init() {
|
||||
if this.BlackList == nil {
|
||||
this.BlackList = make(map[int32]*BlackInfo)
|
||||
|
|
@ -378,27 +346,6 @@ func (this *BlackListMgr) RemoveBlackInfo(Id int32, platform string) {
|
|||
}
|
||||
}
|
||||
|
||||
// func (this *BlackListMgr) RemoveBlackInfoByUser(blackinfo *BlackInfo) {
|
||||
// this.OnRemoveBlackInfo(blackinfo)
|
||||
// }
|
||||
//
|
||||
// func (this *BlackListMgr) OnAddBlackInfo(blackinfo *BlackInfo) {
|
||||
// for _, ob := range this.Observers {
|
||||
// ob.OnAddBlackInfo(blackinfo)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (this *BlackListMgr) OnEditBlackInfo(blackinfo *BlackInfo) {
|
||||
// for _, ob := range this.Observers {
|
||||
// ob.OnEditBlackInfo(blackinfo)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func (this *BlackListMgr) OnRemoveBlackInfo(blackinfo *BlackInfo) {
|
||||
// for _, ob := range this.Observers {
|
||||
// ob.OnRemoveBlackInfo(blackinfo)
|
||||
// }
|
||||
// }
|
||||
func (this *BlackListMgr) CheckPlayerInvalid(blackinfo *BlackInfo, data *model.PlayerData) bool {
|
||||
if len(blackinfo.Platform) > 0 && (data.Platform != blackinfo.Platform && blackinfo.Platform != "0") {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -1,207 +0,0 @@
|
|||
package main
|
||||
|
||||
//
|
||||
//import (
|
||||
// "encoding/json"
|
||||
// "mongo.games.com/game/common"
|
||||
// "mongo.games.com/game/model"
|
||||
// "mongo.games.com/game/webapi"
|
||||
// "mongo.games.com/goserver/core/logger"
|
||||
// "mongo.games.com/goserver/core/module"
|
||||
// "time"
|
||||
//)
|
||||
//
|
||||
////公告模块
|
||||
//
|
||||
//var BulletMgrSington = &BulletMgr{
|
||||
// BulletMsgList: make(map[int32]*Bullet),
|
||||
//}
|
||||
//
|
||||
//type BulletMgr struct {
|
||||
// BulletMsgList map[int32]*Bullet
|
||||
//}
|
||||
//
|
||||
//type Bullet struct {
|
||||
// Id int32
|
||||
// Sort int32 //排序
|
||||
// Platform string
|
||||
// NoticeTitle string
|
||||
// NoticeContent string
|
||||
// UpdateTime string
|
||||
// State int //0 关闭 1开启
|
||||
//}
|
||||
//type ApiBulletResult struct {
|
||||
// Tag int
|
||||
// Msg []Bullet
|
||||
//}
|
||||
//
|
||||
//func (this *BulletMgr) query() {
|
||||
// //不使用etcd的情况下走api获取
|
||||
// if model.GameParamData.UseEtcd {
|
||||
// EtcdMgrSington.InitPlatformBulletin()
|
||||
// } else {
|
||||
// buff, err := webapi.API_GetBulletData(common.GetAppId())
|
||||
// //logger.Logger.Warn("bulletin buff: ", string(buff))
|
||||
// if err == nil {
|
||||
// info := ApiBulletResult{}
|
||||
// err = json.Unmarshal([]byte(buff), &info)
|
||||
// if err == nil {
|
||||
// for i := 0; i < len(info.Msg); i++ {
|
||||
// BulletMgrSington.BulletMsgList[info.Msg[i].Id] = &info.Msg[i]
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Error("Unmarshal Bullet data error:", err, string(buff))
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Error("Get Bullet data error:", err)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *BulletMgr) clearPlatformBullet(Platform string) {
|
||||
// for k, v := range this.BulletMsgList {
|
||||
// if v.Platform == Platform {
|
||||
// delete(this.BulletMsgList, k)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *BulletMgr) updateBullet(id int32, info string) (map[int32]*Bullet, string) {
|
||||
// platform := ""
|
||||
// if info == "" {
|
||||
// delete(this.BulletMsgList, id)
|
||||
// platform = "delete"
|
||||
// } else {
|
||||
// bt := this.Unmarshal(info)
|
||||
// if bt != nil {
|
||||
// this.BulletMsgList[id] = bt
|
||||
// platform = bt.Platform
|
||||
// }
|
||||
// }
|
||||
// return this.BulletMsgList, platform
|
||||
//}
|
||||
//func (this *BulletMgr) Unmarshal(info string) (bt *Bullet) {
|
||||
// err := json.Unmarshal([]byte(info), &bt)
|
||||
// if err != nil {
|
||||
// logger.Logger.Trace("Unmarshal Bullet is error :", err)
|
||||
// return nil
|
||||
// }
|
||||
// return
|
||||
//}
|
||||
//func (this *BulletMgr) ModuleName() string {
|
||||
// return "BulletMgr"
|
||||
//}
|
||||
//func (this *BulletMgr) Init() {
|
||||
//}
|
||||
//func (this *BulletMgr) Update() {
|
||||
//}
|
||||
//func (this *BulletMgr) Shutdown() {
|
||||
// module.UnregisteModule(this)
|
||||
//}
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////招商列表
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//var CustomerMgrSington = &CustomerMgr{
|
||||
// CustomerMsgList: make(map[int32]*Customer),
|
||||
//}
|
||||
//
|
||||
//type CustomerMgr struct {
|
||||
// CustomerMsgList map[int32]*Customer
|
||||
//}
|
||||
//type Customer struct {
|
||||
// Id int32
|
||||
// Platform string
|
||||
// Weixin_account string
|
||||
// Qq_account string
|
||||
// Headurl string
|
||||
// Nickname string
|
||||
// Status int
|
||||
// Ext string
|
||||
//}
|
||||
//type ApiCustomerResult struct {
|
||||
// Tag int
|
||||
// Msg []Customer
|
||||
//}
|
||||
//
|
||||
//func (this *CustomerMgr) ModuleName() string {
|
||||
// return "CustomerMgr"
|
||||
//}
|
||||
//func (this *CustomerMgr) Init() {
|
||||
//}
|
||||
//func (this *CustomerMgr) Update() {
|
||||
//}
|
||||
//func (this *CustomerMgr) Shutdown() {
|
||||
// module.UnregisteModule(this)
|
||||
//}
|
||||
//func (this *CustomerMgr) query() {
|
||||
// //不使用etcd的情况下走api获取
|
||||
// if model.GameParamData.UseEtcd {
|
||||
// EtcdMgrSington.InitPlatformAgent()
|
||||
// } else {
|
||||
// buff, err := webapi.API_GetCustomerData(common.GetAppId())
|
||||
// logger.Logger.Trace("customer buff:", string(buff))
|
||||
// if err == nil {
|
||||
// c_info := ApiCustomerResult{}
|
||||
// err = json.Unmarshal([]byte(buff), &c_info)
|
||||
// if err == nil {
|
||||
// for i := 0; i < len(c_info.Msg); i++ {
|
||||
// CustomerMgrSington.CustomerMsgList[c_info.Msg[i].Id] = &c_info.Msg[i]
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Trace("CustomerMgr is Unmarshal error.", err)
|
||||
// }
|
||||
// } else {
|
||||
// logger.Logger.Trace("API_GetCustomerData is error. ", err)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//func (this *CustomerMgr) updateCustomer(id int32, info string) (map[int32]*Customer, string) {
|
||||
// platform := ""
|
||||
// if info == "" {
|
||||
// delete(this.CustomerMsgList, id)
|
||||
// platform = "delete"
|
||||
// } else {
|
||||
// bt := this.Unmarshal(info)
|
||||
// if bt != nil {
|
||||
// this.CustomerMsgList[id] = bt
|
||||
// platform = bt.Platform
|
||||
// }
|
||||
// }
|
||||
// return this.CustomerMsgList, platform
|
||||
//}
|
||||
//func (this *CustomerMgr) Unmarshal(info string) (bt *Customer) {
|
||||
// err := json.Unmarshal([]byte(info), &bt)
|
||||
// if err != nil {
|
||||
// logger.Logger.Trace("Unmarshal Customer is error :", err)
|
||||
// return nil
|
||||
// }
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func init() {
|
||||
// module.RegisteModule(BulletMgrSington, time.Second*2, 0)
|
||||
// module.RegisteModule(CustomerMgrSington, time.Second*2, 0)
|
||||
//
|
||||
// RegisterParallelLoadFunc("平台公告", func() error {
|
||||
// BulletMgrSington.query()
|
||||
// return nil
|
||||
// })
|
||||
//
|
||||
// ////不使用并发加载,因为并发太快,用到GameParam里面的数据还未来的及加载,下同
|
||||
// //core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||
// // BulletMgrSington.query()
|
||||
// // return nil
|
||||
// //})
|
||||
//
|
||||
// RegisterParallelLoadFunc("平台代理", func() error {
|
||||
// CustomerMgrSington.query()
|
||||
// return nil
|
||||
// })
|
||||
//
|
||||
// //core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||
// // CustomerMgrSington.query()
|
||||
// // return nil
|
||||
// //})
|
||||
//}
|
||||
|
|
@ -59,7 +59,7 @@ func (ms *MatchSceneMgr) NewScene(tm *TmMatch, isFinals bool, round int32) *Scen
|
|||
params := []int32{tm.SortId, finals, round, curPlayerNum, nextNeed, tm.gmd.MatchType}
|
||||
|
||||
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Match, 1,
|
||||
0, params, gs, limitPlatform, groupId, tm.dbGameFree)
|
||||
0, params, gs, limitPlatform, groupId, tm.dbGameFree, tm.dbGameFree.GetId())
|
||||
if scene != nil {
|
||||
scene.matchId = tm.SortId
|
||||
return scene
|
||||
|
|
|
|||
Loading…
Reference in New Issue