v0.6.0: improved logic for old data conversion, dropped support for saves from before 0.4.0

This commit is contained in:
Evan Debenham 2017-03-08 22:02:46 -05:00
parent c120a78239
commit a678549dd3
18 changed files with 83 additions and 340 deletions

View File

@ -662,10 +662,8 @@ public class Dungeon {
public static void preview( GamesInProgress.Info info, Bundle bundle ) {
info.depth = bundle.getInt( DEPTH );
info.version = bundle.getInt( VERSION );
info.challenges = (bundle.getInt( CHALLENGES ) != 0);
if (info.depth == -1) {
info.depth = bundle.getInt( "maxDepth" ); // FIXME
}
Hero.preview( info, bundle.getBundle( HERO ) );
}

View File

@ -45,6 +45,11 @@ public class GamesInProgress {
Bundle bundle = Dungeon.gameBundle( Dungeon.gameFile( cl ) );
info = new Info();
Dungeon.preview( info, bundle );
//saves from before 0.4.0 are not supported
if (info.version < ShatteredPixelDungeon.v0_4_0){
info = null;
}
} catch (IOException e) {
info = null;
@ -75,6 +80,7 @@ public class GamesInProgress {
public static class Info {
public int depth;
public int level;
public int version;
public boolean challenges;
}
}

View File

@ -21,29 +21,15 @@
package com.shatteredpixel.shatteredpixeldungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.DM300;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Goo;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Tengu;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Yog;
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.watabou.noosa.Game;
@ -56,7 +42,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Locale;
import java.util.UUID;
public enum Rankings {
@ -211,6 +196,7 @@ public enum Rankings {
} catch (IOException e) {
ShatteredPixelDungeon.reportException(e);
}
}
public void load() {
@ -250,11 +236,7 @@ public enum Rankings {
}
public static class Record implements Bundlable {
//pre 0.3.4
public String info;
private static final String REASON = "reason";
//pre 0.4.1
public String gameFile;
private static final String FILE = "gameFile";
@ -283,16 +265,7 @@ public enum Rankings {
public String desc(){
if (cause == null) {
if (info != null){
//support for pre-0.3.4 saves
if (Messages.lang() == Languages.ENGLISH) {
return info;
} else {
return Messages.get(this, "something");
}
} else {
return Messages.get(this, "something");
}
return Messages.get(this, "something");
} else {
String result = Messages.get(cause, "rankings_desc", (Messages.get(cause, "name")));
if (result.contains("!!!NO TEXT FOUND!!!")){
@ -305,31 +278,13 @@ public enum Rankings {
@Override
public void restoreFromBundle( Bundle bundle ) {
//conversion logic for pre-0.3.4 saves
if (bundle.contains( REASON )){
String info = bundle.getString( REASON ).toLowerCase(Locale.ENGLISH);
if (info.equals("obtained the amulet of yendor")) cause = Amulet.class;
else if (info.contains("goo")) cause = Goo.class;
else if (info.contains("tengu")) cause = Tengu.class;
else if (info.contains("dm-300")) cause = DM300.class;
else if (info.contains("king")) cause = King.class;
else if (info.contains("yog")) cause = Yog.class;
else if (info.contains("fist")) cause = Yog.class;
else if (info.contains("larva")) cause = Yog.class;
else if (info.equals("burned to ash")) cause = Burning.class;
else if (info.equals("starved to death")) cause = Hunger.class;
else if (info.equals("succumbed to poison")) cause = Poison.class;
else if (info.equals("suffocated")) cause = ToxicGas.class;
else if (info.equals("bled to death")) cause = Bleeding.class;
else if (info.equals("melted away")) cause = Ooze.class;
else if (info.equals("died on impact")) cause = Chasm.class;
//can't get the all, just keep what remains as-is
else this.info = info;
} else {
if (bundle.contains( CAUSE )) {
cause = bundle.getClass( CAUSE );
} else {
cause = null;
}
win = bundle.getBoolean( WIN );
score = bundle.getInt( SCORE );
@ -348,8 +303,7 @@ public enum Rankings {
@Override
public void storeInBundle( Bundle bundle ) {
if (info != null) bundle.put( REASON, info );
else bundle.put( CAUSE, cause );
if (cause != null) bundle.put( CAUSE, cause );
bundle.put( WIN, win );
bundle.put( SCORE, score );

View File

@ -43,129 +43,18 @@ import javax.microedition.khronos.opengles.GL10;
public class ShatteredPixelDungeon extends Game {
//variable constants for specific older versions of shattered, used for data conversion
//versions older than v0.4.0 are no longer supported, and data from them is ignored
public static final int v0_4_0 = 107;
public static final int v0_4_1 = 114;
public static final int v0_4_2b = 129;
public static final int v0_5_0b = 157;
public ShatteredPixelDungeon() {
super( WelcomeScene.class );
// 0.2.4
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Piercing" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Swing" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade" );
// 0.2.4d
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon.class,
"com.shatteredpixel.shatteredpixeldungeon.items.LloydsBeacon" );
// 0.3.0, lots of wands
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfVenom.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfPoison" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFrost.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfSlowness" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFirebolt" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorruption.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfAmok" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTelekinesis" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFlock" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfAvalanche" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlink" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile.class,
"com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTeleportation" );
//0.3.3
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.actors.mobs.FetidRat.class,
"com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost$FetidRat" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GnollTrickster.class,
"com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost$GnollTrickster" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.actors.mobs.GreatCrab.class,
"com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost$GreatCrab" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry.class,
"com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker$Rotberry" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry.Seed.class,
"com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker$Rotberry$Seed" );
//0.4.0
//equipment
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WornShortsword.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.ShortSword" );
//enchants/glyphs
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Grim.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Death" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Blazing.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Fire" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Eldritch.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Horror" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Unstable.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Instability" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Vampiric.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Leech" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Lucky.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Luck" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Stunning.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Paralysis" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Venomous.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Poison" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shocking.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Shock" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Chilling.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.enchantments.Slow" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Bounce" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Displacement" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Potential.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiEntropy" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Entanglement.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Metabolism" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Entanglement.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Multiplicity" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Repulsion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.Stench" );
//0.6.0
//v0.6.0
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom.Bones.class,
"com.shatteredpixel.shatteredpixeldungeon.levels.painters.MassGravePainter.Bones.class" );
@ -175,6 +64,10 @@ public class ShatteredPixelDungeon extends Game {
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom.HiddenWell.class,
"com.shatteredpixel.shatteredpixeldungeon.levels.painters.WeakFloorPainter.HiddenWell.class" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword.class,
"com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.NewShortSword" );
com.watabou.utils.Bundle.exceptionReporter =
new com.watabou.utils.Bundle.BundleExceptionCallback() {

View File

@ -102,20 +102,10 @@ public class Belongings implements Iterable<Item> {
specialKeys[((Key) item).depth] += item.quantity();
}
}
if (bundle.get( WEAPON ) instanceof Wand){
//handles the case of an equipped wand from pre-0.3.0
Wand item = (Wand) bundle.get(WEAPON);
//try to add the wand to inventory
if (!item.collect(backpack)){
//if it's too full, shove it in anyway
backpack.items.add(item);
}
} else {
weapon = (KindOfWeapon) bundle.get(WEAPON);
if (weapon != null) {
weapon.activate(owner);
}
weapon = (KindOfWeapon) bundle.get(WEAPON);
if (weapon != null) {
weapon.activate(owner);
}
armor = (Armor)bundle.get( ARMOR );

View File

@ -43,7 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ScaleArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.NewShortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.levels.SewerLevel;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@ -302,7 +302,7 @@ public class Ghost extends NPC {
} while (!(weapon instanceof MeleeWeapon));
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
weapon = new NewShortsword();
weapon = new Shortsword();
}
//50%:+0, 30%:+1, 15%:+2, 5%:+3

View File

@ -229,12 +229,7 @@ public class Wandmaker extends NPC {
if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
//TODO remove when pre-0.3.2 saves are no longer supported
if (node.contains(TYPE)) {
type = node.getInt(TYPE);
} else {
type = node.getBoolean("alternative")? 1 : 3;
}
type = node.getInt(TYPE);
given = node.getBoolean( GIVEN );

View File

@ -113,12 +113,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.NewShortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Quarterstaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RoundShield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RunicBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sai;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Scimitar;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Spear;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer;
@ -273,7 +273,7 @@ public class Generator {
Category.WEP_T1.probs = new float[]{ 1, 1, 1, 0, 0, 1 };
Category.WEP_T2.classes = new Class<?>[]{
NewShortsword.class,
Shortsword.class,
HandAxe.class,
Spear.class,
Quarterstaff.class,

View File

@ -40,7 +40,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
@ -430,7 +429,6 @@ public class Item implements Bundlable {
private static final String LEVEL_KNOWN = "levelKnown";
private static final String CURSED = "cursed";
private static final String CURSED_KNOWN = "cursedKnown";
private static final String OLDSLOT = "quickslot";
private static final String QUICKSLOT = "quickslotpos";
@Override
@ -462,10 +460,7 @@ public class Item implements Bundlable {
//only want to populate slot on first load.
if (Dungeon.hero == null) {
//support for pre-0.2.3 saves and rankings
if (bundle.contains(OLDSLOT)) {
Dungeon.quickslot.setSlot(0, this);
} else if (bundle.contains(QUICKSLOT)) {
if (bundle.contains(QUICKSLOT)) {
Dungeon.quickslot.setSlot(bundle.getInt(QUICKSLOT), this);
}
}

View File

@ -89,20 +89,8 @@ abstract public class ClassArmor extends Armor {
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
//logic for pre-0.4.0 saves
if (bundle.contains( "DR" )){
//we just assume tier-4 or tier-5 armor was used.
int DR = bundle.getInt( "DR" );
if (DR % 5 == 0){
level((DR - 10)/5);
armorTier = 5;
} else {
level((DR - 8)/4);
armorTier = 4;
}
} else {
armorTier = bundle.getInt( ARMOR_TIER );
}
armorTier = bundle.getInt( ARMOR_TIER );
}
@Override

View File

@ -170,12 +170,6 @@ public class UnstableSpellbook extends Artifact {
super.restoreFromBundle(bundle);
scrolls.clear();
Collections.addAll(scrolls, bundle.getClassArray(SCROLLS));
if (scrolls.contains(null)){
//compatability with pre-0.3.4, just give them a maxed book.
scrolls.clear();
level(levelCap);
chargeCap = 8;
}
}
public class bookRecharge extends ArtifactBuff{

View File

@ -23,8 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
//this class is named as such to avoid conflicts with the ShortSword class, from pre-0.4.0
public class NewShortsword extends MeleeWeapon {
public class Shortsword extends MeleeWeapon {
{
image = ItemSpriteSheet.SHORTSWORD;

View File

@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
@ -305,6 +306,11 @@ public abstract class Level implements Bundlable {
public void restoreFromBundle( Bundle bundle ) {
version = bundle.getInt( VERSION );
//saves from before 0.4.0 are not supported
if (version < ShatteredPixelDungeon.v0_4_0){
throw new RuntimeException("old save");
}
if (bundle.contains("width") && bundle.contains("height")){
width = bundle.getInt("width");
@ -334,13 +340,8 @@ public abstract class Level implements Bundlable {
weakFloorCreated = false;
//for pre-0.3.0c saves
if (version < 44){
map = Terrain.convertTrapsFrom43( map, traps );
}
//for pre-0.4.3 saves
if (version < 130){
if (version <= ShatteredPixelDungeon.v0_4_2b){
map = Terrain.convertTilesFrom129( map );
}

View File

@ -21,17 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.levels;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.GrippingTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.LightningTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ParalyticTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.watabou.utils.SparseArray;
public class Terrain {
public static final int CHASM = 0;
@ -146,72 +135,4 @@ public class Terrain {
return map;
}
//converts terrain values from pre versioncode 44 (0.3.0c) saves
//TODO: remove when no longer supporting saves from 0.3.0b and under
public static int[] convertTrapsFrom43( int[] map, SparseArray<Trap> traps){
for (int i = 0; i < map.length; i++){
int c = map[i];
//non-trap tiles getting their values shifted around
if (c >= 24 && c <= 26) {
c -= 4; //24-26 becomes 20-22
} else if (c == 29) {
c = 23; //29 becomes 23
} else if ( c >= 34 && c <= 36) {
c -= 10; //34-36 becomes 24-26
} else if ( c >= 41 && c <= 46) {
c -= 14; //41-46 becomes 27-32
}
//trap tiles, must be converted to general trap tiles and specific traps instantiated
else if (c >= 17 && c <= 40){
//this is going to be messy...
Trap trap = null;
switch(c){
case 17: trap = new ToxicTrap().reveal(); break;
case 18: trap = new ToxicTrap().hide(); break;
case 19: trap = new FireTrap().reveal(); break;
case 20: trap = new FireTrap().hide(); break;
case 21: trap = new ParalyticTrap().reveal(); break;
case 22: trap = new ParalyticTrap().hide(); break;
case 23:
c = INACTIVE_TRAP;
trap = null;
break;
case 27: trap = new PoisonTrap().reveal(); break;
case 28: trap = new PoisonTrap().hide(); break;
case 30: trap = new AlarmTrap().reveal(); break;
case 31: trap = new AlarmTrap().hide(); break;
case 32: trap = new LightningTrap().reveal(); break;
case 33: trap = new LightningTrap().hide(); break;
case 37: trap = new GrippingTrap().reveal(); break;
case 38: trap = new GrippingTrap().hide(); break;
case 39: trap = new SummoningTrap().reveal(); break;
case 40: trap = new SummoningTrap().hide(); break;
}
if (trap != null){
trap.set( i );
traps.put( trap.pos, trap );
if (trap.visible)
c = TRAP;
else
c = SECRET_TRAP;
}
}
map[i] = c;
}
return map;
}
}

View File

@ -62,7 +62,7 @@ public class Room extends Rect implements Graph.Node, Bundlable {
STANDARD ( StandardRoom.class ),
ENTRANCE ( EntranceRoom.class ),
EXIT ( ExitRoom.class ),
TUNNEL ( MazeRoom.class ),
TUNNEL ( TunnelRoom.class ),
PASSAGE ( PassageRoom.class ),
SHOP ( ShopRoom.class ),
BLACKSMITH ( BlacksmithRoom.class ),

View File

@ -58,7 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.HandAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.NewShortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.CurareDart;
@ -129,7 +129,7 @@ public class ShopRoom extends Room {
switch (Dungeon.depth) {
case 6:
itemsToSpawn.add( (Random.Int( 2 ) == 0 ? new NewShortsword().identify() : new HandAxe()).identify() );
itemsToSpawn.add( (Random.Int( 2 ) == 0 ? new Shortsword().identify() : new HandAxe()).identify() );
itemsToSpawn.add( Random.Int( 2 ) == 0 ?
new IncendiaryDart().quantity(Random.NormalIntRange(2, 4)) :
new CurareDart().quantity(Random.NormalIntRange(1, 3)));

View File

@ -173,8 +173,9 @@ public class InterlevelScene extends PixelScene {
case STATIC:
if (error != null) {
String errorMsg;
if (error instanceof FileNotFoundException) errorMsg = Messages.get(this, "file_not_found");
else if (error instanceof IOException) errorMsg = Messages.get(this, "io_error");
if (error instanceof FileNotFoundException) errorMsg = Messages.get(this, "file_not_found");
else if (error instanceof IOException) errorMsg = Messages.get(this, "io_error");
else if (error.getMessage().equals("old save")) errorMsg = Messages.get(this, "io_error");
else throw new RuntimeException("fatal error occured while moving between floors", error);

View File

@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import android.opengl.GLES20;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Rankings;
@ -36,10 +37,11 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import javax.microedition.khronos.opengles.GL10;
import java.util.ArrayList;
import java.util.UUID;
import javax.microedition.khronos.opengles.GL10;
public class WelcomeScene extends PixelScene {
private static int LATEST_UPDATE = 157;
@ -152,28 +154,34 @@ public class WelcomeScene extends PixelScene {
private void updateVersion(int previousVersion){
//rankings conversion
if (previousVersion <= 114){
Rankings.INSTANCE.load();
for (Rankings.Record rec : Rankings.INSTANCE.records){
if (rec.gameFile != null) {
try {
Dungeon.loadGame(rec.gameFile, false);
rec.gameID = rec.gameFile.replaceAll("\\D", "");
Rankings.INSTANCE.saveGameData(rec);
} catch (Exception e) {
rec.gameID = rec.gameFile.replaceAll("\\D", "");
rec.gameData = null;
if (previousVersion <= ShatteredPixelDungeon.v0_4_1){
try {
Rankings.INSTANCE.load();
for (Rankings.Record rec : Rankings.INSTANCE.records) {
if (rec.gameFile != null) {
try {
Dungeon.loadGame(rec.gameFile, false);
rec.gameID = rec.gameFile.replaceAll("\\D", "");
Rankings.INSTANCE.saveGameData(rec);
} catch (Exception e) {
rec.gameID = rec.gameFile.replaceAll("\\D", "");
rec.gameData = null;
}
String file = rec.gameFile;
rec.gameFile = "";
Game.instance.deleteFile(file);
} else if (rec.gameID == null) {
rec.gameID = UUID.randomUUID().toString();
}
String file = rec.gameFile;
rec.gameFile = "";
Game.instance.deleteFile(file);
} else if (rec.gameID == null){
rec.gameID = UUID.randomUUID().toString();
}
Rankings.INSTANCE.save();
} catch (Exception e) {
//if we encounter a fatal error, then just clear the rankings
Game.instance.deleteFile( Rankings.RANKINGS_FILE );
}
Rankings.INSTANCE.save();
}
ShatteredPixelDungeon.version(ShatteredPixelDungeon.versionCode);