mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Added code to patch legacy saves to adapt to conflicts with new content.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user