# HG changeset patch # User Andrew # Date 1661731943 14400 # Sun Aug 28 20:12:23 2022 -0400 # Node ID 74f28c7e70022e95b4dec48e0f1a05a083c8aaaa # Parent 7c6675c4840b714813a1e17c659055bf4960da5a Calculate the next XML ID automatically based on the source XML file. All decades are now enabled. diff --git a/src/main/java/DBObjects/CityDB.java b/src/main/java/DBObjects/CityDB.java --- a/src/main/java/DBObjects/CityDB.java +++ b/src/main/java/DBObjects/CityDB.java @@ -261,4 +261,8 @@ public String getPicture() { return picture; } + + public int sortByXMLID(CityDB other) { + return this.xmlID - other.xmlID; + } } diff --git a/src/main/java/com/ajtjp/gearCity/Main.java b/src/main/java/com/ajtjp/gearCity/Main.java --- a/src/main/java/com/ajtjp/gearCity/Main.java +++ b/src/main/java/com/ajtjp/gearCity/Main.java @@ -51,9 +51,9 @@ //This will eventually go obsolete once we load everything from our DB //Prior to that, it might decrease when we load EE1 cities from the DB - static int nextXMLID = 125; + static int nextXMLID = 0; - final static int[] years = { 1900, 1910, 1920, 1930, 1940 }; + final static int[] years = { 1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010 }; private static DecimalFormat percentFormat = new DecimalFormat("0.00"); @@ -67,6 +67,7 @@ CreateCityDB cityDB = null; cityDB = ImportCitiesFromXMLFile(cityDB, citiesAlreadyExisting); + Main.nextXMLID = cityDB.getCityList().size() + 1; DBReader dbReader = new DBReader("D:/Gear City Mods/CityInfo.sqlite"); List countries = dbReader.readCountryInfo(); @@ -108,6 +109,7 @@ //Re-import so we don't add cities to the XML more than once cityDB = ImportCitiesFromXMLFile(cityDB, citiesAlreadyExisting); updateExistingXMLCities(citiesAlreadyExisting, cityDB); + cities.sort(CityDB::sortByXMLID); cityDBLoop: for (CityDB city : cities) { //See if it's already in the XML, if so skip @@ -254,6 +256,9 @@ city.setPopPercentByYear(year, percent); //TODO: Less hacky. This shouldn't really be in a loop if (city.getXmlID() == 0) { + if (Main.nextXMLID == 228) { + System.out.println("debug"); + } city.setXMLID(Main.nextXMLID); //todo: less hacky Main.nextXMLID++; }