Sanity check our orientation in setOrientation() and complain sensically

if it's bogus (rather than NPEing).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1251 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-04-15 23:07:14 +00:00
parent ccdacd96d5
commit 1678b84227
@@ -1,5 +1,5 @@
//
// $Id: CharacterSprite.java,v 1.25 2002/03/16 03:15:04 shaper Exp $
// $Id: CharacterSprite.java,v 1.26 2002/04/15 23:07:14 mdb Exp $
package com.threerings.cast;
@@ -117,6 +117,14 @@ public class CharacterSprite extends ImageSprite
{
super.setOrientation(orient);
// sanity check
if (orient < 0 || orient >= _frames.length) {
String errmsg = "Invalid orientation requested " +
"[orient=" + orient +
", fcount=" + ((_frames == null) ? -1 : _frames.length) + "]";
throw new IllegalArgumentException(errmsg);
}
// update the sprite frames to reflect the direction
if (_frames != null) {
setFrames(_frames[orient]);