竞技馆房间配置包类型校验

This commit is contained in:
sk 2024-09-05 18:47:21 +08:00
parent c4bea18f9f
commit fccb385f79
3 changed files with 44 additions and 6 deletions

View File

@ -1,12 +1,13 @@
package model
import (
"mongo.games.com/game/protocol/gamehall"
"slices"
"strconv"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
"mongo.games.com/game/protocol/gamehall"
"mongo.games.com/game/protocol/shop"
"mongo.games.com/game/protocol/webapi"
)
@ -425,7 +426,7 @@ func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) {
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{}
for _, v := range cm.GetConfig(plt).RoomType {
if v.GetOn() != common.On {
@ -436,6 +437,10 @@ func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig {
if vv.GetOn() != common.On {
continue
}
if lastChannel != "" && !slices.Contains(vv.GetOnChannelName(), lastChannel) {
continue
}
var cost, reward []*gamehall.ItemInfo
for _, item := range vv.GetCost() {
cost = append(cost, &gamehall.ItemInfo{

View File

@ -1168,7 +1168,7 @@ func CSRoomConfigHandler(s *netlib.Session, packetId int, data interface{}, sid
return nil
}
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform)
pack := PlatformMgrSingleton.GetRoomConfig(p.Platform, p.LastChannel)
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack)
logger.Logger.Tracef("SCRoomConfig: %v", pack)
return nil
@ -1202,6 +1202,10 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{
send()
return nil
}
if !slices.Contains(cfg.GetOnChannelName(), p.LastChannel) {
send()
return nil
}
// 场次
if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) {
send()

View File

@ -1,11 +1,13 @@
package main
import (
"slices"
"time"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
"mongo.games.com/game/protocol/gamehall"
)
func init() {
@ -76,7 +78,34 @@ func (p *PlayerNotify) GetPlayers(tp common.NotifyType) []int32 {
// SendToClient 发送消息给客户端
// tp 消息类型
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)
logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids)
}
}