v0.6.2a: added safety checks to some usages of curItem

This commit is contained in:
Evan Debenham
2017-11-01 01:49:31 -04:00
parent 0ce6f14a73
commit 3a6ae784f7
3 changed files with 23 additions and 2 deletions

View File

@@ -73,6 +73,13 @@ public abstract class InventoryScroll extends Scroll {
protected static WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
//FIXME this safety check shouldn't be necessary
//it would be better to eliminate the curItem static variable.
if (!(curItem instanceof InventoryScroll)){
return;
}
if (item != null) {
((InventoryScroll)curItem).onItemSelected( item );

View File

@@ -75,6 +75,13 @@ public abstract class InventoryStone extends Runestone {
protected static WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
//FIXME this safety check shouldn't be necessary
//it would be better to eliminate the curItem static variable.
if (!(curItem instanceof InventoryStone)){
return;
}
if (item != null) {
((InventoryStone)curItem).onItemSelected( item );

View File

@@ -347,8 +347,15 @@ public abstract class Wand extends Item {
public void onSelect( Integer target ) {
if (target != null) {
final Wand curWand = (Wand)Wand.curItem;
//FIXME this safety check shouldn't be necessary
//it would be better to eliminate the curItem static variable.
final Wand curWand;
if (curItem instanceof Wand) {
curWand = (Wand) Wand.curItem;
} else {
return;
}
final Ballistica shot = new Ballistica( curUser.pos, target, curWand.collisionProperties);
int cell = shot.collisionPos;