Added equals() and hashCode() so that we can compare game configurations;
removed serialization code because SimpleStreamableObject now automatically handles it. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1153 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameConfig.java,v 1.7 2001/10/11 21:08:21 mdb Exp $
|
// $Id: GameConfig.java,v 1.8 2002/03/26 22:58:31 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.game;
|
package com.threerings.parlor.game;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
import com.threerings.crowd.data.PlaceConfig;
|
import com.threerings.crowd.data.PlaceConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,26 +32,30 @@ public abstract class GameConfig extends PlaceConfig
|
|||||||
/** Indicates whether or not this game is rated. */
|
/** Indicates whether or not this game is rated. */
|
||||||
public boolean rated = false;
|
public boolean rated = false;
|
||||||
|
|
||||||
// documentation inherited
|
/**
|
||||||
public void writeTo (DataOutputStream out)
|
* Returns true if this game config object is equal to the supplied
|
||||||
throws IOException
|
* object (meaning it is also a game config object and its
|
||||||
|
* configuration settings are the same as ours).
|
||||||
|
*/
|
||||||
|
public boolean equals (Object other)
|
||||||
{
|
{
|
||||||
super.writeTo(out);
|
if (other instanceof GameConfig) {
|
||||||
out.writeBoolean(rated);
|
GameConfig go = (GameConfig)other;
|
||||||
|
return go.rated == rated;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
/**
|
||||||
public void readFrom (DataInputStream in)
|
* Computes a hashcode for this game config object that supports our
|
||||||
throws IOException
|
* {@link #equals} implementation. Objects that are equal should have
|
||||||
|
* the same hashcode.
|
||||||
|
*/
|
||||||
|
public int hashCode ()
|
||||||
{
|
{
|
||||||
super.readFrom(in);
|
// look ma, it's so sophisticated!
|
||||||
rated = in.readBoolean();
|
return (rated ? 1 : 0);
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
protected void toString (StringBuffer buf)
|
|
||||||
{
|
|
||||||
super.toString(buf);
|
|
||||||
buf.append(", rated=").append(rated);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user