竞技馆房间配置包类型校验
This commit is contained in:
parent
c4bea18f9f
commit
fccb385f79
|
|
@ -1,12 +1,13 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/game/protocol/gamehall"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
"mongo.games.com/game/protocol/shop"
|
"mongo.games.com/game/protocol/shop"
|
||||||
"mongo.games.com/game/protocol/webapi"
|
"mongo.games.com/game/protocol/webapi"
|
||||||
)
|
)
|
||||||
|
|
@ -425,7 +426,7 @@ func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) {
|
||||||
delete(cm.GetConfig(plt).RoomConfig, id)
|
delete(cm.GetConfig(plt).RoomConfig, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig {
|
func (cm *ConfigMgr) GetRoomConfig(plt string, lastChannel string) *gamehall.SCRoomConfig {
|
||||||
pack := &gamehall.SCRoomConfig{}
|
pack := &gamehall.SCRoomConfig{}
|
||||||
for _, v := range cm.GetConfig(plt).RoomType {
|
for _, v := range cm.GetConfig(plt).RoomType {
|
||||||
if v.GetOn() != common.On {
|
if v.GetOn() != common.On {
|
||||||
|
|
@ -436,6 +437,10 @@ func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig {
|
||||||
if vv.GetOn() != common.On {
|
if vv.GetOn() != common.On {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if lastChannel != "" && !slices.Contains(vv.GetOnChannelName(), lastChannel) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var cost, reward []*gamehall.ItemInfo
|
var cost, reward []*gamehall.ItemInfo
|
||||||
for _, item := range vv.GetCost() {
|
for _, item := range vv.GetCost() {
|
||||||
cost = append(cost, &gamehall.ItemInfo{
|
cost = append(cost, &gamehall.ItemInfo{
|
||||||
|
|
|
||||||
|
|
@ -1168,7 +1168,7 @@ func CSRoomConfigHandler(s *netlib.Session, packetId int, data interface{}, sid
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform)
|
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform, p.LastChannel)
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
|
||||||
logger.Logger.Tracef("SCRoomConfig: %v", pack)
|
logger.Logger.Tracef("SCRoomConfig: %v", pack)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -1202,6 +1202,10 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{
|
||||||
send()
|
send()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if !slices.Contains(cfg.GetOnChannelName(), p.LastChannel) {
|
||||||
|
send()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// 场次
|
// 场次
|
||||||
if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) {
|
if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) {
|
||||||
send()
|
send()
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
"mongo.games.com/game/protocol/gamehall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -76,7 +78,34 @@ func (p *PlayerNotify) GetPlayers(tp common.NotifyType) []int32 {
|
||||||
// SendToClient 发送消息给客户端
|
// SendToClient 发送消息给客户端
|
||||||
// tp 消息类型
|
// tp 消息类型
|
||||||
func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) {
|
func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) {
|
||||||
ids := p.GetPlayers(tp)
|
switch tp {
|
||||||
|
case common.NotifyPrivateRoomList:
|
||||||
|
d := pack.(*gamehall.SCGetPrivateRoomList)
|
||||||
|
if len(d.GetDatas()) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
scene := SceneMgrSingleton.GetScene(int(d.GetDatas()[0].GetRoomId()))
|
||||||
|
if scene == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
roomConfigId := d.GetDatas()[0].GetRoomConfigId()
|
||||||
|
cfg := PlatformMgrSingleton.GetConfig(scene.limitPlatform.IdStr).RoomConfig[roomConfigId]
|
||||||
|
if cfg == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var ids []int32
|
||||||
|
for _, v := range p.GetPlayers(tp) {
|
||||||
|
player := PlayerMgrSington.GetPlayerBySnId(v)
|
||||||
|
if player == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if slices.Contains(cfg.GetOnChannelName(), player.LastChannel) {
|
||||||
|
ids = append(ids, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack)
|
PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack)
|
||||||
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
|
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue