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,12 +92,14 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
} }
} else { } else {
Item item = select(slotNum); Item item = select(slotNum);
if (Dungeon.hero.belongings.contains(item)) {
item.execute(Dungeon.hero); item.execute(Dungeon.hero);
if (item.usesTargeting) { if (item.usesTargeting) {
useTargeting(); useTargeting();
} }
} }
} }
}
@Override @Override
public GameAction keyAction() { public GameAction keyAction() {

View File

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

View File

@ -57,7 +57,9 @@ public class WndUseItem extends WndInfoItem {
protected void onClick() { protected void onClick() {
hide(); hide();
if (owner != null && owner.parent != null) owner.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 ); btn.setSize( btn.reqWidth(), BUTTON_HEIGHT );

View File

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