Don't attempt to put a tile in the tile cache if we didn't retrieve it

from the tileset manager successfully.  Cleaned up comments.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@350 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-09-28 00:44:31 +00:00
parent 33854265f8
commit da1484a019
@@ -1,5 +1,5 @@
// //
// $Id: TileManager.java,v 1.16 2001/09/17 05:18:21 mdb Exp $ // $Id: TileManager.java,v 1.17 2001/09/28 00:44:31 shaper Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
@@ -12,16 +12,15 @@ import com.samskivert.util.HashIntMap;
import com.threerings.media.Log; import com.threerings.media.Log;
/** /**
* The <code>TileManager</code> class provides a simplified interface * The tile manager provides a simplified interface for retrieving and
* for retrieving and caching tiles. * caching tiles.
* *
* @see TileSetManager * @see TileSetManager
*/ */
public class TileManager public class TileManager
{ {
/** /**
* Initialize the tile manager with the given * Initialize the tile manager.
* <code>TileSetManager</code> object.
* *
* @param tilesetmgr the tileset manager. * @param tilesetmgr the tileset manager.
*/ */
@@ -31,13 +30,13 @@ public class TileManager
} }
/** /**
* Return the <code>Tile</code> object for the specified tileset * Returns the {@link Tile} object for the specified tileset and
* and tile id. * tile id, or null if an error occurred.
* *
* @param tsid the tileset id. * @param tsid the tileset id.
* @param tid the tile id. * @param tid the tile id.
* *
* @return the tile object. * @return the tile object, or null if an error occurred.
*/ */
public Tile getTile (int tsid, int tid) public Tile getTile (int tsid, int tid)
{ {
@@ -47,22 +46,24 @@ public class TileManager
// look the tile up in our hash // look the tile up in our hash
Tile tile = (Tile) _tiles.get(utid); Tile tile = (Tile) _tiles.get(utid);
if (tile != null) { if (tile != null) {
// Log.info("Retrieved tile from cache [tsid=" + tsid + // Log.info("Retrieved tile from cache [tsid=" + tsid +
// ", tid=" + tid + "]."); // ", tid=" + tid + "].");
return tile; return tile;
} }
// retrieve the tile from the tileset // retrieve the tile from the tileset
tile = _tilesetmgr.getTile(tsid, tid); tile = _tilesetmgr.getTile(tsid, tid);
_tiles.put(utid, tile); if (tile != null) {
// Log.info("Loaded tile into cache [tsid=" + tsid +
// Log.info("Loaded tile into cache [tsid="+tsid+", tid="+tid+"]."); // ", tid=" + tid + "].");
_tiles.put(utid, tile);
}
return tile; return tile;
} }
/** /**
* Return the TileSetManager that the TileManager is using. * Returns the tile set manager used by this tile manager.
*/ */
public TileSetManager getTileSetManager () public TileSetManager getTileSetManager ()
{ {