v0.6.1a: small refactor to dungeon/level bundling

This commit is contained in:
Evan Debenham 2017-08-16 23:52:52 -04:00
parent d4849e4888
commit bde794bb8f
2 changed files with 6 additions and 7 deletions

View File

@ -677,7 +677,7 @@ public class Dungeon {
Bundle bundle = Bundle.read( input ); Bundle bundle = Bundle.read( input );
input.close(); input.close();
return (Level)bundle.get( "level" ); return (Level)bundle.get( LEVEL );
} }
public static void deleteGame( HeroClass cl, boolean deleteLevels ) { public static void deleteGame( HeroClass cl, boolean deleteLevels ) {

View File

@ -154,6 +154,8 @@ public abstract class Level implements Bundlable {
public int color2 = 0x88CC44; public int color2 = 0x88CC44;
private static final String VERSION = "version"; private static final String VERSION = "version";
private static final String WIDTH = "width";
private static final String HEIGHT = "height";
private static final String MAP = "map"; private static final String MAP = "map";
private static final String VISITED = "visited"; private static final String VISITED = "visited";
private static final String MAPPED = "mapped"; private static final String MAPPED = "mapped";
@ -295,10 +297,7 @@ public abstract class Level implements Bundlable {
throw new RuntimeException("old save"); throw new RuntimeException("old save");
} }
if (bundle.contains("width") && bundle.contains("height")){ setSize( bundle.getInt(WIDTH), bundle.getInt(HEIGHT));
setSize( bundle.getInt("width"), bundle.getInt("height"));
} else
setSize( 32, 32); //default sizes
mobs = new HashSet<>(); mobs = new HashSet<>();
heaps = new SparseArray<>(); heaps = new SparseArray<>();
@ -404,8 +403,8 @@ public abstract class Level implements Bundlable {
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
bundle.put( VERSION, Game.versionCode ); bundle.put( VERSION, Game.versionCode );
bundle.put( "width", width ); bundle.put( WIDTH, width );
bundle.put( "height", height ); bundle.put( HEIGHT, height );
bundle.put( MAP, map ); bundle.put( MAP, map );
bundle.put( VISITED, visited ); bundle.put( VISITED, visited );
bundle.put( MAPPED, mapped ); bundle.put( MAPPED, mapped );