From 7b9c30bd9bf0f38871a26df8afd229fc2f5cd7c3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 14 Mar 2024 11:44:13 +0800 Subject: [PATCH] 1 --- server/matchserver/common/types.go | 1 + server/matchserver/player/player.go | 4 ++++ server/matchserver/team/team.go | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 8059ae22..adc857fb 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -70,6 +70,7 @@ type Player interface { IsOnline() bool GetTeam() Team SetTeam(Team) + IsReady() bool FillMFTeamMember(*cs.MFTeamMember) GetSortIdx() int32 SetSortIdx(int32) diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 35b5edbf..ccc8d1ec 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -120,6 +120,10 @@ func (this *player) IsOnline() bool { return this.socket.IsValid() } +func (this *player) IsReady() bool { + return this.isReady != 0 +} + func (this *player) GetTeam() common.Team { return this.team } diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 235f7c3f..03a12ce6 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -108,13 +108,22 @@ func (this *team) Started() bool { func (this *team) CanStartGame(hum common.Player) bool { if !this.Started() { - this.state = constant.TEAM_STATE_STARTED + if this.GetMemberNum() > 0 { + allReady := true + for _, m := range this.accountIdHash { + if m != this.owner && !m.IsReady() { + allReady = false + break + } + } + return allReady + } } - return true + return false } func (this *team) StartGame() { - if !this.Started() { + if !this.Started() && this.CanStartGame(this.owner) { this.state = constant.TEAM_STATE_STARTED this.startTime = f5.GetApp().GetNowSeconds() this.genStartGameInfo()