Skip to content

Commit

Permalink
Update map scores only when data already exists
Browse files Browse the repository at this point in the history
Signed-off-by: Pugzy <[email protected]>
  • Loading branch information
Pugzy committed Nov 6, 2023
1 parent 3d2a687 commit 9358b8a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/main/java/tc/oc/pgm/rotation/pools/VotingPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private void tickScores(MapInfo currentMap) {
private void updateScores(Map<MapInfo, Set<UUID>> votes) {
double voters = votes.values().stream().flatMap(Collection::stream).distinct().count();
if (voters == 0) return; // Literally no one voted
votes.forEach((m, v) -> mapScores.put(m, Math.max(v.size() / voters, Double.MIN_VALUE)));
votes.forEach(
(m, v) ->
mapScores.computeIfPresent(m, (a, b) -> Math.max(v.size() / voters, Double.MIN_VALUE)));
}

@Override
Expand Down

0 comments on commit 9358b8a

Please sign in to comment.