From 6fb616dc61e8472a15b7e3c52e43b1452d9c6679 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Mar 2024 21:32:16 +0800 Subject: [PATCH] 1 --- server/matchserver/player/player.go | 1 + server/matchserver/proto/cs_proto.proto | 1 + server/matchserver/team/team.go | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index ce1e61c5..7ed0d6c6 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -139,6 +139,7 @@ func (this *player) SetSortIdx(sortIdx int32) { func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { member_pb.AccountId = proto.String(this.accountId) member_pb.Name = proto.String(this.name) + member_pb.Id = proto.Int32(this.sortIdx) if this.GetTeam().IsLeader(this) { member_pb.IsLeader = proto.Int32(1) } else { diff --git a/server/matchserver/proto/cs_proto.proto b/server/matchserver/proto/cs_proto.proto index 21c7e07d..01476ee6 100644 --- a/server/matchserver/proto/cs_proto.proto +++ b/server/matchserver/proto/cs_proto.proto @@ -130,6 +130,7 @@ message MFTeamMember optional int32 online = 7; //是否在线 optional int32 permission = 8; //是否有邀请权限 optional int32 is_ready = 9; //是否已准备 + optional int32 id = 10; //编号 } //队伍信息 diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index aebb1764..7b7c9b47 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -7,6 +7,7 @@ import ( "main/common" "main/constant" + "sort" "github.com/golang/protobuf/proto" ) @@ -85,6 +86,7 @@ func (this *team) Join(hum common.Player) bool { hum.SetTeam(this) hum.SetSortIdx(this.sortIdx) this.accountIdHash[hum.GetAccountId()] = hum + this.rearrangementSortIdx() return true } @@ -175,6 +177,22 @@ func (this *team) GrantInvitePermission(hum common.Player, targetId string) { } } +func (this *team) rearrangementSortIdx() { + members := []common.Player{} + q5.NewSlice(&members, 0, 4) + for _, m := range this.accountIdHash { + q5.AppendSlice(&members, m) + } + sort.Slice(members, func(i, j int) bool { + return members[i].GetSortIdx() < members[j].GetSortIdx() + }) + idx := int32(0) + for _, m := range members { + idx++ + m.SetSortIdx(idx) + } +} + func (this *team) genStartGameInfo() { startInfo := struct { ZoneId int32 `json:"zone_id"`