From a77cfa41dda7a864eae87621f31ae7eae1648adc Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 29 Aug 2024 16:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=BB=E5=BC=80=E6=88=BF=E9=97=B4=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/action/action_game.go | 42 +++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/gamesrv/action/action_game.go b/gamesrv/action/action_game.go index 4245e12..344fa6e 100644 --- a/gamesrv/action/action_game.go +++ b/gamesrv/action/action_game.go @@ -293,10 +293,48 @@ func CSRoomEvent(s *netlib.Session, packetid int, data interface{}, sid int64) e return nil } +func CSDestroyRoom(s *netlib.Session, packetid int, data interface{}, sid int64) error { + logger.Logger.Trace("CSDestroyRoomHandler Process recv ", data) + p := base.PlayerMgrSington.GetPlayer(sid) + if p == nil { + logger.Logger.Warn("CSDestroyRoomHandler p == nil") + return nil + } + scene := p.GetScene() + if scene == nil { + logger.Logger.Warn("CSDestroyRoomHandler p.GetScene() == nil") + return nil + } + if !scene.HasPlayer(p) { + return nil + } + + pack := &gamehall.SCDestroyRoom{ + RoomId: scene.SceneId, + OpRetCode: gamehall.OpResultCode_Game_OPRC_Error_Game, + } + send := func() { + p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_DESTROYROOM), pack) + logger.Logger.Tracef("SCDestroyRoom: %v", pack) + } + + if scene.Creator != p.SnId { + logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId") + send() + return nil + } + // 房卡场开始后不能解散 + if scene.IsCustom() && scene.NumOfGames > 0 { + send() + return nil + } + scene.Destroy(true) + return nil +} + func init() { // 房间创建者解散房间 - common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomHandler{}) - netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomPacketFactory{}) + common.Register(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &gamehall.CSDestroyRoom{}, CSDestroyRoom) // 离开或暂离房间 common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVEROOM), &CSLeaveRoomHandler{})