Added code to patch legacy saves to adapt to conflicts with new content.

This commit is contained in:
Zukero
2019-01-03 14:27:03 +01:00
parent 665d140f04
commit b423b3cf69
2 changed files with 42 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
package com.gpl.rpg.AndorsTrail.savegames;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
public class LegacySavegamesContentAdaptations {
public static void adaptToNewContentForVersion45(WorldContext world, ControllerContext controllers) {
PredefinedMap map = world.maps.findPredefinedMap("fields5");
if (map != null) {
for (MonsterSpawnArea area : map.spawnAreas) {
if (area.monsters != null) {
for (Monster m : area.monsters) {
if (m.getMonsterTypeID().equals("feygard_bridgeguard")) {
area.resetForNewGame();
for (MonsterSpawnArea newarea : map.spawnAreas) {
if (newarea.areaID.equals("guynmart_robber1")) {
controllers.monsterSpawnController.spawnAllInArea(map,
(world.model.currentMap == map ? world.model.currentTileMap : null),
newarea, true);
break;
}
}
break;
}
}
}
}
}
}
}

View File

@@ -122,7 +122,11 @@ public final class Savegames {
world.maps.readFromParcel(src, world, controllers, header.fileversion);
world.model = new ModelContainer(src, world, controllers, header.fileversion);
src.close();
if (header.fileversion < 45) {
LegacySavegamesContentAdaptations.adaptToNewContentForVersion45(world, controllers);
}
onWorldLoaded(res, world, controllers);
return LoadSavegameResult.success;