From e731f6f71d319af5d989b1accfa1a0c7ee9139a3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 31 Aug 2014 03:42:31 -0400 Subject: [PATCH] V0.2.0: Fixed a bug with the item sprite sheet and hard-coded values(ooh, another PC-classes tweak) --- .../shatteredpixeldungeon/Dungeon.java | 7 ++++--- .../items/ItemStatusHandler.java | 16 +++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index e5013d9df..55fa07b5f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -132,6 +132,8 @@ public class Dungeon { public static boolean[] visible = new boolean[Level.LENGTH]; public static boolean nightMode; + + public static int version; public static void init() { @@ -400,7 +402,7 @@ public class Dungeon { try { Bundle bundle = new Bundle(); - bundle.put( VERSION, Game.version ); + bundle.put( VERSION, Game.versionCode ); bundle.put( HERO, hero ); bundle.put( GOLD, gold ); bundle.put( DEPTH, depth ); @@ -556,8 +558,7 @@ public class Dungeon { quickslot = null; } - @SuppressWarnings("unused") - String version = bundle.getString( VERSION ); + version = bundle.getInt( VERSION ); hero = null; hero = (Hero)bundle.get( HERO ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java index acc59c026..4c555235b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/ItemStatusHandler.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -92,20 +93,22 @@ public class ItemStatusHandler { Class item = (Class)(items[i]); String itemName = item.toString(); - if (bundle.contains( itemName + PFX_LABEL )) { + if (bundle.contains( itemName + PFX_LABEL ) && Dungeon.version > 3) { String label = bundle.getString( itemName + PFX_LABEL ); labels.put( item, label ); labelsLeft.remove( label ); - + Integer image = bundle.getInt( itemName + PFX_IMAGE ); images.put( item, image ); imagesLeft.remove( image ); - + if (bundle.getBoolean( itemName + PFX_KNOWN )) { known.add( item ); } - + + //if there's a new item, give it a random image + //or.. if we're loading from an untrusted version, randomize the image to be safe. } else { int index = Random.Int( labelsLeft.size() ); @@ -115,7 +118,10 @@ public class ItemStatusHandler { images.put( item, imagesLeft.get( index ) ); imagesLeft.remove( index ); - + + if (bundle.contains( itemName + PFX_KNOWN ) && bundle.getBoolean( itemName + PFX_KNOWN )) { + known.add( item ); + } } } }