From 3f8ef69198d3e9ea9925d673260eece3d2589e9b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 20:23:10 +0800 Subject: [PATCH] 1 --- server/matchserver/team/team.go | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 19973645..8c21db78 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -25,7 +25,7 @@ type team struct { state int32 startTime int64 stateNotifyMsg *cs.SMTeamStateNotify - accountIdHash map[string]common.Player + memberIdHash map[string]common.Player matchOk *team matchTick int64 } @@ -43,7 +43,7 @@ func (this *team) init(copyIdx int32, zoneId int32, nodeId int32, this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.teamUuid) owner.SetTeam(this) owner.SetSortIdx(this.sortIdx) - this.accountIdHash[owner.GetAccountId()] = owner + this.memberIdHash[owner.GetAccountId()] = owner } func (this *team) GetZoneId() int32 { @@ -76,7 +76,7 @@ func (this *team) CanJoin(accountId string) bool { } func (this *team) GetMemberByAccountId(accountId string) common.Player { - hum, ok := this.accountIdHash[accountId] + hum, ok := this.memberIdHash[accountId] if ok { return hum } @@ -95,7 +95,7 @@ func (this *team) Join(hum common.Player) bool { this.sortIdx++ hum.SetTeam(this) hum.SetSortIdx(this.sortIdx) - this.accountIdHash[hum.GetAccountId()] = hum + this.memberIdHash[hum.GetAccountId()] = hum this.rearrangementSortIdx() return true } @@ -105,7 +105,7 @@ func (this *team) IsLeader(hum common.Player) bool { } func (this *team) isFull() bool { - return len(this.accountIdHash) >= 4 + return len(this.memberIdHash) >= 4 } func (this *team) IsCopy() bool { @@ -165,7 +165,7 @@ func (this *team) CanStartGame(hum common.Player) bool { if !this.IsLock() { if this.GetMemberNum() > 0 { allReady := true - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { if m != this.owner && !m.IsReady() { allReady = false break @@ -199,12 +199,12 @@ func (this *team) StartGame() { } func (this *team) GetMemberNum() int32 { - return int32(len(this.accountIdHash)) + return int32(len(this.memberIdHash)) } func (this *team) chooseNextLeader() { nextLeader := this.owner - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { if nextLeader == nil { nextLeader = m } else if m.GetSortIdx() < nextLeader.GetSortIdx() { @@ -218,12 +218,12 @@ func (this *team) chooseNextLeader() { func (this *team) Leave(hum common.Player) { if !this.Started() { if this.IsLeader(hum) { - delete(this.accountIdHash, hum.GetAccountId()) + delete(this.memberIdHash, hum.GetAccountId()) if this.GetMemberNum() > 0 { this.chooseNextLeader() } } else { - delete(this.accountIdHash, hum.GetAccountId()) + delete(this.memberIdHash, hum.GetAccountId()) } if this.GetMemberNum() < 0 { this.Disband() @@ -251,7 +251,7 @@ func (this *team) KickOut(hum common.Player, targetId string) { notifyMsg := &cs.SMTeamKickoutNotify{} notifyMsg.AccountId = proto.String(target.GetAccountId()) target.SendMsg(notifyMsg) - delete(this.accountIdHash, target.GetAccountId()) + delete(this.memberIdHash, target.GetAccountId()) } } } @@ -291,7 +291,7 @@ func (this* team) IsMobaMode() bool { func (this *team) rearrangementSortIdx() { members := []common.Player{} q5.NewSlice(&members, 0, 4) - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { q5.AppendSlice(&members, m) } sort.Slice(members, func(i, j int) bool { @@ -359,7 +359,7 @@ func (this *team) genStartGameInfo() { for _, t := range teamList { ele := q5.NewSliceElement(&startInfo.TeamList) ele.TeamUuid = t.GetTeamUuid() - for _, m := range t.accountIdHash { + for _, m := range t.memberIdHash { ele2 := q5.NewSliceElement(&ele.Members) ele2.AccountId = m.GetAccountId() ele2.SpecSkill = m.GetSpecSkill() @@ -397,7 +397,7 @@ func (this *team) genNextCopyTeam() { nextTeam := newTeam() nextTeam.init(nextCopyIdx, this.zoneId, this.nodeId, this.nextTeamUuid, this.owner.GenNextCopy(), nextMapInfo) - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { if m != this.owner { nextTeam.Join(m.GenNextCopy()) } @@ -406,7 +406,7 @@ func (this *team) genNextCopyTeam() { } func (this *team) broadcastMsg(msg proto.Message) { - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { m.SendMsg(msg) } } @@ -417,7 +417,7 @@ func (this *team) SendUpdateNotify() { notifyMsg.TeamInfo.TeamUuid = proto.String(this.teamUuid) notifyMsg.TeamInfo.MapId = proto.Int32(this.mapInfo.MapId) q5.NewSlice(¬ifyMsg.TeamInfo.Members, 0, 1) - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { m_pb := &cs.MFTeamMember{} q5.AppendSlice(¬ifyMsg.TeamInfo.Members, m_pb) m.FillMFTeamMember(m_pb) @@ -439,7 +439,7 @@ func (this *team) canMatch(targetT *team) bool { if this.GetMemberNum() <= 0 || targetT.GetMemberNum() <= 0 { return false } - for _, m := range this.accountIdHash { + for _, m := range this.memberIdHash { if targetT.GetMemberByAccountId(m.GetAccountId()) != nil { return false } @@ -452,6 +452,6 @@ func newTeam() *team { t.state = constant.TEAM_STATE_INIT t.stateNotifyMsg = &cs.SMTeamStateNotify{} t.stateNotifyMsg.JoinMsg = &cs.MFJoinMsg{} - t.accountIdHash = map[string]common.Player{} + t.memberIdHash = map[string]common.Player{} return t }