Bugfix: Store all visited maps in savegame

* Required for keeping the "lastSeenLayoutHash" between savegames.
This commit is contained in:
Oskar Wiksten
2013-06-27 20:24:42 +02:00
parent 98caa3295e
commit e560bba808
5 changed files with 60 additions and 50 deletions

View File

@@ -3,7 +3,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gpl.rpg.AndorsTrail"
android:versionCode="36"
android:versionCode="37"
android:versionName="0.7.0dev"
android:installLocation="auto"
>

View File

@@ -18,7 +18,7 @@ public final class AndorsTrailApplication extends Application {
public static final boolean DEVELOPMENT_VALIDATEDATA = true;
public static final boolean DEVELOPMENT_DEBUGMESSAGES = true;
public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES || DEVELOPMENT_DEBUGBUTTONS;
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 36;
public static final int CURRENT_VERSION = DEVELOPMENT_INCOMPATIBLE_SAVEGAMES ? 999 : 37;
public static final String CURRENT_VERSION_DISPLAY = "0.7.0dev";
private final AndorsTrailPreferences preferences = new AndorsTrailPreferences();

View File

@@ -102,6 +102,7 @@ public final class MovementController implements TimedMessageTask.Callback {
}
controllers.mapController.applyCurrentMapReplacements(res, false);
newMap.visited = true;
newMap.updateLastVisitTime();
moveBlockedActors(newMap, model.currentTileMap);
refreshMonsterAggressiveness(newMap, model.player);
controllers.effectController.updateSplatters(newMap);

View File

@@ -83,9 +83,8 @@ public final class MapCollection {
}
private static boolean shouldSaveMap(WorldContext world, PredefinedMap map) {
if (map.visited) return true;
if (map == world.model.currentMap) return true;
if (!map.visited) return false;
if (map.hasPersistentData()) return true;
return false;
}

View File

@@ -180,44 +180,52 @@ public final class PredefinedMap {
// ====== PARCELABLE ===================================================================
public void readFromParcel(DataInputStream src, WorldContext world, ControllerContext controllers, int fileversion) throws IOException {
final int loadedSpawnAreas = src.readInt();
for(int i = 0; i < loadedSpawnAreas; ++i) {
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
if (i >= this.spawnAreas.length) {
L.log("WARNING: Trying to load monsters in map " + this.name + " for spawn #" + i + ". This will totally fail.");
boolean shouldLoadPersistentData = true;
if (fileversion >= 37) shouldLoadPersistentData = src.readBoolean();
int loadedSpawnAreas = 0;
if (shouldLoadPersistentData) {
loadedSpawnAreas = src.readInt();
for(int i = 0; i < loadedSpawnAreas; ++i) {
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
if (i >= this.spawnAreas.length) {
L.log("WARNING: Trying to load monsters in map " + this.name + " for spawn #" + i + ". This will totally fail.");
}
}
this.spawnAreas[i].readFromParcel(src, world, fileversion);
}
groundBags.clear();
if (fileversion <= 5) return;
final int size2 = src.readInt();
for(int i = 0; i < size2; ++i) {
groundBags.add(new Loot(src, world, fileversion));
}
if (fileversion <= 11) return;
if (fileversion < 37) visited = src.readBoolean();
if (fileversion <= 15) {
if (visited) {
lastVisitTime = System.currentTimeMillis();
createAllContainerLoot();
}
return;
}
lastVisitTime = src.readLong();
if (visited) {
if (fileversion > 30 && fileversion < 36) {
/*int lastVisitVersion = */src.readInt();
}
}
this.spawnAreas[i].readFromParcel(src, world, fileversion);
}
groundBags.clear();
if (fileversion <= 5) return;
final int size2 = src.readInt();
for(int i = 0; i < size2; ++i) {
groundBags.add(new Loot(src, world, fileversion));
}
if (fileversion >= 37) visited = true;
if (fileversion <= 11) return;
visited = src.readBoolean();
if (fileversion <= 15) {
if (visited) {
lastVisitTime = System.currentTimeMillis();
createAllContainerLoot();
}
return;
}
lastVisitTime = src.readLong();
if (visited) {
if (fileversion > 30 && fileversion < 36) {
/*int lastVisitVersion = */src.readInt();
}
if (fileversion < 36) lastSeenLayoutHash = "";
else lastSeenLayoutHash = src.readUTF();
}
if (fileversion < 36) lastSeenLayoutHash = "";
else lastSeenLayoutHash = src.readUTF();
for(int i = loadedSpawnAreas; i < spawnAreas.length; ++i) {
MonsterSpawnArea area = this.spawnAreas[i];
@@ -227,18 +235,20 @@ public final class PredefinedMap {
}
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
dest.writeInt(spawnAreas.length);
for(MonsterSpawnArea a : spawnAreas) {
a.writeToParcel(dest, flags);
}
dest.writeInt(groundBags.size());
for(Loot l : groundBags) {
l.writeToParcel(dest, flags);
}
dest.writeBoolean(visited);
dest.writeLong(lastVisitTime);
if (visited) {
dest.writeUTF(lastSeenLayoutHash);
if (hasPersistentData()) {
dest.writeBoolean(true);
dest.writeInt(spawnAreas.length);
for(MonsterSpawnArea a : spawnAreas) {
a.writeToParcel(dest, flags);
}
dest.writeInt(groundBags.size());
for(Loot l : groundBags) {
l.writeToParcel(dest, flags);
}
dest.writeLong(lastVisitTime);
} else {
dest.writeBoolean(false);
}
dest.writeUTF(lastSeenLayoutHash);
}
}