From e21c14c4c1eeeb32184233d417d57ebdc80321a2 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Fri, 14 Sep 2007 15:35:25 +0000 Subject: [PATCH] Since returning -1 is perfectly acceptable for this method, let's be robust in handling an call to it for an unknown player; we already checked for unknown opponents. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@435 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../parlor/rating/server/RatingManagerDelegate.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/parlor/rating/server/RatingManagerDelegate.java b/src/java/com/threerings/parlor/rating/server/RatingManagerDelegate.java index 26195539..7b15c7b9 100644 --- a/src/java/com/threerings/parlor/rating/server/RatingManagerDelegate.java +++ b/src/java/com/threerings/parlor/rating/server/RatingManagerDelegate.java @@ -279,7 +279,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate /** * Computes updated ratings for the players of this game. The default implementation uses the * {@link GameObject#winners} field to determine winners and losers and uses a FIDE/ELO - * algorithm to comptue updated ratings. + * algorithm to compute updated ratings. */ protected void updateRatings () { @@ -313,7 +313,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate * final rating adjustment, which is then added to the player's previous rating and bounded to * the rating range. Note: provisional players (those with experience of less than 20) * will be treated as having, at most, the default rating when used as an opponent in - * calculatons for a non-provisional player. + * calculations for a non-provisional player. * * @return the player's updated rating or -1 if none of the opponents could be applicably rated * against this player. @@ -322,7 +322,14 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate { float totDeltaR = 0; // the total delta rating int opponents = 0; + Rating prating = _ratings.get(_playerIds[pidx]); + if (prating == null) { + // be robust + log.warning("Computing ratings for unknown player [where=" + where() + + ", pidx=" + pidx + "]."); + return -1; + } for (int ii = 0; ii < _playerIds.length; ii++) { Rating orating = _ratings.get(_playerIds[ii]);