v0.9.3: fixed various exploits caused by window stacking and multitaps

This commit is contained in:
Evan Debenham 2021-04-10 22:49:37 -04:00
parent 3429381d2a
commit 0095fe726d
4 changed files with 28 additions and 7 deletions

View File

@ -92,9 +92,11 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
}
} else {
Item item = select(slotNum);
item.execute( Dungeon.hero );
if (item.usesTargeting) {
useTargeting();
if (Dungeon.hero.belongings.contains(item)) {
item.execute(Dungeon.hero);
if (item.usesTargeting) {
useTargeting();
}
}
}
}

View File

@ -34,11 +34,19 @@ public class WndInfoItem extends Window {
private static final int WIDTH_MIN = 120;
private static final int WIDTH_MAX = 220;
//only one WndInfoItem can appear at a time
private static WndInfoItem INSTANCE;
public WndInfoItem( Heap heap ) {
super();
if (INSTANCE != null){
INSTANCE.hide();
}
INSTANCE = this;
if (heap.type == Heap.Type.HEAP) {
fillFields( heap.peek() );
@ -50,6 +58,11 @@ public class WndInfoItem extends Window {
public WndInfoItem( Item item ) {
super();
if (INSTANCE != null){
INSTANCE.hide();
}
INSTANCE = this;
fillFields( item );
}

View File

@ -57,7 +57,9 @@ public class WndUseItem extends WndInfoItem {
protected void onClick() {
hide();
if (owner != null && owner.parent != null) owner.hide();
if (Dungeon.hero.isAlive()) item.execute( Dungeon.hero, action );
if (Dungeon.hero.isAlive() && Dungeon.hero.belongings.contains(item)){
item.execute( Dungeon.hero, action );
}
}
};
btn.setSize( btn.reqWidth(), BUTTON_HEIGHT );

View File

@ -136,7 +136,11 @@ public class WndWandmaker extends Window {
}
@Override
protected void onClick() {
ShatteredPixelDungeon.scene().addToFront(new RewardWindow(item));
if (Dungeon.hero.belongings.contains(item)) {
ShatteredPixelDungeon.scene().addToFront(new RewardWindow(item));
} else {
hide();
}
}
};
add(slot);