From fccb385f79e0a289ec7cde9701302ecf4e700168 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 5 Sep 2024 18:47:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8C=85=E7=B1=BB=E5=9E=8B=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/config.go | 9 +++++++-- worldsrv/action_game.go | 6 +++++- worldsrv/playernotify.go | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/model/config.go b/model/config.go index e569e0c..622469d 100644 --- a/model/config.go +++ b/model/config.go @@ -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{ diff --git a/worldsrv/action_game.go b/worldsrv/action_game.go index 7785ce8..61e09b8 100644 --- a/worldsrv/action_game.go +++ b/worldsrv/action_game.go @@ -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() diff --git a/worldsrv/playernotify.go b/worldsrv/playernotify.go index e944769..29f2829 100644 --- a/worldsrv/playernotify.go +++ b/worldsrv/playernotify.go @@ -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) - PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack) - logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids) + 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) + } }