v2.1.1: fixed crash errors with inventory radial menu and targeting

This commit is contained in:
Evan Debenham
2023-06-05 23:29:14 -04:00
parent c9bed0e0cb
commit 604dead311
3 changed files with 7 additions and 1 deletions
@@ -404,10 +404,15 @@ public class InventoryPane extends Component {
return selector != null; return selector != null;
} }
public static void clearTargetingSlot(){
targetingSlot = null;
}
public static void useTargeting(){ public static void useTargeting(){
if (instance != null && if (instance != null &&
instance.visible && instance.visible &&
lastTarget != null && lastTarget != null &&
targetingSlot != null &&
Actor.chars().contains( lastTarget ) && Actor.chars().contains( lastTarget ) &&
lastTarget.isAlive() && lastTarget.isAlive() &&
lastTarget.alignment != Char.Alignment.ALLY && lastTarget.alignment != Char.Alignment.ALLY &&
@@ -463,6 +463,7 @@ public class Toolbar extends Component {
if (alt && item.defaultAction() != null) { if (alt && item.defaultAction() != null) {
item.execute(Dungeon.hero); item.execute(Dungeon.hero);
} else { } else {
InventoryPane.clearTargetingSlot();
Game.scene().addToFront(new WndUseItem(null, item)); Game.scene().addToFront(new WndUseItem(null, item));
} }
} }
@@ -55,7 +55,7 @@ public class WndUseItem extends WndInfoItem {
item.execute( Dungeon.hero, action ); item.execute( Dungeon.hero, action );
} }
Item.updateQuickslot(); Item.updateQuickslot();
if (action == item.defaultAction() && item.usesTargeting && owner == null){ if (action.equals(item.defaultAction()) && item.usesTargeting && owner == null){
InventoryPane.useTargeting(); InventoryPane.useTargeting();
} }
} }