Added an isPrivate variable to GameObject.
Set it if a table game is created as being private. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3738 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -49,6 +49,9 @@ public class GameObject extends PlaceObject
|
|||||||
/** The field name of the <code>isRated</code> field. */
|
/** The field name of the <code>isRated</code> field. */
|
||||||
public static final String IS_RATED = "isRated";
|
public static final String IS_RATED = "isRated";
|
||||||
|
|
||||||
|
/** The field name of the <code>isPrivate</code> field. */
|
||||||
|
public static final String IS_PRIVATE = "isPrivate";
|
||||||
|
|
||||||
/** The field name of the <code>players</code> field. */
|
/** The field name of the <code>players</code> field. */
|
||||||
public static final String PLAYERS = "players";
|
public static final String PLAYERS = "players";
|
||||||
|
|
||||||
@@ -93,6 +96,9 @@ public class GameObject extends PlaceObject
|
|||||||
/** Indicates whether or not this game is rated. */
|
/** Indicates whether or not this game is rated. */
|
||||||
public boolean isRated;
|
public boolean isRated;
|
||||||
|
|
||||||
|
/** Indicates whether the game is "private". */
|
||||||
|
public boolean isPrivate;
|
||||||
|
|
||||||
/** The usernames of the players involved in this game. */
|
/** The usernames of the players involved in this game. */
|
||||||
public Name[] players;
|
public Name[] players;
|
||||||
|
|
||||||
@@ -289,6 +295,22 @@ public class GameObject extends PlaceObject
|
|||||||
this.isRated = value;
|
this.isRated = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the <code>isPrivate</code> field be set to the
|
||||||
|
* specified value. The local value will be updated immediately and an
|
||||||
|
* event will be propagated through the system to notify all listeners
|
||||||
|
* that the attribute did change. Proxied copies of this object (on
|
||||||
|
* clients) will apply the value change when they received the
|
||||||
|
* attribute changed notification.
|
||||||
|
*/
|
||||||
|
public void setIsPrivate (boolean value)
|
||||||
|
{
|
||||||
|
boolean ovalue = this.isPrivate;
|
||||||
|
requestAttributeChange(
|
||||||
|
IS_PRIVATE, new Boolean(value), new Boolean(ovalue));
|
||||||
|
this.isPrivate = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the <code>players</code> field be set to the
|
* Requests that the <code>players</code> field be set to the
|
||||||
* specified value. The local value will be updated immediately and an
|
* specified value. The local value will be updated immediately and an
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.samskivert.util.HashIntMap;
|
|||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
|
import com.threerings.presents.dobj.ChangeListener;
|
||||||
import com.threerings.presents.dobj.ObjectAddedEvent;
|
import com.threerings.presents.dobj.ObjectAddedEvent;
|
||||||
import com.threerings.presents.dobj.ObjectDeathListener;
|
import com.threerings.presents.dobj.ObjectDeathListener;
|
||||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||||
@@ -47,6 +48,7 @@ import com.threerings.parlor.data.Table;
|
|||||||
import com.threerings.parlor.data.TableConfig;
|
import com.threerings.parlor.data.TableConfig;
|
||||||
import com.threerings.parlor.data.TableLobbyObject;
|
import com.threerings.parlor.data.TableLobbyObject;
|
||||||
import com.threerings.parlor.game.data.GameConfig;
|
import com.threerings.parlor.game.data.GameConfig;
|
||||||
|
import com.threerings.parlor.game.data.GameObject;
|
||||||
import com.threerings.parlor.game.server.GameManager;
|
import com.threerings.parlor.game.server.GameManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,6 +287,9 @@ public class TableManager
|
|||||||
// update the table with the newly created game object
|
// update the table with the newly created game object
|
||||||
table.gameOid = plobj.getOid();
|
table.gameOid = plobj.getOid();
|
||||||
|
|
||||||
|
// configure the privacy of the game
|
||||||
|
((GameObject) plobj).setIsPrivate(table.tconfig.privateTable);
|
||||||
|
|
||||||
// clear the occupant to table mappings as this game is underway
|
// clear the occupant to table mappings as this game is underway
|
||||||
for (int i = 0; i < table.bodyOids.length; i++) {
|
for (int i = 0; i < table.bodyOids.length; i++) {
|
||||||
_boidMap.remove(table.bodyOids[i]);
|
_boidMap.remove(table.bodyOids[i]);
|
||||||
@@ -292,11 +297,7 @@ public class TableManager
|
|||||||
|
|
||||||
// add an object death listener to unmap the table when the game
|
// add an object death listener to unmap the table when the game
|
||||||
// finally goes away
|
// finally goes away
|
||||||
plobj.addListener(new ObjectDeathListener() {
|
plobj.addListener(_gameDeathListener);
|
||||||
public void objectDestroyed (ObjectDestroyedEvent event) {
|
|
||||||
unmapTable(event.getTargetOid());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// and then update the lobby object that contains the table
|
// and then update the lobby object that contains the table
|
||||||
_tlobj.updateTables(table);
|
_tlobj.updateTables(table);
|
||||||
@@ -370,4 +371,11 @@ public class TableManager
|
|||||||
|
|
||||||
/** A mapping from body oid to table. */
|
/** A mapping from body oid to table. */
|
||||||
protected HashIntMap _boidMap = new HashIntMap();
|
protected HashIntMap _boidMap = new HashIntMap();
|
||||||
|
|
||||||
|
/** A listener that prunes tables after the game dies. */
|
||||||
|
protected ChangeListener _gameDeathListener = new ObjectDeathListener() {
|
||||||
|
public void objectDestroyed (ObjectDestroyedEvent event) {
|
||||||
|
unmapTable(event.getTargetOid());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user