Skip to content

Commit

Permalink
Title mode should now work (slowly) on CK2 saves.
Browse files Browse the repository at this point in the history
Editor should no longer crash when a region definition includes an area which is not defined.
  • Loading branch information
mmyers committed May 30, 2016
1 parent ccc537e commit 6e0542d
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 167 deletions.
3 changes: 3 additions & 0 deletions EU3_Scenario_Editor/src/editor/EditorUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import eug.shared.ObjectVariable;
import eug.shared.Style;
import eug.specific.ck2.CK2DataSource;
import eug.specific.ck2.CK2SaveGame;
import eug.specific.ck2.CK2Scenario;
import eug.specific.clausewitz.ClausewitzHistory;
import eug.specific.clausewitz.ClausewitzSaveGame;
Expand Down Expand Up @@ -190,6 +191,8 @@ else if (version.getSaveType().equalsIgnoreCase("ck2"))
save = EU3SaveGame.loadSaveGame(saveFile, resolver);
else if (version.getSaveType().equalsIgnoreCase("victoria"))
save = Vic2SaveGame.loadSaveGame(saveFile, resolver);
else if (version.getSaveType().equalsIgnoreCase("ck2"))
save = CK2SaveGame.loadSaveGame(saveFile, resolver);
else {
log.log(Level.WARNING, "Unknown or missing save game type specified by config (\"{0}\"). Defaulting to EU3/EU4.", version.getSaveType());
save = EU3SaveGame.loadSaveGame(saveFile, resolver);
Expand Down
38 changes: 31 additions & 7 deletions EU3_Scenario_Editor/src/editor/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public java.util.Map<String, List<String>> getRegions() {
if (areas != null) {
// areas.txt exists, so assume regions are lists of areas (EU4 1.14)
List<String> aggregate = cont.getList().stream()
.flatMap(area -> getAreas().get(area).stream()) // list all provinces in each area of the region
.flatMap(area -> getArea(area).stream()) // list all provinces in each area of the region
.collect(Collectors.toList());
regionList.put(cont.getName(), aggregate);
} else {
Expand All @@ -293,7 +293,7 @@ public java.util.Map<String, List<String>> getRegions() {
for (GenericObject reg : regions.children) {
if (reg.containsList("areas")) {
List<String> aggregate = reg.getList("areas").getList().stream()
.flatMap(area -> getAreas().get(area).stream()) // list all provinces in each area of the region
.flatMap(area -> getArea(area).stream()) // list all provinces in each area of the region
.collect(Collectors.toList());
regionList.put(reg.name, aggregate);
} else if (reg.containsList("provinces")) {
Expand All @@ -312,7 +312,7 @@ public java.util.Map<String, List<String>> getSuperRegions() {
for (GenericList sr : superRegions.lists) {
// at this point, if superregions.txt exists, just assume areas.txt also exists
List<String> aggregate = sr.getList().stream()
.flatMap(region -> getRegions().get(region).stream()) // list all provinces in each area of each region of the superregion
.flatMap(region -> getRegion(region).stream()) // list all provinces in each area of each region of the superregion
.collect(Collectors.toList());
superRegionList.put(sr.getName(), aggregate);
}
Expand All @@ -335,19 +335,43 @@ public java.util.Map<String, List<String>> getProvinceGroups() {
}

public List<String> getArea(String name) {
return getAreas().get(name);
List<String> ret = getAreas().get(name);
if (ret == null) {
log.log(Level.WARNING, "Area {0} is not defined in the map files", name);
ret = new ArrayList<>();
areaList.put(name, ret);
}
return ret;
}

public List<String> getRegion(String name) {
return getRegions().get(name);
List<String> ret = getRegions().get(name);
if (ret == null) {
log.log(Level.WARNING, "Region {0} is not defined in the map files", name);
ret = new ArrayList<>();
regionList.put(name, ret);
}
return ret;
}

public List<String> getSuperRegion(String name) {
return getSuperRegions().get(name);
List<String> ret = getSuperRegions().get(name);
if (ret == null) {
log.log(Level.WARNING, "Super region {0} is not defined in the map files", name);
ret = new ArrayList<>();
superRegionList.put(name, ret);
}
return ret;
}

public List<String> getProvinceGroup(String name) {
return getProvinceGroups().get(name);
List<String> ret = getProvinceGroups().get(name);
if (ret == null) {
log.log(Level.WARNING, "Province group {0} is not defined in the map files", name);
ret = new ArrayList<>();
provinceGroupList.put(name, ret);
}
return ret;
}

public List<String> getAreasOfProv(String provId) {
Expand Down
Loading

0 comments on commit 6e0542d

Please sign in to comment.