Let the caller know that we're refusing a duplicate interesting object.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3071 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-08-13 20:48:27 +00:00
parent 439f2b2d2b
commit 79da3ac15c
4 changed files with 16 additions and 11 deletions
@@ -1,5 +1,5 @@
// //
// $Id: MisoSceneModel.java,v 1.19 2004/02/25 14:43:57 mdb Exp $ // $Id: MisoSceneModel.java,v 1.20 2004/08/13 20:48:27 mdb Exp $
package com.threerings.miso.data; package com.threerings.miso.data;
@@ -75,8 +75,11 @@ public abstract class MisoSceneModel extends SimpleStreamableObject
/** /**
* Adds an object to this scene. * Adds an object to this scene.
*
* @return true if the object was added, false if the add was rejected
* due to being a duplicate.
*/ */
public abstract void addObject (ObjectInfo info); public abstract boolean addObject (ObjectInfo info);
/** /**
* Updates an object in this scene. * Updates an object in this scene.
@@ -1,5 +1,5 @@
// //
// $Id: SimpleMisoSceneModel.java,v 1.5 2003/04/19 22:40:34 mdb Exp $ // $Id: SimpleMisoSceneModel.java,v 1.6 2004/08/13 20:48:27 mdb Exp $
package com.threerings.miso.data; package com.threerings.miso.data;
@@ -126,7 +126,7 @@ public class SimpleMisoSceneModel extends MisoSceneModel
} }
// documentation inherited // documentation inherited
public void addObject (ObjectInfo info) public boolean addObject (ObjectInfo info)
{ {
if (info.isInteresting()) { if (info.isInteresting()) {
objectInfo = (ObjectInfo[])ArrayUtil.append(objectInfo, info); objectInfo = (ObjectInfo[])ArrayUtil.append(objectInfo, info);
@@ -135,6 +135,7 @@ public class SimpleMisoSceneModel extends MisoSceneModel
objectXs = ArrayUtil.append(objectXs, (short)info.x); objectXs = ArrayUtil.append(objectXs, (short)info.x);
objectYs = ArrayUtil.append(objectYs, (short)info.y); objectYs = ArrayUtil.append(objectYs, (short)info.y);
} }
return true;
} }
// documentation inherited // documentation inherited
@@ -1,5 +1,5 @@
// //
// $Id: SparseMisoSceneModel.java,v 1.13 2004/03/31 02:16:12 eric Exp $ // $Id: SparseMisoSceneModel.java,v 1.14 2004/08/13 20:48:27 mdb Exp $
package com.threerings.miso.data; package com.threerings.miso.data;
@@ -97,14 +97,14 @@ public class SparseMisoSceneModel extends MisoSceneModel
baseTileIds[(row-y)*width+(col-x)] = fqBaseTileId; baseTileIds[(row-y)*width+(col-x)] = fqBaseTileId;
} }
public void addObject (ObjectInfo info) { public boolean addObject (ObjectInfo info) {
// sanity check: see if there is already an object of this // sanity check: see if there is already an object of this
// type at these coordinates // type at these coordinates
if (ListUtil.indexOfEqual(objectInfo, info) != -1 || if (ListUtil.indexOfEqual(objectInfo, info) != -1 ||
indexOfUn(info) != -1) { indexOfUn(info) != -1) {
Log.warning("Refusing to add duplicate interesting " + Log.warning("Refusing to add duplicate interesting " +
"object " + info + "."); "object " + info + ".");
return; return false;
} }
if (info.isInteresting()) { if (info.isInteresting()) {
@@ -114,6 +114,7 @@ public class SparseMisoSceneModel extends MisoSceneModel
objectXs = ArrayUtil.append(objectXs, (short)info.x); objectXs = ArrayUtil.append(objectXs, (short)info.x);
objectYs = ArrayUtil.append(objectYs, (short)info.y); objectYs = ArrayUtil.append(objectYs, (short)info.y);
} }
return true;
} }
public boolean removeObject (ObjectInfo info) { public boolean removeObject (ObjectInfo info) {
@@ -329,9 +330,9 @@ public class SparseMisoSceneModel extends MisoSceneModel
} }
// documentation inherited // documentation inherited
public void addObject (ObjectInfo info) public boolean addObject (ObjectInfo info)
{ {
getSection(info.x, info.y, true).addObject(info); return getSection(info.x, info.y, true).addObject(info);
} }
// documentation inherited // documentation inherited
@@ -1,5 +1,5 @@
// //
// $Id: VirtualMisoSceneModel.java,v 1.4 2004/02/25 14:43:57 mdb Exp $ // $Id: VirtualMisoSceneModel.java,v 1.5 2004/08/13 20:48:27 mdb Exp $
package com.threerings.miso.data; package com.threerings.miso.data;
@@ -21,7 +21,7 @@ public abstract class VirtualMisoSceneModel extends MisoSceneModel
} }
// documentation inherited from interface // documentation inherited from interface
public void addObject (ObjectInfo info) public boolean addObject (ObjectInfo info)
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }