/// <summary> /// Completes the initialization. /// </summary> /// <param name="datafile">The datafile.</param> private static void CompleteInitialization(GeoDatafile datafile) { // Connects the systems foreach (SerializableJump srcJump in datafile.Jumps) { SolarSystem a = GetSolarSystemByID(srcJump.FirstSystemID); SolarSystem b = GetSolarSystemByID(srcJump.SecondSystemID); if (a == null || b == null) continue; a.AddNeighbor(b); b.AddNeighbor(a); } foreach (SolarSystem system in s_solarSystemsByID.Values) { system.TrimNeighbors(); } }
/// <summary> /// Generates the geography datafile. /// </summary> internal static void GenerateDatafile() { Stopwatch stopwatch = Stopwatch.StartNew(); Util.ResetCounters(); Console.WriteLine(); Console.Write(@"Generating geography datafile... "); // Regions IEnumerable<SerializableRegion> regions = Database.MapRegionsTable.Select( srcRegion => { Util.UpdatePercentDone(Database.GeographyTotalCount); SerializableRegion region = new SerializableRegion { ID = srcRegion.ID, Name = srcRegion.Name }; // Constellations region.Constellations.AddRange(ExportConstellations(srcRegion).OrderBy(x => x.Name)); return region; }); // Jumps IEnumerable<SerializableJump> jumps = Database.MapSolarSystemJumpsTable.Where(srcJump => srcJump.A < srcJump.B) .Select(srcJump => new SerializableJump { FirstSystemID = srcJump.A, SecondSystemID = srcJump.B }); // Serialize GeoDatafile datafile = new GeoDatafile(); datafile.Regions.AddRange(regions.OrderBy(x => x.Name)); datafile.Jumps.AddRange(jumps); Util.DisplayEndTime(stopwatch); Util.SerializeXml(datafile, DatafileConstants.GeographyDatafile); }
/// <summary> /// Generates the geo datafile. /// </summary> private static void GenerateGeography() { Console.WriteLine(); Console.Write(@"Generated geography datafile... "); s_counter = 0; s_percentOld = 0; s_text = String.Empty; s_startTime = DateTime.Now; var allSystems = new List<SerializableSolarSystem>(); var regions = new List<SerializableRegion>(); // Regions foreach (MapRegion srcRegion in s_regions) { var region = new SerializableRegion { ID = srcRegion.ID, Name = srcRegion.Name }; regions.Add(region); // Constellations var constellations = new List<SerializableConstellation>(); foreach (MapConstellation srcConstellation in s_constellations.Where(x => x.RegionID == srcRegion.ID)) { var constellation = new SerializableConstellation { ID = srcConstellation.ID, Name = srcConstellation.Name }; constellations.Add(constellation); // Systems const double baseDistance = 1.0E14; var systems = new List<SerializableSolarSystem>(); foreach ( MapSolarSystem srcSystem in s_solarSystems.Where(x => x.ConstellationID == srcConstellation.ID)) { var system = new SerializableSolarSystem { ID = srcSystem.ID, Name = srcSystem.Name, X = (int) (srcSystem.X/baseDistance), Y = (int) (srcSystem.Y/baseDistance), Z = (int) (srcSystem.Z/baseDistance), SecurityLevel = srcSystem.SecurityLevel }; systems.Add(system); // Stations var stations = new List<SerializableStation>(); foreach (StaStation srcStation in s_stations.Where(x => x.SolarSystemID == srcSystem.ID)) { UpdatePercentDone(s_geoGen); // Agents var stationAgents = new List<SerializableAgent>(); foreach (AgtAgents srcAgent in s_agents.Where(x => x.LocationID == srcStation.ID)) { var agent = new SerializableAgent { ID = srcAgent.ID, Level = srcAgent.Level, Quality = srcAgent.Quality, Name = s_names.FirstOrDefault(x => x.ID == srcAgent.ID).Name }; stationAgents.Add(agent); } var station = new SerializableStation { ID = srcStation.ID, Name = srcStation.Name, CorporationID = srcStation.CorporationID, CorporationName = s_names.FirstOrDefault(x => x.ID == srcStation.CorporationID).Name, ReprocessingEfficiency = srcStation.ReprocessingEfficiency, ReprocessingStationsTake = srcStation.ReprocessingStationsTake, Agents = stationAgents.ToArray() }; stations.Add(station); } system.Stations = stations.OrderBy(x => x.Name).ToArray(); } constellation.Systems = systems.OrderBy(x => x.Name).ToArray(); } region.Constellations = constellations.OrderBy(x => x.Name).ToArray(); } // Jumps var jumps = new List<SerializableJump>(); foreach (MapSolarSystemJump srcJump in s_jumps) { UpdatePercentDone(s_geoGenTotal); // In CCP tables, every jump is included twice, we only need one. if (srcJump.A < srcJump.B) jumps.Add(new SerializableJump {FirstSystemID = srcJump.A, SecondSystemID = srcJump.B}); } s_endTime = DateTime.Now; Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0')); // Serialize var datafile = new GeoDatafile(); datafile.Regions = regions.OrderBy(x => x.Name).ToArray(); datafile.Jumps = jumps.ToArray(); Util.SerializeXML(datafile, DatafileConstants.GeographyDatafile); }