This commit is contained in:
aozhiwei 2023-09-13 12:56:12 +08:00
parent 0c61ae146a
commit 85286a2443
2 changed files with 12 additions and 1 deletions

View File

@ -225,7 +225,8 @@ message CMDisbandRoom
message SMDisbandRoom
{
optional int32 errcode = 1; // 0 1:
optional string errmsg = 2; //
}
//退

View File

@ -141,6 +141,12 @@ func (this *room) OnPlayerOffline(hum common.Player) {
func (this *room) CMDisbandRoom(hdr *f5.MsgHdr, msg *cs.CMDisbandRoom) {
hum := hdr.Context.(common.Player)
rspMsg := &cs.SMDisbandRoom{}
if !this.isOwner(hum) {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("insufficient permissions")
hum.SendMsg(rspMsg)
return
}
if this.roomState == ROOM_INIT_STATE {
this.doDisband(1)
}
@ -311,3 +317,7 @@ func (this *room) canStart() bool {
}
return alreadyNum >- ROOM_MIN_START_TEAM_NUM
}
func (this *room) isOwner(hum common.Player) bool {
return this.owner.hum.GetAccountId() == hum.GetAccountId()
}