This commit is contained in:
aozhiwei 2024-03-13 21:32:16 +08:00
parent f46ef668cc
commit 6fb616dc61
3 changed files with 20 additions and 0 deletions

View File

@ -139,6 +139,7 @@ func (this *player) SetSortIdx(sortIdx int32) {
func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
member_pb.AccountId = proto.String(this.accountId) member_pb.AccountId = proto.String(this.accountId)
member_pb.Name = proto.String(this.name) member_pb.Name = proto.String(this.name)
member_pb.Id = proto.Int32(this.sortIdx)
if this.GetTeam().IsLeader(this) { if this.GetTeam().IsLeader(this) {
member_pb.IsLeader = proto.Int32(1) member_pb.IsLeader = proto.Int32(1)
} else { } else {

View File

@ -130,6 +130,7 @@ message MFTeamMember
optional int32 online = 7; //线 optional int32 online = 7; //线
optional int32 permission = 8; // optional int32 permission = 8; //
optional int32 is_ready = 9; // optional int32 is_ready = 9; //
optional int32 id = 10; //
} }
// //

View File

@ -7,6 +7,7 @@ import (
"main/common" "main/common"
"main/constant" "main/constant"
"sort"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
@ -85,6 +86,7 @@ func (this *team) Join(hum common.Player) bool {
hum.SetTeam(this) hum.SetTeam(this)
hum.SetSortIdx(this.sortIdx) hum.SetSortIdx(this.sortIdx)
this.accountIdHash[hum.GetAccountId()] = hum this.accountIdHash[hum.GetAccountId()] = hum
this.rearrangementSortIdx()
return true 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() { func (this *team) genStartGameInfo() {
startInfo := struct { startInfo := struct {
ZoneId int32 `json:"zone_id"` ZoneId int32 `json:"zone_id"`