diff --git a/src/as/com/threerings/parlor/game/client/GameController.as b/src/as/com/threerings/parlor/game/client/GameController.as index 74ff66ff..37066af4 100644 --- a/src/as/com/threerings/parlor/game/client/GameController.as +++ b/src/as/com/threerings/parlor/game/client/GameController.as @@ -36,7 +36,6 @@ import com.threerings.crowd.util.CrowdContext; import com.threerings.parlor.game.data.GameCodes; import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameObject; -import com.threerings.parlor.game.data.UserIdentifier; import com.threerings.parlor.util.ParlorContext; /** @@ -54,22 +53,6 @@ public /*abstract*/ class GameController extends PlaceController { protected static const log :Log = Log.getLog(GameController); - /** - * Configures a means for identifying users persistently. - */ - public static function setUserIdentifier (userIder :UserIdentifier) :void - { - _userIder = userIder; - } - - /** - * Returns the persistent user id for the supplied player name. - */ - public static function nameToId (name :Name) :int - { - return (_userIder == null) ? 0 : _userIder.getUserId(name); - } - /** * Initializes this game controller with the game configuration that * was established during the match making process. Derived classes @@ -339,8 +322,5 @@ public /*abstract*/ class GameController extends PlaceController * the client knows the game is over before the server has * transitioned the game object accordingly. */ protected var _gameOver :Boolean; - - /** Used to map users to persistent integer identifiers. */ - protected static var _userIder :UserIdentifier; } } diff --git a/src/as/com/threerings/parlor/game/data/UserIdentifier.as b/src/as/com/threerings/parlor/game/data/UserIdentifier.as index d0e790f3..c4d3e775 100644 --- a/src/as/com/threerings/parlor/game/data/UserIdentifier.as +++ b/src/as/com/threerings/parlor/game/data/UserIdentifier.as @@ -5,11 +5,21 @@ package com.threerings.parlor.game.data { import com.threerings.util.Name; -public interface UserIdentifier +public class UserIdentifier { /** - * Returns the id of the specified user, or 0 if they're not valid. + * Get the user id for the specified user, or 0 if they're not valid. */ - function getUserId (name :Name) :int; + public static function getUserId (name :Name) :int + { + return (_userIder == null) ? 0 : _userIder(name); + } + + public static function setIder (userIder :Function) :void + { + _userIder = userIder; + } + + protected static var _userIder :Function; } } diff --git a/src/java/com/threerings/parlor/game/data/UserIdentifier.java b/src/java/com/threerings/parlor/game/data/UserIdentifier.java index 3ced410b..eb049dc4 100644 --- a/src/java/com/threerings/parlor/game/data/UserIdentifier.java +++ b/src/java/com/threerings/parlor/game/data/UserIdentifier.java @@ -5,10 +5,31 @@ package com.threerings.parlor.game.data; import com.threerings.util.Name; -public interface UserIdentifier +public class UserIdentifier { + /** + * Implement this and set the mutha up. + */ + public interface Ider + { + int getUserId (Name name); + } + /** * Returns the id of the specified user, or 0 if they're not valid. */ - int getUserId (Name name); + public static int getUserId (Name name) + { + return (_userIder == null) ? 0 : _userIder.getUserId(name); + } + + /** + * Set the global user identifier to use. + */ + public static void setIder (Ider userIder) + { + _userIder = userIder; + } + + protected static Ider _userIder; } diff --git a/src/java/com/threerings/parlor/game/server/GameManager.java b/src/java/com/threerings/parlor/game/server/GameManager.java index 3f2894f7..c73e4834 100644 --- a/src/java/com/threerings/parlor/game/server/GameManager.java +++ b/src/java/com/threerings/parlor/game/server/GameManager.java @@ -66,15 +66,6 @@ import static com.threerings.parlor.Log.log; public class GameManager extends PlaceManager implements ParlorCodes, GameCodes, PlayManager { - /** - * Configures a means by which the Parlor game services can map users to a persistent user id - * for things like per-game cookies and ratings. - */ - public static void setUserIdentifier (UserIdentifier userIder) - { - _userIder = userIder; - } - /** * Returns the configuration object for the game being managed by this manager. */ @@ -339,7 +330,7 @@ public class GameManager extends PlaceManager */ public int getPlayerPersistentId (Name name) { - return _userIder.getUserId(name); + return UserIdentifier.getUserId(name); } /** @@ -1392,13 +1383,6 @@ public class GameManager extends PlaceManager /** The interval for the AI tick. */ protected Interval _aiTicker; - /** Used to map users to persistent integer identifiers. */ - protected static UserIdentifier _userIder = new UserIdentifier() { - public int getUserId (Name name) { - return 0; // by default no one has persistent info - } - }; - /** The default value returned by {@link #getNoShowTime}. */ protected static final long DEFAULT_NOSHOW_DELAY = 30 * 1000L; diff --git a/src/java/com/threerings/parlor/rating/server/RatingDelegate.java b/src/java/com/threerings/parlor/rating/server/RatingDelegate.java index 4a87be6f..aaaf66e0 100644 --- a/src/java/com/threerings/parlor/rating/server/RatingDelegate.java +++ b/src/java/com/threerings/parlor/rating/server/RatingDelegate.java @@ -127,7 +127,7 @@ public abstract class RatingDelegate extends GameManagerDelegate BodyObject bobj = (BodyObject)_omgr.getObject(_gobj.occupants.get(ii)); int pidx = _gmgr.getPlayerIndex(bobj.getVisibleName()); if (pidx != -1) { - _playerIds[pidx] = _gmgr.getPlayerPersistentId(bobj.getVisibleName()); + _playerIds[pidx] = _gmgr.getPlayerPersistentId(bobj); } Rating rating = maybeCreateRating(bobj); if (rating != null) { @@ -169,7 +169,7 @@ public abstract class RatingDelegate extends GameManagerDelegate protected Rating maybeCreateRating (BodyObject bobj) { // if this occupant is not a player (or not ratable), skip 'em - int playerId = _gmgr.getPlayerPersistentId(bobj.getVisibleName()); + int playerId = _gmgr.getPlayerPersistentId(bobj); if (playerId == 0) { return null; }