From 73b7f8c8e930b3982a128707e9b50b3a6b9af37f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 11 Nov 2025 13:20:12 -0500 Subject: [PATCH] v3.3.0: fixed exploit where existing items made imp shop items free --- .../levels/rooms/standard/ImpShopRoom.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java index 213ad898d..d0c338968 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.ImpShopkeeper; +import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; @@ -32,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.watabou.utils.Bundle; import com.watabou.utils.Point; +import com.watabou.utils.Random; import java.util.ArrayList; import java.util.Collection; @@ -100,6 +102,31 @@ public class ImpShopRoom extends ShopRoom { placeItems(level); } + @Override + protected void placeItems(Level level) { + ArrayList existing = new ArrayList<>(); + + //check if there are existing items and remove them + for (Heap h : level.heaps.valueList()){ + if (inside(level.cellToPoint(h.pos))){ + existing.addAll(h.items); + level.heaps.remove(h.pos); + if (h.sprite != null) h.sprite.kill(); + } + } + + super.placeItems(level); + + //place any existing items below the room + if (!existing.isEmpty()){ + int pos = level.pointToCell(new Point(left+2, bottom+2)); + for (Item i :existing){ + level.drop(i, pos + Random.Int(5)); + } + } + + } + public boolean shopSpawned(){ return impSpawned; }