import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.ActorStatsController;
import com.gpl.rpg.AndorsTrail.controller.Constants;
+import com.gpl.rpg.AndorsTrail.controller.Controller;
import com.gpl.rpg.AndorsTrail.controller.MovementController;
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
import com.gpl.rpg.AndorsTrail.util.L;
world.model.writeToParcel(dest, flags);
dest.close();
}
- public static int loadWorld(WorldContext world, InputStream inState) throws IOException {
+
+ public static int loadWorld(WorldContext world, InputStream inState) throws IOException {
DataInputStream src = new DataInputStream(inState);
final FileHeader header = new FileHeader(src);
if (header.fileversion > AndorsTrailApplication.CURRENT_VERSION) return LOAD_RESULT_FUTURE_VERSION;
world.model = new ModelContainer(src, world, header.fileversion);
src.close();
- ActorStatsController.recalculatePlayerCombatTraits(world.model.player);
- MovementController.moveBlockedActors(world);
+ onWorldLoaded(world);
return LOAD_RESULT_SUCCESS;
}
+ private static void onWorldLoaded(WorldContext world) {
+ ActorStatsController.recalculatePlayerCombatTraits(world.model.player);
+ Controller.resetMaps(world, true, true);
+ MovementController.moveBlockedActors(world);
+ }
+
public static FileHeader quickload(Context androidContext, int slot) {
try {
if (slot != SLOT_QUICKSAVE) {
public void onClick(View arg0) {
for(PredefinedMap map : world.maps.predefinedMaps) {
map.lastVisitTime = 1;
- map.resetIfNotRecentlyVisited();
+ map.resetIfNotRecentlyVisited(true);
}
mainActivity.showToast("DEBUG: maps respawned", Toast.LENGTH_SHORT);
}
player.spawnPlace = area.id;
player.spawnMap = world.model.currentMap.name;
}
- for (PredefinedMap m : world.maps.predefinedMaps) {
- if (m.visited) m.spawnAll(world);
- }
+ resetMaps(world, false, true);
}
public static void ui_playerRested(final Activity currentActivity, final ViewContext viewContext, MapObject area) {
return false;
}
- public void resetMaps() {
+ public static void resetMaps(final WorldContext world, boolean excludeCurrentMap, boolean resetEvenIfMapIsAlreadyReset) {
for (PredefinedMap m : world.maps.predefinedMaps) {
- if (m == model.currentMap) continue;
- m.resetIfNotRecentlyVisited();
+ if (excludeCurrentMap) {
+ if (m == world.model.currentMap) continue;
+ }
+ m.resetIfNotRecentlyVisited(resetEvenIfMapIsAlreadyReset);
}
}
}
private void onNewFullRound() {
- view.controller.resetMaps();
+ Controller.resetMaps(world, true, false);
view.actorStatsController.applyConditionsToMonsters(model.currentMap, true);
view.actorStatsController.applyConditionsToPlayer(model.player, true);
}
spawnAllInArea(world, a, respawnUniqueMonsters);
}
}
- public void spawnAllInArea(WorldContext world, MonsterSpawnArea area, boolean respawnUniqueMonsters) {
+ private void spawnAllInArea(WorldContext world, MonsterSpawnArea area, boolean respawnUniqueMonsters) {
while (area.isSpawnable(respawnUniqueMonsters)) {
final boolean wasAbleToSpawn = spawnInArea(area, world, null);
if (!wasAbleToSpawn) break;
public void updateLastVisitTime() {
lastVisitTime = System.currentTimeMillis();
}
- public void resetIfNotRecentlyVisited() {
- if (lastVisitTime == VISIT_RESET) return;
+ 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.