Skip to content

Commit

Permalink
Resolve matchmaker regression
Browse files Browse the repository at this point in the history
Resolve an issue that would cause the matchmaker to not match two suitable opponents.

Resolves #827
  • Loading branch information
sesposito committed May 19, 2022
1 parent 75dee50 commit 043bafd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions server/matchmaker.go
Expand Up @@ -238,7 +238,7 @@ func (m *LocalMatchmaker) process(batch *index.Batch) {

for ticket, index := range m.activeIndexes {
index.Intervals++
lastInterval := index.Intervals > m.config.GetMatchmaker().MaxIntervals || index.MinCount == index.MaxCount
lastInterval := index.Intervals >= m.config.GetMatchmaker().MaxIntervals || index.MinCount == index.MaxCount
if lastInterval {
// Drop from active indexes if it has reached its max intervals, or if its min/max counts are equal. In the
// latter case keeping it active would have the same result as leaving it in the pool, so this saves work.
Expand Down Expand Up @@ -302,15 +302,18 @@ func (m *LocalMatchmaker) process(batch *index.Batch) {
continue
}

for idx, hit := range blugeMatches.Hits {
if hit.ID == ticket {
// Remove the current ticket.
blugeMatches.Hits = append(blugeMatches.Hits[:idx], blugeMatches.Hits[idx+1:]...)
break
}
}

// Form possible combinations, in case multiple matches might be suitable.
entryCombos := make([][]*MatchmakerEntry, 0, 5)
lastHitCounter := len(blugeMatches.Hits) - 1
for hitCounter, hit := range blugeMatches.Hits {
if hit.ID == ticket {
// Skip the current ticket.
continue
}

hitIndex, ok := m.indexes[hit.ID]
if !ok {
// Ticket did not exist, should not happen.
Expand Down

0 comments on commit 043bafd

Please sign in to comment.