Files
narya/src/java/com/threerings/crowd/data/OccupantInfo.java
T
Michael Bayne 32dee3cbaf 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
2004-03-06 11:29:19 +00:00

77 lines
2.3 KiB
Java

//
// $Id: OccupantInfo.java,v 1.12 2004/03/06 11:29:19 mdb Exp $
package com.threerings.crowd.data;
import com.threerings.io.SimpleStreamableObject;
import com.threerings.util.Name;
import com.threerings.presents.dobj.DSet;
/**
* The occupant info object contains all of the information about an
* occupant of a place that should be shared with other occupants of the
* place. These objects are stored in the place object itself and are
* updated when bodies enter and exit a place.
*
* <p> A system that builds upon the Crowd framework can extend this class
* to include extra information about their occupants. They will need to
* be sure to return the proper class from {@link
* com.threerings.crowd.server.PlaceManager#getOccupantInfoClass} and
* populate their occupant info in {@link
* com.threerings.crowd.server.PlaceManager#populateOccupantInfo}.
*
* <p> Note also that this class implements {@link Cloneable} which means
* that if derived classes add non-primitive attributes, they are
* responsible for adding the code to clone those attributes when a clone
* is requested.
*/
public class OccupantInfo extends SimpleStreamableObject
implements DSet.Entry, Cloneable
{
/** Constant value for {@link #status}. */
public static final byte ACTIVE = 0;
/** Constant value for {@link #status}. */
public static final byte IDLE = 1;
/** Constant value for {@link #status}. */
public static final byte DISCONNECTED = 2;
/** Maps status codes to human readable strings. */
public static final String[] X_STATUS = { "active", "idle", "discon" };
/** The body object id of this occupant (and our entry key). */
public Integer bodyOid;
/** The username of this occupant. */
public Name username;
/** The status of this occupant. */
public byte status = ACTIVE;
/** Access to the body object id as an int. */
public int getBodyOid ()
{
return bodyOid.intValue();
}
// documentation inherited
public Comparable getKey ()
{
return bodyOid;
}
/**
* Generates a cloned copy of this instance.
*/
public Object clone ()
{
try {
return super.clone();
} catch (CloneNotSupportedException cnse) {
throw new RuntimeException("WTF? " + cnse);
}
}
}