405 modified source files and 17,367 lines of diffs later we now enforce
more discipline when handling names in our code base. Any user entered name should find its way into a Name object as soon as it comes out of a text field or whatnot, and stay that way until it makes its way into a text field or into a database record (for which String objects are vastly simpler because of JORA magic). Dear God, let me never again make a change this large for the rest of my mortal life. Unfortunately, this means we have to keep an eye out for funny business pretty much everywhere. However, since we will absolutely want to test market stalls and so forth on Azure, we'll have an opportunity to iron out any funny business that might fall under the radar during our internal testing. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2980 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
//
|
||||
// $Id: GameConfig.java,v 1.16 2004/02/25 14:44:54 mdb Exp $
|
||||
// $Id: GameConfig.java,v 1.17 2004/03/06 11:29:19 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
/**
|
||||
* The game config class encapsulates the configuration information for a
|
||||
@@ -26,7 +27,7 @@ public abstract class GameConfig extends PlaceConfig
|
||||
{
|
||||
/** The usernames of the players involved in this game, or an empty
|
||||
* array if such information is not needed by this particular game. */
|
||||
public String[] players = new String[0];
|
||||
public Name[] players = new Name[0];
|
||||
|
||||
/** Indicates whether or not this game is rated. */
|
||||
public boolean rated = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameManager.java,v 1.70 2004/02/25 14:44:54 mdb Exp $
|
||||
// $Id: GameManager.java,v 1.71 2004/03/06 11:29:19 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
|
||||
import com.samskivert.util.IntervalManager;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||
@@ -18,9 +19,8 @@ import com.threerings.presents.server.util.SafeInterval;
|
||||
import com.threerings.crowd.chat.server.SpeakProvider;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.CrowdServer;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceManagerDelegate;
|
||||
|
||||
import com.threerings.parlor.Log;
|
||||
@@ -79,7 +79,7 @@ public class GameManager extends PlaceManager
|
||||
* @return the player index at which the player was added, or
|
||||
* <code>-1</code> if the player could not be added to the game.
|
||||
*/
|
||||
public int addPlayer (String player)
|
||||
public int addPlayer (Name player)
|
||||
{
|
||||
// determine the first available player index
|
||||
int pidx = -1;
|
||||
@@ -112,7 +112,7 @@ public class GameManager extends PlaceManager
|
||||
* @param pidx the player index at which the player is to be added.
|
||||
* @return true if the player was added successfully, false if not.
|
||||
*/
|
||||
public boolean addPlayerAt (String player, int pidx)
|
||||
public boolean addPlayerAt (Name player, int pidx)
|
||||
{
|
||||
// make sure the specified player index is valid
|
||||
if (pidx < 0 || pidx >= getPlayerSlots()) {
|
||||
@@ -173,7 +173,7 @@ public class GameManager extends PlaceManager
|
||||
* @param player the username of the player added to the game.
|
||||
* @param pidx the player index of the player added to the game.
|
||||
*/
|
||||
protected void playerWasAdded (String player, int pidx)
|
||||
protected void playerWasAdded (Name player, int pidx)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class GameManager extends PlaceManager
|
||||
* @param player the username of the player to remove from this game.
|
||||
* @return true if the player was successfully removed, false if not.
|
||||
*/
|
||||
public boolean removePlayer (String player)
|
||||
public boolean removePlayer (Name player)
|
||||
{
|
||||
// get the player's index in the player list
|
||||
int pidx = _gameobj.getPlayerIndex(player);
|
||||
@@ -230,7 +230,7 @@ public class GameManager extends PlaceManager
|
||||
* @param pidx the player index of the player before they were removed
|
||||
* from the game.
|
||||
*/
|
||||
protected void playerWasRemoved (String player, int pidx)
|
||||
protected void playerWasRemoved (Name player, int pidx)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -265,18 +265,19 @@ public class GameManager extends PlaceManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the player with the specified index.
|
||||
* Returns the name of the player with the specified index or null if
|
||||
* no player exists at that index.
|
||||
*/
|
||||
public String getPlayerName (int index)
|
||||
public Name getPlayerName (int index)
|
||||
{
|
||||
return (_gameobj == null) ? "" : _gameobj.players[index];
|
||||
return (_gameobj == null) ? null : _gameobj.players[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player index of the given user in the game, or
|
||||
* <code>-1</code> if the player is not involved in the game.
|
||||
*/
|
||||
public int getPlayerIndex (String username)
|
||||
public int getPlayerIndex (Name username)
|
||||
{
|
||||
return (_gameobj == null) ? -1 : _gameobj.getPlayerIndex(username);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
//
|
||||
// $Id: GameObject.dobj,v 1.20 2003/05/26 23:46:46 mdb Exp $
|
||||
// $Id: GameObject.dobj,v 1.21 2004/03/06 11:29:19 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
import com.samskivert.util.ListUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class GameObject extends PlaceObject
|
||||
public boolean isRated;
|
||||
|
||||
/** The usernames of the players involved in this game. */
|
||||
public String[] players;
|
||||
public Name[] players;
|
||||
|
||||
/** Whether each player in the game is a winner, or <code>null</code>
|
||||
* if the game is not yet over. */
|
||||
@@ -75,7 +76,7 @@ public class GameObject extends PlaceObject
|
||||
* Returns the player index of the given user in the game, or
|
||||
* <code>-1</code> if the player is not involved in the game.
|
||||
*/
|
||||
public int getPlayerIndex (String username)
|
||||
public int getPlayerIndex (Name username)
|
||||
{
|
||||
int size = (players == null) ? 0 : players.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
//
|
||||
// $Id: GameObject.java,v 1.17 2004/02/25 14:44:54 mdb Exp $
|
||||
// $Id: GameObject.java,v 1.18 2004/03/06 11:29:19 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
import com.samskivert.util.ListUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
@@ -64,7 +66,7 @@ public class GameObject extends PlaceObject
|
||||
public boolean isRated;
|
||||
|
||||
/** The usernames of the players involved in this game. */
|
||||
public String[] players;
|
||||
public Name[] players;
|
||||
|
||||
/** Whether each player in the game is a winner, or <code>null</code>
|
||||
* if the game is not yet over. */
|
||||
@@ -95,7 +97,7 @@ public class GameObject extends PlaceObject
|
||||
* Returns the player index of the given user in the game, or
|
||||
* <code>-1</code> if the player is not involved in the game.
|
||||
*/
|
||||
public int getPlayerIndex (String username)
|
||||
public int getPlayerIndex (Name username)
|
||||
{
|
||||
int size = (players == null) ? 0 : players.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
@@ -223,7 +225,7 @@ public class GameObject extends PlaceObject
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
public void setPlayers (String[] players)
|
||||
public void setPlayers (Name[] players)
|
||||
{
|
||||
requestAttributeChange(PLAYERS, players);
|
||||
this.players = players;
|
||||
@@ -237,7 +239,7 @@ public class GameObject extends PlaceObject
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
public void setPlayersAt (String value, int index)
|
||||
public void setPlayersAt (Name value, int index)
|
||||
{
|
||||
requestElementUpdate(PLAYERS, value, index);
|
||||
this.players[index] = value;
|
||||
|
||||
Reference in New Issue
Block a user