From f46ef668ccf28588a6b82937b905e15264824755 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Mar 2024 20:47:27 +0800 Subject: [PATCH] 1 --- server/matchserver/common/types.go | 1 + server/matchserver/player/player.go | 7 ++++++- server/matchserver/team/team.go | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 7c0dc125..4470d6ab 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -73,6 +73,7 @@ type Player interface { SetTeam(Team) FillMFTeamMember(*cs.MFTeamMember) GetSortIdx() int32 + SetSortIdx(int32) } type PlayerMgr interface { diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 31205f6c..ce1e61c5 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -31,6 +31,7 @@ type player struct { permission int32 hero hero team common.Team + sortIdx int32 } func (this *player) SendMsg(rspMsg proto.Message) { @@ -128,7 +129,11 @@ func (this *player) SetTeam(team common.Team) { } func (this *player) GetSortIdx() int32 { - return 0 + return this.sortIdx +} + +func (this *player) SetSortIdx(sortIdx int32) { + this.sortIdx = sortIdx } func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 1ccedbf9..aebb1764 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -18,6 +18,7 @@ type team struct { zoneId int32 nodeId int32 mapId int32 + sortIdx int32 owner common.Player state int32 startTime int64 @@ -26,6 +27,7 @@ type team struct { } func (this *team) init(teamUuid string, owner common.Player, msg *cs.CMLogin) { + this.sortIdx++ this.teamUuid = teamUuid this.zoneId = owner.GetZoneId() this.nodeId = owner.GetNodeId() @@ -33,6 +35,7 @@ func (this *team) init(teamUuid string, owner common.Player, msg *cs.CMLogin) { this.owner = owner this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.teamUuid) owner.SetTeam(this) + owner.SetSortIdx(this.sortIdx) this.accountIdHash[owner.GetAccountId()] = owner } @@ -78,7 +81,9 @@ func (this *team) OnPlayerOnline(hum common.Player) { } func (this *team) Join(hum common.Player) bool { + this.sortIdx++ hum.SetTeam(this) + hum.SetSortIdx(this.sortIdx) this.accountIdHash[hum.GetAccountId()] = hum return true }