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:
@@ -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,34 +170,35 @@ 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
|
// fill in the cache if necessary
|
||||||
if (_tiles[tileIndex] != null) {
|
if (_tiles[tileIndex] == null) {
|
||||||
return _tiles[tileIndex];
|
// get our tileset image
|
||||||
|
Image tsimg = getTileSetImage();
|
||||||
|
if (tsimg == null) {
|
||||||
|
// we already logged an error, so we can just freak out
|
||||||
|
throw new NoSuchTileException(tileIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create, initialize and cache the tile object
|
||||||
|
Tile tile = createTile(tileIndex, tsimg);
|
||||||
|
initTile(tile);
|
||||||
|
// _tiles[tileIndex] = tile;
|
||||||
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get our tileset image
|
return _tiles[tileIndex];
|
||||||
Image tsimg = getTileSetImage();
|
|
||||||
if (tsimg == null) {
|
|
||||||
// we already logged an error, so we can just freak out
|
|
||||||
throw new NoSuchTileException(tileIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create, initialize and cache the tile object
|
|
||||||
Tile tile = createTile(tileIndex, tsimg);
|
|
||||||
initTile(tile);
|
|
||||||
_tiles[tileIndex] = tile;
|
|
||||||
|
|
||||||
return tile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user