From 1806eb334430f412a2abfdb38b0e681c00d76a22 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 26 Mar 2002 22:58:31 +0000 Subject: [PATCH] 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 --- .../threerings/parlor/game/GameConfig.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/java/com/threerings/parlor/game/GameConfig.java b/src/java/com/threerings/parlor/game/GameConfig.java index 56c89aeac..e20fc5fe1 100644 --- a/src/java/com/threerings/parlor/game/GameConfig.java +++ b/src/java/com/threerings/parlor/game/GameConfig.java @@ -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; -import java.io.IOException; -import java.io.DataInputStream; -import java.io.DataOutputStream; - import com.threerings.crowd.data.PlaceConfig; /** @@ -36,26 +32,30 @@ public abstract class GameConfig extends PlaceConfig /** Indicates whether or not this game is rated. */ public boolean rated = false; - // documentation inherited - public void writeTo (DataOutputStream out) - throws IOException + /** + * Returns true if this game config object is equal to the supplied + * 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); - out.writeBoolean(rated); + if (other instanceof GameConfig) { + GameConfig go = (GameConfig)other; + return go.rated == rated; + + } else { + return false; + } } - // documentation inherited - public void readFrom (DataInputStream in) - throws IOException + /** + * Computes a hashcode for this game config object that supports our + * {@link #equals} implementation. Objects that are equal should have + * the same hashcode. + */ + public int hashCode () { - super.readFrom(in); - rated = in.readBoolean(); - } - - // documentation inherited - protected void toString (StringBuffer buf) - { - super.toString(buf); - buf.append(", rated=").append(rated); + // look ma, it's so sophisticated! + return (rated ? 1 : 0); } }