The UserIdentifier is global. Cut through the crap.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@837 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user