]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Bugfix: respawn all maps after resting. (Thanks Nyktos for finding it!)
authorOskar Wiksten <oskar.wiksten@gmail.com>
Sat, 8 Sep 2012 13:46:13 +0000 (15:46 +0200)
committerOskar Wiksten <oskar.wiksten@gmail.com>
Sat, 8 Sep 2012 13:46:13 +0000 (15:46 +0200)
AndorsTrail/src/com/gpl/rpg/AndorsTrail/Savegames.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DebugInterface.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Controller.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/PredefinedMap.java

index 7516e44d38920bd3e702e2a9d9406a720444ffdc..3bd3471136238ecda0dd2c6b94e999026b8f7bfe 100644 (file)
@@ -128,7 +128,7 @@ public final class Savegames {
     
        private static void onWorldLoaded(WorldContext world) {
                ActorStatsController.recalculatePlayerCombatTraits(world.model.player);
-               Controller.resetMaps(world, true, true);
+               Controller.resetMapsNotRecentlyVisited(world);
                MovementController.moveBlockedActors(world);
        }
        
index 21e57f6f7782941290d62fc9793f89ae957d3553..4edaf576ae3ee7764d88471a7b7656da2193c79b 100644 (file)
@@ -119,8 +119,7 @@ public final class DebugInterface {
                        @Override
                                public void onClick(View arg0) {
                                for(PredefinedMap map : world.maps.predefinedMaps) {
-                                       map.lastVisitTime = 1;
-                                       map.resetIfNotRecentlyVisited(true);
+                                       map.resetTemporaryData();
                                }
                                mainActivity.showToast("DEBUG: maps respawned", Toast.LENGTH_SHORT);
                                }
index 7fc33e4ea9875dca22cf8cad9a94b1b81a419e0a..9718d1d6d8c782d9cd6326d676a00c038cfef8bc 100644 (file)
@@ -85,7 +85,9 @@ public final class Controller {
                        player.spawnPlace = area.id;
                        player.spawnMap = world.model.currentMap.name;
                }
-               resetMaps(world, false, true);
+               for (PredefinedMap m : world.maps.predefinedMaps) {
+                       m.resetTemporaryData();
+       }
                if (area != null) {
                        world.model.currentMap.spawnAll(world);
                }
@@ -103,12 +105,12 @@ public final class Controller {
                return false;
        }
 
-       public static void resetMaps(final WorldContext world, boolean excludeCurrentMap, boolean resetEvenIfMapIsAlreadyReset) {
+       public static void resetMapsNotRecentlyVisited(final WorldContext world) {
                for (PredefinedMap m : world.maps.predefinedMaps) {
-                       if (excludeCurrentMap) {
-                               if (m == world.model.currentMap) continue;
-                       }
-                       m.resetIfNotRecentlyVisited(resetEvenIfMapIsAlreadyReset);
+                       if (m == world.model.currentMap) continue;
+                       if (m.isRecentlyVisited()) continue;
+                       if (m.hasResetTemporaryData()) continue;
+                       m.resetTemporaryData();
        }
        }
 
index 5f1c460f87243fab3c2daa38d546473f7420a1ce..0666385721e737f75676b827d2e944f4576ddfa9 100644 (file)
@@ -53,9 +53,9 @@ public final class GameRoundController implements TimedMessageTask.Callback {
        model.uiSelections.isMainActivityVisible = false;
     }
        
-    private void onNewFullRound() {
-       Controller.resetMaps(world, true, false);
-       view.actorStatsController.applyConditionsToMonsters(model.currentMap, true);
+    public void onNewFullRound() {
+       Controller.resetMapsNotRecentlyVisited(world);
+               view.actorStatsController.applyConditionsToMonsters(model.currentMap, true);
        view.actorStatsController.applyConditionsToPlayer(model.player, true);
     }
     
index efaa44ab4d857880c923f46e41e7c44284ea5b18..32a061c5e4a50cb69cb85768726e56762b1a3426 100644 (file)
@@ -89,6 +89,7 @@ public final class MovementController implements TimedMessageTask.Callback {
        }
     
        private static void playerVisitsMapFirstTime(final WorldContext world, PredefinedMap m) {
+               m.reset();
                m.spawnAll(world);
                m.createAllContainerLoot();
                m.visited = true;
index 57ab6f7c359b9ff47c976bbcffd7ec53f45a2add..7190746bbf1d130370643a5248dc8b946ecccf36 100644 (file)
@@ -210,13 +210,12 @@ public final class PredefinedMap {
                groundBags.remove(loot);
        }
        public void reset() {
-               groundBags.clear();
+               resetTemporaryData();
                for(MonsterSpawnArea a : spawnAreas) {
                        a.reset();
                }
-               splatters.clear();
+               groundBags.clear();
                visited = false;
-               lastVisitTime = VISIT_RESET;
        }
 
        public boolean isRecentlyVisited() {
@@ -226,13 +225,7 @@ public final class PredefinedMap {
        public void updateLastVisitTime() {
                lastVisitTime = System.currentTimeMillis();
        }
-       public void resetIfNotRecentlyVisited(boolean resetEvenIfMapIsAlreadyReset) {
-               if (!resetEvenIfMapIsAlreadyReset) {
-                       if (lastVisitTime == VISIT_RESET) return;
-               }
-               if (isRecentlyVisited()) return;
-               
-               // We reset all non-unique spawn areas. This keeps the savegame file smaller, thus reducing load and save times. Also keeps the running memory usage slightly lower.
+       public void resetTemporaryData() {
                for(MonsterSpawnArea a : spawnAreas) {
                        if (a.isUnique) a.resetShops();
                        else a.reset();
@@ -240,6 +233,9 @@ public final class PredefinedMap {
                splatters.clear();
                lastVisitTime = VISIT_RESET;
        }
+       public boolean hasResetTemporaryData() {
+               return lastVisitTime == VISIT_RESET;
+       }
 
        public void createAllContainerLoot() {
                for (MapObject o : eventObjects) {