Bugfix: respawn all maps after resting. (Thanks Nyktos for finding it!)

This commit is contained in:
Oskar Wiksten
2012-09-08 15:46:13 +02:00
parent 628367f773
commit a02ab17f25
6 changed files with 20 additions and 22 deletions

View 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);
}

View 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);
}

View 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();
}
}

View 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);
}

View 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;

View 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) {