/// <param name="popNode"></param> private void readPopulationNode(XmlNode popNode) { try { DataStore.strictCapacity = Convert.ToBoolean(popNode.Attributes["strictCapacity"].InnerText); } catch (Exception) { // Do nothing } foreach (XmlNode node in popNode.ChildNodes) { // TODO - These two to be removed in Jan 2017 if (node.Name.Equals(bonusHouseName)) { readBonusHouseNode(node); } else if (node.Name.Equals(bonusWorkName)) { readBonusWorkers(node); } else { string[] attr = node.Name.Split(new char[] { '_' }); string name = attr[0]; int level = Convert.ToInt32(attr[1]) - 1; int[] array = new int[12]; try { array = getArray(name, level, "readPopulationNode"); int temp = Convert.ToInt32(node.Attributes["level_height"].InnerText); array[DataStore.LEVEL_HEIGHT] = temp > 0 ? temp : 10; temp = Convert.ToInt32(node.Attributes["space_pp"].InnerText); if (temp <= 0) { temp = 100; // Bad person trying to give negative or div0 error. } array[DataStore.PEOPLE] = transformPopulationModifier(name, level, temp, false); } catch (Exception e) { Debugging.bufferWarning("readPopulationNode exception:\r\n" + e.ToString()); } try { if (Convert.ToBoolean(node.Attributes["calc"].InnerText.Equals("plot"))) { array[DataStore.CALC_METHOD] = 1; } else { array[DataStore.CALC_METHOD] = 0; } } catch { } if (!name.Contains("Residential")) { try { int dense = Convert.ToInt32(node.Attributes["ground_mult"].InnerText); array[DataStore.DENSIFICATION] = dense >= 0 ? dense : 0; // Force to be greater than 0 int level0 = Convert.ToInt32(node.Attributes["lvl_0"].InnerText); int level1 = Convert.ToInt32(node.Attributes["lvl_1"].InnerText); int level2 = Convert.ToInt32(node.Attributes["lvl_2"].InnerText); int level3 = Convert.ToInt32(node.Attributes["lvl_3"].InnerText); // Ensure all is there first array[DataStore.WORK_LVL0] = level0; array[DataStore.WORK_LVL1] = level1; array[DataStore.WORK_LVL2] = level2; array[DataStore.WORK_LVL3] = level3; } catch (Exception e) { Debugging.bufferWarning("readPopulationNode, part b exception:\r\n" + e.ToString()); } } } // end if } // end foreach }
/// <param name="pollutionNode"></param> private void readPollutionNode(XmlNode pollutionNode) { string name = ""; foreach (XmlNode node in pollutionNode.ChildNodes) { try { // Extract power, water, sewage, garbage and wealth string[] attr = node.Name.Split(new char[] { '_' }); name = attr[0]; int level = Convert.ToInt32(attr[1]) - 1; int ground = Convert.ToInt32(node.Attributes["ground"].InnerText); int noise = Convert.ToInt32(node.Attributes["noise"].InnerText); switch (name) { case "ResidentialLow": setPollutionRates(DataStore.residentialLow[level], ground, noise); break; case "ResidentialHigh": setPollutionRates(DataStore.residentialHigh[level], ground, noise); break; case "CommercialLow": setPollutionRates(DataStore.commercialLow[level], ground, noise); break; case "CommercialHigh": setPollutionRates(DataStore.commercialHigh[level], ground, noise); break; case "CommercialTourist": setPollutionRates(DataStore.commercialTourist[level], ground, noise); break; case "CommercialLeisure": setPollutionRates(DataStore.commercialLeisure[level], ground, noise); break; case "Office": setPollutionRates(DataStore.office[level], ground, noise); break; case "Industry": setPollutionRates(DataStore.industry[level], ground, noise); break; case "IndustryOre": setPollutionRates(DataStore.industry_ore[level], ground, noise); break; case "IndustryOil": setPollutionRates(DataStore.industry_oil[level], ground, noise); break; case "IndustryForest": setPollutionRates(DataStore.industry_forest[level], ground, noise); break; case "IndustryFarm": setPollutionRates(DataStore.industry_farm[level], ground, noise); break; } } catch (Exception e) { Debugging.bufferWarning("readPollutionNode exception:\r\n" + e.ToString()); } } // end foreach }