diff --git a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java index cba664a27..b092bde56 100644 --- a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java +++ b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java @@ -44,7 +44,7 @@ public class TextureCache { bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; } - public static SmartTexture createSolid( int color ) { + public synchronized static SmartTexture createSolid( int color ) { final String key = "1x1:" + color; if (all.containsKey( key )) { @@ -63,7 +63,7 @@ public class TextureCache { } } - public static SmartTexture createGradient( int... colors ) { + public synchronized static SmartTexture createGradient( int... colors ) { final String key = "" + colors; @@ -88,11 +88,11 @@ public class TextureCache { } - public static void add( Object key, SmartTexture tx ) { + public synchronized static void add( Object key, SmartTexture tx ) { all.put( key, tx ); } - public static void remove( Object key ){ + public synchronized static void remove( Object key ){ SmartTexture tx = all.get( key ); if (tx != null){ all.remove(key); @@ -100,7 +100,7 @@ public class TextureCache { } } - public static SmartTexture get( Object src ) { + public synchronized static SmartTexture get( Object src ) { if (all.containsKey( src )) { @@ -119,17 +119,17 @@ public class TextureCache { } - public static void clear() { + public synchronized static void clear() { - for (Texture txt:all.values()) { + for (Texture txt : all.values()) { txt.delete(); } all.clear(); } - public static void reload() { - for (SmartTexture tx:all.values()) { + public synchronized static void reload() { + for (SmartTexture tx : all.values()) { tx.reload(); } } @@ -164,7 +164,7 @@ public class TextureCache { } } - public static boolean contains( Object key ) { + public synchronized static boolean contains( Object key ) { return all.containsKey( key ); } diff --git a/SPD-classes/src/main/java/com/watabou/noosa/Group.java b/SPD-classes/src/main/java/com/watabou/noosa/Group.java index 5d792ef3d..8756973e7 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/Group.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/Group.java @@ -51,8 +51,10 @@ public class Group extends Gizmo { } } - members.clear(); - members = null; + if (members != null) { + members.clear(); + members = null; + } length = 0; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java index a192489de..bbf8bf5b8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfHealth.java @@ -42,6 +42,8 @@ public class WaterOfHealth extends WellWater { @Override protected boolean affectHero( Hero hero ) { + if (!hero.isAlive()) return false; + Sample.INSTANCE.play( Assets.SND_DRINK ); hero.HP = hero.HT; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java index 7b7d5dfd8..e19e1d277 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mimic.java @@ -62,14 +62,16 @@ public class Mimic extends Mob { @Override public void storeInBundle( Bundle bundle ) { super.storeInBundle( bundle ); - bundle.put( ITEMS, items ); + if (items != null) bundle.put( ITEMS, items ); bundle.put( LEVEL, level ); } @SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { - items = new ArrayList<>( (Collection) ((Collection) bundle.getCollection( ITEMS ) )); + if (bundle.contains( ITEMS )) { + items = new ArrayList<>((Collection) ((Collection) bundle.getCollection(ITEMS))); + } adjustStats( bundle.getInt( LEVEL ) ); super.restoreFromBundle(bundle); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SummoningTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SummoningTrap.java index 2025643f2..6f05f24ff 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SummoningTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/SummoningTrap.java @@ -77,10 +77,12 @@ public class SummoningTrap extends Trap { for (Integer point : respawnPoints) { Mob mob = Dungeon.level.createMob(); - mob.state = mob.WANDERING; - mob.pos = point; - GameScene.add( mob, DELAY ); - mobs.add( mob ); + if (mob != null) { + mob.state = mob.WANDERING; + mob.pos = point; + GameScene.add(mob, DELAY); + mobs.add(mob); + } } //important to process the visuals and pressing of cells last, so spawned mobs have a chance to occupy cells first diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndAlchemy.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndAlchemy.java index 76c5672dc..1bbf7cf73 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndAlchemy.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndAlchemy.java @@ -302,7 +302,7 @@ public class WndAlchemy extends Window { public void destroy() { synchronized ( inputs ) { for (int i = 0; i < inputs.length; i++) { - if (inputs[i].item != null) { + if (inputs[i] != null && inputs[i].item != null) { if (!inputs[i].item.collect()) { Dungeon.level.drop(inputs[i].item, Dungeon.hero.pos); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index f1fd6e2a7..6ff77103b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -213,7 +213,7 @@ public class WndBag extends WndTabbed { } // Items in the bag - for (Item item : container.items) { + for (Item item : container.items.toArray(new Item[0])) { placeItem( item ); }