From b104ad197dbb0e7c41daa2b31c591c3f988557ba Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 24 Oct 2016 13:55:59 -0400 Subject: [PATCH] v0.4.3a: fixed nullpointer exceptions caused by new blob bundle restore behaviour --- .../shatteredpixeldungeon/actors/blobs/Alchemy.java | 11 ++++++----- .../shatteredpixeldungeon/actors/blobs/Blob.java | 2 +- .../shatteredpixeldungeon/actors/blobs/WellWater.java | 11 ++++++----- .../items/potions/PotionOfPurity.java | 2 +- .../shatteredpixeldungeon/windows/WndInfoCell.java | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Alchemy.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Alchemy.java index 803f094cc..0a517edda 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Alchemy.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Alchemy.java @@ -37,12 +37,13 @@ public class Alchemy extends Blob { public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - for (int i=0; i < cur.length; i++) { - if (cur[i] > 0) { - pos = i; - break; + if (volume > 0) + for (int i=0; i < cur.length; i++) { + if (cur[i] > 0) { + pos = i; + break; + } } - } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java index 943ce21f8..8ae024bab 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/Blob.java @@ -245,7 +245,7 @@ public class Blob extends Actor { public static int volumeAt( int cell, Class type){ Blob gas = Dungeon.level.blobs.get( type ); - if (gas == null) { + if (gas == null || gas.volume == 0) { return 0; } else { return gas.cur[cell]; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WellWater.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WellWater.java index ff64da9e4..234c511c3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WellWater.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WellWater.java @@ -41,12 +41,13 @@ public class WellWater extends Blob { public void restoreFromBundle( Bundle bundle ) { super.restoreFromBundle( bundle ); - for (int i=0; i < cur.length; i++) { - if (cur[i] > 0) { - pos = i; - break; + if (volume > 0) + for (int i=0; i < cur.length; i++) { + if (cur[i] > 0) { + pos = i; + break; + } } - } } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfPurity.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfPurity.java index 11da1dead..5f6b4e6af 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfPurity.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfPurity.java @@ -66,7 +66,7 @@ public class PotionOfPurity extends Potion { for (int j=0; j < blobs.length; j++) { Blob blob = blobs[j]; - if (blob == null) { + if (blob == null || blob.volume == 0) { continue; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoCell.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoCell.java index a6fd313c6..781bd03bd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoCell.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoCell.java @@ -89,7 +89,7 @@ public class WndInfoCell extends Window { add(info); for (Blob blob:Dungeon.level.blobs.values()) { - if (blob.cur[cell] > 0 && blob.tileDesc() != null) { + if (blob.volume > 0 && blob.cur[cell] > 0 && blob.tileDesc() != null) { if (desc.length() > 0) { desc += "\n\n"; }