Removed crack pipe, inserted call to super.clone().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1702 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-09-17 21:29:26 +00:00
parent 80ac8a280f
commit 234d7d6971
+12 -11
View File
@@ -1,5 +1,5 @@
// //
// $Id: TileSet.java,v 1.31 2002/09/17 21:17:15 mdb Exp $ // $Id: TileSet.java,v 1.32 2002/09/17 21:29:26 mdb Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
@@ -132,7 +132,7 @@ public abstract class TileSet
public Object clone () public Object clone ()
throws CloneNotSupportedException throws CloneNotSupportedException
{ {
TileSet dup = (TileSet)clone(); TileSet dup = (TileSet)super.clone();
// clear out the tileset cache // clear out the tileset cache
dup._tiles = null; dup._tiles = null;
return dup; return dup;
@@ -170,21 +170,20 @@ public abstract class TileSet
public Tile getTile (int tileIndex) public Tile getTile (int tileIndex)
throws NoSuchTileException throws NoSuchTileException
{ {
int tcount = getTileCount();
// bail if there's no such tile // bail if there's no such tile
if (tileIndex < 0 || tileIndex >= getTileCount()) { if (tileIndex < 0 || tileIndex >= tcount) {
throw new NoSuchTileException(tileIndex); throw new NoSuchTileException(tileIndex);
} }
// create our tile cache array if necessary // create our tile cache array if necessary
if (_tiles == null) { if (_tiles == null) {
_tiles = new Tile[getTileCount()]; _tiles = new Tile[tcount];
}
// return the cached tile if possible
if (_tiles[tileIndex] != null) {
return _tiles[tileIndex];
} }
// fill in the cache if necessary
if (_tiles[tileIndex] == null) {
// get our tileset image // get our tileset image
Image tsimg = getTileSetImage(); Image tsimg = getTileSetImage();
if (tsimg == null) { if (tsimg == null) {
@@ -195,11 +194,13 @@ public abstract class TileSet
// create, initialize and cache the tile object // create, initialize and cache the tile object
Tile tile = createTile(tileIndex, tsimg); Tile tile = createTile(tileIndex, tsimg);
initTile(tile); initTile(tile);
_tiles[tileIndex] = tile; // _tiles[tileIndex] = tile;
return tile; return tile;
} }
return _tiles[tileIndex];
}
/** /**
* Computes and returns the bounds for the specified tile based on the * Computes and returns the bounds for the specified tile based on the
* mechanism used by the derived class to do such things. The width * mechanism used by the derived class to do such things. The width