From 1da61b99c7bca9d042796e83325b26f1223cc689 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 22 Apr 2003 01:57:20 +0000 Subject: [PATCH] Disallow adding the same object in the same place twice. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2441 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/miso/client/SceneBlock.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/miso/client/SceneBlock.java b/src/java/com/threerings/miso/client/SceneBlock.java index f862c57ac..e788c5d05 100644 --- a/src/java/com/threerings/miso/client/SceneBlock.java +++ b/src/java/com/threerings/miso/client/SceneBlock.java @@ -1,5 +1,5 @@ // -// $Id: SceneBlock.java,v 1.5 2003/04/21 17:08:56 mdb Exp $ +// $Id: SceneBlock.java,v 1.6 2003/04/22 01:57:20 mdb Exp $ package com.threerings.miso.client; @@ -186,15 +186,27 @@ public class SceneBlock * Adds the supplied object to this block. Coverage is not computed * for the added object, a subsequent call to {@link #update} will be * needed. + * + * @return true if the object was added, false if it was not because + * another object of the same type already occupies that location. */ - public void addObject (ObjectInfo info) + public boolean addObject (ObjectInfo info) { + // make sure we don't already have this same object at these + // coordinates + for (int ii = 0; ii < _objects.length; ii++) { + if (_objects[ii].info.equals(info)) { + return false; + } + } + _objects = (SceneObject[]) ArrayUtil.append(_objects, new SceneObject(_panel, info)); // clear out our neighbors array so that the subsequent update // causes us to recompute our coverage Arrays.fill(_neighbors, null); + return true; } /**