Calculate the figures for existing XML-and-DB cities from scratch.  This brings their stats in line with the rest of the DB cities.
M src/main/java/DBObjects/CityDB.java +8 -1
@@ 62,6 62,10 @@ public class CityDB {
         }
     }
     
+    public boolean hasStats() {
+        return this.populationByYear.size() > 0;
+    }
+    
     public void setPopulation(int year, int population) {
         this.populationByYear.put(year, population);
     }

          
@@ 141,7 145,7 @@ public class CityDB {
                 return result.intValue();
             }
             catch(Exception ex) {
-                System.out.println(":( " + this.getName() + " - " + ex.getMessage() + " for year " + year);
+                System.out.println(":( " + this.getName() + " - " + ex.toString() + " " +  ex.getMessage() + " for year " + year);
                 return 100;
             }
         }

          
@@ 211,6 215,9 @@ public class CityDB {
         CurrencyFigure nationalGNPInYear = this.getCountry().getGNPInYear(year);
         try {
             CurrencyFigure usDosh = nationalGNPInYear.convertTo("USD");
+            if (this.region == null) {
+                throw new RuntimeException("Error: " + this.name + " does not have a region assigned");
+            }
             Double regionalWealthComparedToNational = this.region.getRegionalWealthComparedToNational(year);
 //            System.out.println("  " + this.region.getName() + " wealth relative to " + this.country.getName() + " = " + regionalWealthComparedToNational);
             return (int)(usDosh.getAmount() * regionalWealthComparedToNational);

          
M src/main/java/com/ajtjp/gearCity/CityInfoFile/City.java +4 -0
@@ 39,6 39,10 @@ public class City {
     
     public City(){};
     public City(CityDB city, int xmlYear, int nextXmlYear) {
+        this.setStatsFromDatabase(city, xmlYear, nextXmlYear);
+    }
+    
+    public final void setStatsFromDatabase(CityDB city, int xmlYear, int nextXmlYear) {
         this.iD = new ID(city.getXmlID());
         this.nAME = new NAME(city.getName());
         this.cOUNTRY = new COUNTRY(city.getCountry().getName());

          
M src/main/java/com/ajtjp/gearCity/Main.java +46 -45
@@ 64,10 64,10 @@ public class Main {
 
         Set<String> citiesAlreadyExisting = new HashSet<>();
 
-        CreateCityDB cityDB = null;
+        CreateCityDB citiesXML = null;
 
-        cityDB = ImportCitiesFromXMLFile(cityDB, citiesAlreadyExisting);
-        Main.nextXMLID = cityDB.getCityList().size() + 1;
+        citiesXML = ImportCitiesFromXMLFile(citiesXML, citiesAlreadyExisting);
+        Main.nextXMLID = citiesXML.getCityList().size() + 1;
 
         DBReader dbReader = new DBReader("D:/Gear City Mods/CityInfo.sqlite");
         List<CountryDB> countries = dbReader.readCountryInfo();

          
@@ 99,35 99,43 @@ public class Main {
         
         //At this point the population data should be loaded
         for (RegionDB region : regions) {
+            if (region.getCountry() == null) {
+                System.err.println("Error: " + region.getName() + " does not have a country assigned");
+                throw new Exception("Fatal exception");
+            }
             if (!region.getCountry().getName().equals("Ireland"))
-                AddRegionalCities(region, citiesAlreadyExisting, cityDB);
+                AddRegionalCities(region, citiesAlreadyExisting, citiesXML);
         }
         
-        updateExistingXMLCities(citiesAlreadyExisting, cityDB);
+        updateExistingXMLCities(citiesAlreadyExisting, citiesXML);
         
         for (int year : years) {
             //Re-import so we don't add cities to the XML more than once
-            cityDB = ImportCitiesFromXMLFile(cityDB, citiesAlreadyExisting);
-            updateExistingXMLCities(citiesAlreadyExisting, cityDB);
+            citiesXML = ImportCitiesFromXMLFile(citiesXML, citiesAlreadyExisting);
+            updateExistingXMLCities(citiesAlreadyExisting, citiesXML);
             cities.sort(CityDB::sortByXMLID);
             
 cityDBLoop: for (CityDB city : cities) {
                 //See if it's already in the XML, if so skip
-                for (City xml : cityDB.getCityList()) {
+                for (City xml : citiesXML.getCityList()) {
                     if (xml.getNAME().getName().equals(city.getName())) {
+                        if (city.hasStats()) {
+                            System.out.println("Updating XML stats for " + city);
+                            xml.setStatsFromDatabase(city, year, year + 10);
+                        }
                         continue cityDBLoop;
                     }
                 }
                 System.out.println("Creating " + city + " in year " + year);
                 System.out.println("  The population is " + city.getAdjustedRegionalBasedPopulation(year));
                 City xmlCity = new City(city, year, year + 10);
-                cityDB.getCityList().add(xmlCity);
+                citiesXML.getCityList().add(xmlCity);
             }
 
             printCityGrowthStats(cities, year);
 
             //Export back to file
-            Document document= BeanToXMLUtil.convertBeanToXML(cityDB);
+            Document document= BeanToXMLUtil.convertBeanToXML(citiesXML);
             TransformerFactory transformerFactory = TransformerFactory.newInstance();
             Transformer transformer = transformerFactory.newTransformer();
             DOMSource source = new DOMSource(document);

          
@@ 205,34 213,34 @@ cityDBLoop: for (CityDB city : cities) {
                 if (cityFromDB.getPicture() != null) {
                     cityFromXML.setPIC(new PIC(cityFromDB.getPicture() + ".dds"));
                 }
-                //Region data
-                int region = 1;
-                try {
-                    switch (cityFromDB.getCountry().getDistrict()) {
-                        case "Western Europe":
-                            region = 1;
-                            break;
-                        case "Southern Europe":
-                            region = 2;
-                            break;
-                        case "Eastern Europe":
-                            region = 3;
-                            break;
-                        case "Scandinavia":
-                            region = 4;
-                            break;
-                        case "Soviet Europe":
-                            region = 5;
-                            break;
-                        case "Southeastern Europe":
-                            region = 6;
-                            break;
-                    }
-                    cityFromXML.setREGION(String.valueOf(region));
-                }
-                catch(Exception ex) {
-                    System.out.println("Could not assign region for city " + cityFromDB);
-                }
+                //Region data.  Disabled as the car popularities are not moddable
+//                int region = 1;
+//                try {
+//                    switch (cityFromDB.getCountry().getDistrict()) {
+//                        case "Western Europe":
+//                            region = 1;
+//                            break;
+//                        case "Southern Europe":
+//                            region = 2;
+//                            break;
+//                        case "Eastern Europe":
+//                            region = 3;
+//                            break;
+//                        case "Scandinavia":
+//                            region = 4;
+//                            break;
+//                        case "Soviet Europe":
+//                            region = 5;
+//                            break;
+//                        case "Southeastern Europe":
+//                            region = 6;
+//                            break;
+//                    }
+//                    cityFromXML.setREGION(String.valueOf(region));
+//                }
+//                catch(Exception ex) {
+//                    System.out.println("Could not assign region for city " + cityFromDB);
+//                }
             }
         }
     }

          
@@ 247,18 255,11 @@ cityDBLoop: for (CityDB city : cities) {
                     totalPop += city.getBaseUrbanPopulation(year);
                 }
                 for (CityDB city : citiesInRegion) {
-                    if (citiesAlreadyExisting.contains(city.getName())) {
-                        //TODO: Update pop anyway, but don't duplicate
-                        continue;
-                    }
                     int pop = city.getBaseUrbanPopulation(year);
                     double percent = (pop + 0.0) / totalPop;
                     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++;
                     }