Skip to content

Commit bd6902c

Browse files
authored
Merge pull request #297 from inada-s/team-shuffle-opt-2
regional team shuffle opt
2 parents fcb0207 + 7a431bf commit bd6902c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

gdxsv/lbs_lobby.go

+18-14
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func chatMsg(userID, name, text string) *LbsMessage {
125125
WriteString(userID).
126126
WriteString(name).
127127
WriteString(text).
128-
Write8(0). // chat_type
129-
Write8(0). // id color
130-
Write8(0). // handle color
128+
Write8(0). // chat_type
129+
Write8(0). // id color
130+
Write8(0). // handle color
131131
Write8(0).Msg() // msg color
132132
}
133133

@@ -558,20 +558,24 @@ func teamShuffle(seed int64, peers []*LbsPeer, mode int) []uint16 {
558558
})
559559

560560
// Special case - Shuffle twice if the team is same of the previous match
561-
sameTeam := false
562-
for i, p := range peers {
563-
for j, q := range peers {
564-
if i != j && teams[i] == teams[j] {
565-
if getLastTeamUserID(p.UserID) == q.UserID && getLastTeamUserID(q.UserID) == p.UserID {
566-
sameTeam = true
561+
for t := 0; t < 2; t++ {
562+
sameTeam := false
563+
for i, p := range peers {
564+
for j, q := range peers {
565+
if i != j && teams[i] == teams[j] {
566+
if getLastTeamUserID(p.UserID) == q.UserID && getLastTeamUserID(q.UserID) == p.UserID {
567+
sameTeam = true
568+
}
567569
}
568570
}
569571
}
570-
}
571-
if sameTeam {
572-
r.Shuffle(len(teams), func(i, j int) {
573-
teams[i], teams[j] = teams[j], teams[i]
574-
})
572+
if sameTeam {
573+
r.Shuffle(len(teams), func(i, j int) {
574+
teams[i], teams[j] = teams[j], teams[i]
575+
})
576+
} else {
577+
break
578+
}
575579
}
576580

577581
if mode == TeamShuffleRegionFriendly {

0 commit comments

Comments
 (0)