From 2a7367852911054243e1092ec4cc580dba821093 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 26 Sep 2016 01:40:30 -0400 Subject: [PATCH] v0.4.3: removed visual-only tile types --- core/src/main/AndroidManifest.xml | 4 +- .../shatteredpixeldungeon/levels/Level.java | 58 +++---------------- .../levels/SewerBossLevel.java | 2 +- .../shatteredpixeldungeon/levels/Terrain.java | 39 ++++++++----- .../levels/traps/PitfallTrap.java | 9 +-- 5 files changed, 34 insertions(+), 78 deletions(-) diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml index 67ec1e711..1889491bd 100644 --- a/core/src/main/AndroidManifest.xml +++ b/core/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 5d3f0e279..ca48fcf82 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -333,6 +333,11 @@ public abstract class Level implements Bundlable { if (version < 44){ map = Terrain.convertTrapsFrom43( map, traps ); } + + //for pre-0.4.3 saves + if (version < 130){ + map = Terrain.convertTilesFrom129( map ); + } Collection collection = bundle.getCollection( HEAPS ); for (Bundlable h : collection) { @@ -587,41 +592,6 @@ public abstract class Level implements Bundlable { passable[i] = avoid[i] = false; passable[i + width()-1] = avoid[i + width()-1] = false; } - - for (int i=width(); i < length() - width(); i++) { - - if (water[i]) { - map[i] = getWaterTile( i ); - } - - if (pit[i]) { - if (!pit[i - width()]) { - int c = map[i - width()]; - if (c == Terrain.EMPTY_SP || c == Terrain.STATUE_SP) { - map[i] = Terrain.CHASM_FLOOR_SP; - } else if (water[i - width()]) { - map[i] = Terrain.CHASM_WATER; - } else if ((Terrain.flags[c] & Terrain.UNSTITCHABLE) != 0) { - map[i] = Terrain.CHASM_WALL; - } else { - map[i] = Terrain.CHASM_FLOOR; - } - } - } - } - } - - //FIXME this is a temporary fix here to avoid changing the tiles texture - //This logic will be changed in 0.4.3 anyway - private static int[] N4Indicies = new int[]{0, 2, 3, 1}; - private int getWaterTile( int pos ) { - int t = Terrain.WATER_TILES; - for (int j=0; j < PathFinder.NEIGHBOURS4.length; j++) { - if ((Terrain.flags[map[pos + PathFinder.NEIGHBOURS4[N4Indicies[j]]]] & Terrain.UNSTITCHABLE) != 0) { - t += 1 << j; - } - } - return t; } public void destroy( int pos ) { @@ -638,7 +608,7 @@ public abstract class Level implements Bundlable { } } if (flood) { - set( pos, getWaterTile( pos ) ); + set( pos, Terrain.WATER ); } else { set( pos, Terrain.EMBERS ); } @@ -691,7 +661,7 @@ public abstract class Level implements Bundlable { solid[cell] = (flags & Terrain.SOLID) != 0; avoid[cell] = (flags & Terrain.AVOID) != 0; pit[cell] = (flags & Terrain.PIT) != 0; - water[cell] = terrain == Terrain.WATER || terrain >= Terrain.WATER_TILES; + water[cell] = terrain == Terrain.WATER; } public Heap drop( Item item, int cell ) { @@ -1021,14 +991,6 @@ public abstract class Level implements Bundlable { public String tileName( int tile ) { - if (tile >= Terrain.WATER_TILES) { - return tileName( Terrain.WATER ); - } - - if (tile != Terrain.CHASM && (Terrain.flags[tile] & Terrain.PIT) != 0) { - return tileName( Terrain.CHASM ); - } - switch (tile) { case Terrain.CHASM: return Messages.get(Level.class, "chasm_name"); @@ -1121,12 +1083,6 @@ public abstract class Level implements Bundlable { case Terrain.EMPTY_WELL: return Messages.get(Level.class, "empty_well_desc"); default: - if (tile >= Terrain.WATER_TILES) { - return tileDesc( Terrain.WATER ); - } - if ((Terrain.flags[tile] & Terrain.PIT) != 0) { - return tileDesc( Terrain.CHASM ); - } return Messages.get(Level.class, "default_desc"); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java index f8795ab0b..8db6b1ff8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java @@ -249,7 +249,7 @@ public class SewerBossLevel extends RegularLevel { super.seal(); - set( entrance, Terrain.WATER_TILES ); + set( entrance, Terrain.WATER ); GameScene.updateMap( entrance ); GameScene.ripple( entrance ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Terrain.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Terrain.java index 517d89ad8..1242389ba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Terrain.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Terrain.java @@ -65,13 +65,7 @@ public class Terrain { public static final int BOOKSHELF = 27; public static final int ALCHEMY = 28; - public static final int CHASM_FLOOR = 29; - public static final int CHASM_FLOOR_SP = 30; - public static final int CHASM_WALL = 31; - public static final int CHASM_WATER = 32; - - public static final int WATER_TILES = 48; - public static final int WATER = 63; + public static final int WATER = 29; public static final int PASSABLE = 0x01; public static final int LOS_BLOCKING = 0x02; @@ -118,15 +112,7 @@ public class Terrain { flags[STATUE_SP] = flags[STATUE] | UNSTITCHABLE; flags[BOOKSHELF] = flags[BARRICADE] | UNSTITCHABLE; flags[ALCHEMY] = PASSABLE; - - flags[CHASM_WALL] = flags[CHASM]; - flags[CHASM_FLOOR] = flags[CHASM]; - flags[CHASM_FLOOR_SP] = flags[CHASM]; - flags[CHASM_WATER] = flags[CHASM]; - - for (int i=WATER_TILES; i < WATER_TILES + 16; i++) { - flags[i] = flags[WATER]; - } + }; public static int discover( int terr ) { @@ -140,6 +126,27 @@ public class Terrain { } } + //converts terrain values from pre versioncode 120 (0.4.3) saves + //TODO: remove when no longer supporting saves from 0.4.2b and under + public static int[] convertTilesFrom129(int[] map){ + for (int i = 0; i < map.length; i++){ + + int c = map[i]; + + if (c >= 29){ + if (c <= 32){ + c = 0; //chasm tiles + } else { + c = 29; //water tiles + } + } + + map[i] = c; + + } + 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 traps){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PitfallTrap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PitfallTrap.java index 92a5b39e1..96ea6c85f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PitfallTrap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/traps/PitfallTrap.java @@ -70,14 +70,7 @@ public class PitfallTrap extends Trap { if (!(Dungeon.level.solid[pos - Dungeon.level.width()] && Dungeon.level.solid[pos + Dungeon.level.width()]) && !(Dungeon.level.solid[pos - 1]&& Dungeon.level.solid[pos + 1])){ - int c = Dungeon.level.map[pos - Dungeon.level.width()]; - - if (c == Terrain.WALL || c == Terrain.WALL_DECO) { - Level.set(pos, Terrain.CHASM_WALL); - } else { - Level.set( pos, Terrain.CHASM_FLOOR ); - } - + Level.set(pos, Terrain.CHASM); sprite.parent.add(new WindParticle.Wind(pos)); sprite.kill(); GameScene.updateMap( pos );