离开房间返回错误码
This commit is contained in:
parent
33eab3f5bc
commit
a77cfa41dd
|
@ -293,10 +293,48 @@ func CSRoomEvent(s *netlib.Session, packetid int, data interface{}, sid int64) e
|
||||||
return nil
|
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() {
|
func init() {
|
||||||
// 房间创建者解散房间
|
// 房间创建者解散房间
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomHandler{})
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &gamehall.CSDestroyRoom{}, CSDestroyRoom)
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomPacketFactory{})
|
|
||||||
|
|
||||||
// 离开或暂离房间
|
// 离开或暂离房间
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVEROOM), &CSLeaveRoomHandler{})
|
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVEROOM), &CSLeaveRoomHandler{})
|
||||||
|
|
Loading…
Reference in New Issue