From 5e81710e6ac98ca0d46a2139b72e209eff61dbea Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 18:44:33 +0800 Subject: [PATCH] 1 --- server/matchserver/team/matchmgr.go | 5 +-- server/matchserver/team/team.go | 53 ++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/server/matchserver/team/matchmgr.go b/server/matchserver/team/matchmgr.go index 33aa72db..5c889651 100644 --- a/server/matchserver/team/matchmgr.go +++ b/server/matchserver/team/matchmgr.go @@ -108,6 +108,7 @@ func (this *matchMgr) onMatchOk(m *matchingInfo) { m.team.setMatchOk(m.matchOk.team) m.matchOk.team.setMatchOk(m.team) - m.team.onMatchOk() - m.matchOk.team.onMatchOk() + startTime := f5.GetApp().GetNowSeconds() + m.team.onMatchOk(startTime) + m.matchOk.team.onMatchOk(startTime) } diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 4388e445..e6268502 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -126,16 +126,24 @@ func (this *team) setMatchOk(targetM *team) { this.matchTick = q5.GetTickCount() } -func (this *team) isMainTeam() bool{ - if this.matchOk == nil { - return true - } - return this.GetTeamUuid() < this.matchOk.GetTeamUuid() +func (this *team) isMainTeam() bool { + return this.getMainTeam() == this } -func (this *team) onMatchOk() { +func (this *team) getMainTeam() *team { + if this.matchOk == nil { + return this + } + if this.GetTeamUuid() < this.matchOk.GetTeamUuid() { + return this + } else { + return this.matchOk + } +} + +func (this *team) onMatchOk(startTime int64) { this.state = constant.TEAM_STATE_STARTED - this.startTime = f5.GetApp().GetNowSeconds() + this.startTime = startTime this.stateNotifyMsg.State = proto.Int32(this.state) this.genStartGameInfo() this.SendStateNotify() @@ -311,21 +319,34 @@ func (this *team) genStartGameInfo() { ZoneId: this.GetZoneId(), NodeId: this.GetNodeId(), MapId: this.mapInfo.MapId, - RoomUuid: q5.ToString(this.GetTeamUuid()), + RoomUuid: q5.ToString(this.getMainTeam().GetTeamUuid()), StartTime: int32(this.startTime), } { q5.NewSlice(&startInfo.TeamList, 0, 10) teamList := []*team{} q5.NewSlice(&teamList, 0, 10) - { - ele := q5.NewSliceElement(&teamList) - *ele = this - } - { - if this.matchOk != nil { + if this.isMainTeam() { + { ele := q5.NewSliceElement(&teamList) - *ele = this.matchOk + *ele = this + } + { + if this.matchOk != nil { + ele := q5.NewSliceElement(&teamList) + *ele = this.matchOk + } + } + } else { + { + if this.matchOk != nil { + ele := q5.NewSliceElement(&teamList) + *ele = this.matchOk + } + } + { + ele := q5.NewSliceElement(&teamList) + *ele = this } } for _, t := range teamList { @@ -341,7 +362,7 @@ func (this *team) genStartGameInfo() { } sign := q5.Md5Str(q5.EncodeJson(&startInfo) + "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)") payload := sign + ":" + "normal_room|" + q5.EncodeJson(&startInfo) - this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.GetTeamUuid()) + this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.getMainTeam().GetTeamUuid()) this.stateNotifyMsg.JoinMsg.Payload = proto.String(payload) }