From 3a9bf7cfd2487e26bd6d8c964245dedef380d1c2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Mar 2024 19:39:16 +0800 Subject: [PATCH] 1 --- server/matchserver/common/types.go | 1 + server/matchserver/player/player.go | 28 ++++++++++++++++++++-------- server/matchserver/team/team.go | 4 ++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 3da8b2de..ebde3570 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -52,6 +52,7 @@ type Team interface { HandoverLeader(Player, string) CancelMatch() SetReady(Player) + GrantInvitePermission(Player, string) } type TeamMgr interface { diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 164a854f..6770fccb 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -186,8 +186,11 @@ func (this *player) CMKickOut(hdr *f5.MsgHdr, msg *cs.CMKickOut) { func (this *player) CMHandoverLeader(hdr *f5.MsgHdr, msg *cs.CMHandoverLeader) { rspMsg := &cs.SMHandoverLeader{} - if !this.GetTeam().Started() { - + if this.GetTeam().Started() { + rspMsg.Errcode = proto.Int32(1) + rspMsg.Errmsg = proto.String("team already started") + } else { + this.GetTeam().HandoverLeader(this, msg.GetTargetId()) } this.SendMsg(rspMsg) } @@ -204,24 +207,33 @@ func (this *player) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) { func (this *player) CMCancel(hdr *f5.MsgHdr, msg *cs.CMCancel) { rspMsg := &cs.SMCancel{} - if !this.GetTeam().Started() { - + if this.GetTeam().Started() { + rspMsg.Errcode = proto.Int32(1) + rspMsg.Errmsg = proto.String("team already started") + } else { + this.GetTeam().CancelMatch() } this.SendMsg(rspMsg) } func (this *player) CMSetReady(hdr *f5.MsgHdr, msg *cs.CMSetReady) { rspMsg := &cs.SMSetReady{} - if !this.GetTeam().Started() { - + if this.GetTeam().Started() { + rspMsg.Errcode = proto.Int32(1) + rspMsg.Errmsg = proto.String("team already started") + } else { + this.GetTeam().SetReady(this) } this.SendMsg(rspMsg) } func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvitePermission) { rspMsg := &cs.SMGrantInvitePermission{} - if !this.GetTeam().Started() { - + if this.GetTeam().Started() { + rspMsg.Errcode = proto.Int32(1) + rspMsg.Errmsg = proto.String("team already started") + } else { + this.GetTeam().GrantInvitePermission(this, msg.GetTargetId()) } this.SendMsg(rspMsg) } diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 4ab922bf..9e305f7f 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -155,6 +155,10 @@ func (this *team) SetReady(common.Player) { } } +func (this *team) GrantInvitePermission(common.Player, string) { + +} + func (this *team) genStartGameInfo() { startInfo := struct { ZoneId int32 `json:"zone_id"`