From 6d5a41d834667d2e86fa0850aab765ac8758e3e1 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Thu, 30 Aug 2001 01:13:08 +0000 Subject: [PATCH] Return a null tile if a non-existent tile id is requested. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@321 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/tile/TileSet.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/media/tile/TileSet.java b/src/java/com/threerings/media/tile/TileSet.java index 7e967a3be..567ef3a0a 100644 --- a/src/java/com/threerings/media/tile/TileSet.java +++ b/src/java/com/threerings/media/tile/TileSet.java @@ -1,5 +1,5 @@ // -// $Id: TileSet.java,v 1.14 2001/08/16 23:14:20 mdb Exp $ +// $Id: TileSet.java,v 1.15 2001/08/30 01:13:08 shaper Exp $ package com.threerings.media.tile; @@ -13,7 +13,7 @@ import com.threerings.media.ImageManager; /** * A tileset stores information on a single logical set of tiles. It - * provides a clean interface for the TileSetManager to + * provides a clean interface for the {@link TileSetManager} to * retrieve individual tiles from the tileset. * *

Tiles are referenced by their tile id. The tile id is @@ -120,17 +120,23 @@ public class TileSet } /** - * Return the Tile object from this tileset - * corresponding to the specified tile id. The tile image is - * retrieved from the given image manager. + * Return the {@link Tile} object from this tileset corresponding + * to the specified tile id, or null if no such tile + * id exists. The tile image is retrieved from the given image + * manager. * * @param imgmgr the image manager. * @param tid the tile identifier. * - * @return the tile object. + * @return the tile object, or null if no such tile exists. */ public Tile getTile (ImageManager imgmgr, int tid) { + // bail if there's no such tile + if (tid > (_numTiles - 1)) { + return null; + } + // create the tile object Tile tile = new Tile(_tsid, tid);