mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-02-23 15:38:29 +01:00
Forced regeneration of all worldmaps' HTML upon loading a legacy save to
ensure UTF-8 encoding is used.
This commit is contained in:
@@ -294,7 +294,7 @@ public final class WorldMapController {
|
||||
return new CoordRect(topLeft, new Size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y));
|
||||
}
|
||||
|
||||
private static void updateWorldMapSegment(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
public static void updateWorldMapSegment(Resources res, WorldContext world, String segmentName) throws IOException {
|
||||
String mapAsHtml = getWorldMapSegmentAsHtml(res, world, segmentName);
|
||||
File outputFile = getCombinedWorldMapFile(segmentName);
|
||||
PrintWriter pw = new PrintWriter(outputFile);
|
||||
|
||||
@@ -1,25 +1,35 @@
|
||||
package com.gpl.rpg.AndorsTrail.savegames;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.controller.WorldMapController;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
|
||||
import com.gpl.rpg.AndorsTrail.model.map.WorldMapSegment;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
import android.content.res.Resources;
|
||||
|
||||
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) {
|
||||
public static void adaptToNewContentForVersion45(WorldContext world, ControllerContext controllers, Resources res) {
|
||||
PredefinedMap fields5Map = world.maps.findPredefinedMap("fields5");
|
||||
if (fields5Map != null) {
|
||||
for (MonsterSpawnArea area : fields5Map.spawnAreas) {
|
||||
if (area.monsters != null) {
|
||||
for (Monster m : area.monsters) {
|
||||
if (m.getMonsterTypeID().equals("feygard_bridgeguard")) {
|
||||
area.resetForNewGame();
|
||||
for (MonsterSpawnArea newarea : map.spawnAreas) {
|
||||
for (MonsterSpawnArea newarea : fields5Map.spawnAreas) {
|
||||
if (newarea.areaID.equals("guynmart_robber1")) {
|
||||
controllers.monsterSpawnController.spawnAllInArea(map,
|
||||
(world.model.currentMap == map ? world.model.currentTileMap : null),
|
||||
controllers.monsterSpawnController.spawnAllInArea(fields5Map,
|
||||
(world.model.currentMap == fields5Map ? world.model.currentTileMap : null),
|
||||
newarea, true);
|
||||
break;
|
||||
}
|
||||
@@ -30,8 +40,21 @@ public class LegacySavegamesContentAdaptations {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Force update of existing worldmaps to ensure regenerating the html when needed, using the new UTF-8-enabled template.
|
||||
List<String> segmentsCovered = new LinkedList<String>();
|
||||
for (WorldMapSegment segment : world.maps.worldMapSegments.values()) {
|
||||
if (segment == null || segment.name == null) continue;
|
||||
if (segmentsCovered.contains(segment.name)) continue;
|
||||
segmentsCovered.add(segment.name);
|
||||
try {
|
||||
WorldMapController.updateWorldMapSegment(res, world, segment.name);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) {
|
||||
L.log("Forcing generation of worldmap file for segment " + segment.name);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
L.log("Error creating worldmap file for segment " + segment.name + " : " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public final class Savegames {
|
||||
src.close();
|
||||
|
||||
if (header.fileversion < 45) {
|
||||
LegacySavegamesContentAdaptations.adaptToNewContentForVersion45(world, controllers);
|
||||
LegacySavegamesContentAdaptations.adaptToNewContentForVersion45(world, controllers, res);
|
||||
}
|
||||
|
||||
onWorldLoaded(res, world, controllers);
|
||||
|
||||
Reference in New Issue
Block a user