public List<Zone> getFlyZoneTemplates(Map world) { List<Zone> templates = new List<Zone>(); Zone template = new Zone(); // Other map / zone data must me loaded from individual level / mission files. try { // If no level data exists, most likely test level thats missing data, ignore // without level data the level can not be properly loaded in retail client if (!File.Exists(path + world.map.ToLower() + @"\leveldata.xml")) { return templates; } Console.WriteLine("Loading Level Mission Data: " + world.map); Utility.LoadMissionFile(path + world.map.ToLower() + @"\mission_mission0.xml"); // If no flying templates return the empty list if (Utility.MissionFile.CommonShapeList.flying_zones.flying_zone == null) { return templates; } IEnumerable flyzones = Utility.MissionFile.CommonShapeList.flying_zones.flying_zone.Where(n => n != null); foreach (MissionCommonShapeListFlying_zonesFlying_zone_zone flyzone in flyzones) { template.mapid = world.id; template.zone_type = "FLY"; template.name = getFormattedZoneName(flyzone.name, 0); template.description = stripCharacters(flyzone.name); zoneDescription.Add(template.name + " // " + world.id.ToString() + " : " + template.description); template.area_type = flyzone.points_info.type.ToUpper(); template.points = new Points(); template.points.top = flyzone.points_info.top; template.points.bottom = flyzone.points_info.bottom; template.points.point = new List<Point>(); var points = flyzone.points_info.points.data.Where(n => n != null); foreach (points_infoPointsData point in points) { Point newpoint = new Point(); newpoint.x = Math.Round(point.x, 4); newpoint.y = Math.Round(point.y, 4); template.points.point.Add(newpoint); } templates.Add(template); } } catch (Exception ex) { Debug.Print("Error Processing Level Data File: '{0}'", ex.InnerException); } return templates; }
static void Main(string[] args) { Utility.WriteExeDetails(); Console.WriteLine("Loading level strings..."); Utility.LoadLevelStrings(root); Console.WriteLine("Loading world ids..."); Utility.LoadWorldId(root); Console.WriteLine("Loading zone maps..."); Utility.LoadZoneMaps(root); Console.WriteLine("Loading Instance Cooltimes..."); Utility.LoadInstanceCooltimeDataFile(root); var worlds = Utility.WorldIdIndex.worlds.Where(n => n.id != 0); WorldMapsTemplate outputFile = new WorldMapsTemplate(); outputFile.world_maps = new List<Map>(); // Build Enumeration output for WorldMapType.java in gameserver ;) StringBuilder worldMapType = new StringBuilder(); // Build Enumeration output for ClientLevelMap.cs StringBuilder clientLevelMap = new StringBuilder(); foreach (var worldmap in worlds) { var template = new Map(); template.id = worldmap.id; template.map = worldmap.name; clientLevelMap.Append(" {\"" + worldmap.name.ToLower() + "\", " + worldmap.id.ToString() + " }, " + Environment.NewLine); template.name = Utility.LevelStringIndex.GetString("STR_ZONE_NAME_" + worldmap.name).Replace("STR_ZONE_NAME_", String.Empty); template.twin_count = worldmap.twin_count; template.prison = Convert.ToBoolean(worldmap.prison); template.except_buff = Convert.ToBoolean(worldmap.except_buff); template.instance = Utility.InstanceCooltimesIndex[worldmap.name] > 0 ? true : false; // Load Zone Map and get level size ZoneMap zone = Utility.ZoneMapIndex.getZoneMap(worldmap.id); template.world_type = zone != null ? zone.getWorldTypeFromString() : WorldType.NONE; template.world_size = zone != null ? zone.world_width : 3072; if (template.world_size == 0) template.world_size = 3072; // additional check to overide any defaults in client xml //if (zone != null) template.world_size = zone.world_width; // Other map / zone data must me loaded from individual level / mission files. try { // If no level data exists, most likely test level thats missing data, ignore // without level data the level can not be properly loaded in retail client if (!File.Exists(path + worldmap.name.ToLower() + @"\leveldata.xml")) { continue; } Console.WriteLine("Loading Level Data: " + worldmap.name); Utility.LoadLevelDataFile(path + worldmap.name.ToLower() + @"\leveldata.xml"); template.water_level = (int) Utility.LevelDataFile.level_info.WaterLevel; Mission mission = Utility.LevelDataFile.Missions.getMission("Mission0"); if (mission != null) { template.fly = mission.LevelOption.Fly.Fly_Whole_Level == 2 ? true : false; } } catch (Exception ex) { Debug.Print("Error Processing Level Data File: '{0}'", ex.InnerException); } // build enumeration for template worldMapType.Append(template.map + @"(" + template.id.ToString() + @"), // " + template.name + Environment.NewLine); outputFile.world_maps.Add(template); } string outputPath = Path.Combine(root, @".\output"); if (!Directory.Exists(outputPath)) Directory.CreateDirectory(outputPath); // save enumertion for gameserver world type using (StreamWriter outfile = new StreamWriter(outputPath + @"\WorldMapType.txt")) { outfile.Write(worldMapType); } // save enumertion for parser client level mapping using (StreamWriter outfile = new StreamWriter(outputPath + @"\ClientLevelMap.txt")) { outfile.Write(clientLevelMap); } var settings = new XmlWriterSettings() { CheckCharacters = false, CloseOutput = false, Indent = true, IndentChars = "\t", NewLineChars = "\n", Encoding = new UTF8Encoding(false) }; try { using (var fs = new FileStream(Path.Combine(outputPath, "world_maps.xml"), FileMode.Create, FileAccess.Write)) using (var writer = XmlWriter.Create(fs, settings)) { XmlSerializer ser = new XmlSerializer(typeof(WorldMapsTemplate)); ser.Serialize(writer, outputFile); } } catch (Exception ex) { Debug.Print(ex.ToString()); } Console.Write("Parse Zone Data? (y/n) "); var answer = Console.ReadLine(); if (answer.Trim() == "y") { ZoneParse zoneParser = new ZoneParse(); zoneParser.parseZones(outputFile); } }
public Zone getZoneTemplate(SubZone subzone, Map world, string zone_type) { var template = new Zone(); template.mapid = world.id; template.priority = subzone.priority; template.zone_type = zone_type; template.area_type = subzone.points_info.type.ToUpper(); string desc = Utility.LevelStringIndex.GetString(subzone.desc); if (desc.StartsWith("_") || desc == "") desc = subzone.name + desc; if (zone_type == "ITEM_USE") { template.name = getFormattedZoneName(desc, 0); } else { template.name = getFormattedZoneName(desc, world.id); } //template.description = (Utility.LevelStringIndex.GetString(subzone.desc) + "_" + world.id.ToString()).ToUpper(); zoneDescription.Add(template.name + " // " + subzone.name + " : " + world.id.ToString()); if (subzone.norecall != null) template.norecall = subzone.norecall.ToUpper() == "TRUE" ? true : false; if (subzone.noride != null) template.noride = subzone.noride.ToUpper() == "TRUE" ? true : false; if (zone_type == "ARTIFACT") { // make list of siege artifacts that affect this area var artifact_infos = Utility.ZoneDataFile.artifact_infos != null ? Utility.ZoneDataFile.artifact_infos.artifact_info.Where(n => n != null) : new List<ArtifactInfo>(); List<int> siegeId = new List<int>(); foreach (var artifact in artifact_infos) { if (artifact.artifact_result_area1 == subzone.name) { siegeId.Add(Convert.ToInt32(artifact.artifact_name.Split('_')[1].Substring(0, 4))); } } if (siegeId.Count > 0) template.siege_id = siegeId; } else { template.siege_id = null; } if (zone_type == "FORT") { List<int> abyssid = new List<int>(); abyssid.Add(subzone.abyss_id); template.siege_id = abyssid; } template.points = new Points(); template.points.top = subzone.points_info.top; template.points.bottom = subzone.points_info.bottom; template.points.point = new List<Point>(); IEnumerable points = subzone.points_info.points.data as IEnumerable; foreach (ParserBase.Data point in points) { Point newpoint = new Point(); newpoint.x = Math.Round(point.x, 4); newpoint.y = Math.Round(point.y, 4); template.points.point.Add(newpoint); } return template; }
static void Main(string[] args) { Utility.WriteExeDetails(); Console.WriteLine("Loading level strings..."); Utility.LoadLevelStrings(root); Console.WriteLine("Loading world ids..."); Utility.LoadWorldId(root); Console.WriteLine("Loading zone maps..."); Utility.LoadZoneMaps(root); Console.WriteLine("Loading Instance Cooltimes..."); Utility.LoadInstanceCooltimeDataFile(root); var worlds = Utility.WorldIdIndex.worlds.Where(n => n.id != 0); WorldMapsTemplate outputFile = new WorldMapsTemplate(); outputFile.world_maps = new List <Map>(); // Build Enumeration output for WorldMapType.java in gameserver ;) StringBuilder worldMapType = new StringBuilder(); // Build Enumeration output for ClientLevelMap.cs StringBuilder clientLevelMap = new StringBuilder(); foreach (var worldmap in worlds) { var template = new Map(); template.id = worldmap.id; template.map = worldmap.name; clientLevelMap.Append(" {\"" + worldmap.name.ToLower() + "\", " + worldmap.id.ToString() + " }, " + Environment.NewLine); template.name = Utility.LevelStringIndex.GetString("STR_ZONE_NAME_" + worldmap.name).Replace("STR_ZONE_NAME_", String.Empty); template.twin_count = worldmap.twin_count; template.prison = Convert.ToBoolean(worldmap.prison); template.except_buff = Convert.ToBoolean(worldmap.except_buff); template.instance = Utility.InstanceCooltimesIndex[worldmap.name] > 0 ? true : false; // Load Zone Map and get level size ZoneMap zone = Utility.ZoneMapIndex.getZoneMap(worldmap.id); template.world_type = zone != null?zone.getWorldTypeFromString() : WorldType.NONE; template.world_size = zone != null ? zone.world_width : 3072; if (template.world_size == 0) { template.world_size = 3072; // additional check to overide any defaults in client xml } //if (zone != null) template.world_size = zone.world_width; // Other map / zone data must me loaded from individual level / mission files. try { // If no level data exists, most likely test level thats missing data, ignore // without level data the level can not be properly loaded in retail client if (!File.Exists(path + worldmap.name.ToLower() + @"\leveldata.xml")) { continue; } Console.WriteLine("Loading Level Data: " + worldmap.name); Utility.LoadLevelDataFile(path + worldmap.name.ToLower() + @"\leveldata.xml"); template.water_level = (int)Utility.LevelDataFile.level_info.WaterLevel; Mission mission = Utility.LevelDataFile.Missions.getMission("Mission0"); if (mission != null) { template.fly = mission.LevelOption.Fly.Fly_Whole_Level == 2 ? true : false; } } catch (Exception ex) { Debug.Print("Error Processing Level Data File: '{0}'", ex.InnerException); } // build enumeration for template worldMapType.Append(template.map + @"(" + template.id.ToString() + @"), // " + template.name + Environment.NewLine); outputFile.world_maps.Add(template); } string outputPath = Path.Combine(root, @".\output"); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } // save enumertion for gameserver world type using (StreamWriter outfile = new StreamWriter(outputPath + @"\WorldMapType.txt")) { outfile.Write(worldMapType); } // save enumertion for parser client level mapping using (StreamWriter outfile = new StreamWriter(outputPath + @"\ClientLevelMap.txt")) { outfile.Write(clientLevelMap); } var settings = new XmlWriterSettings() { CheckCharacters = false, CloseOutput = false, Indent = true, IndentChars = "\t", NewLineChars = "\n", Encoding = new UTF8Encoding(false) }; try { using (var fs = new FileStream(Path.Combine(outputPath, "world_maps.xml"), FileMode.Create, FileAccess.Write)) using (var writer = XmlWriter.Create(fs, settings)) { XmlSerializer ser = new XmlSerializer(typeof(WorldMapsTemplate)); ser.Serialize(writer, outputFile); } } catch (Exception ex) { Debug.Print(ex.ToString()); } Console.Write("Parse Zone Data? (y/n) "); var answer = Console.ReadLine(); if (answer.Trim() == "y") { ZoneParse zoneParser = new ZoneParse(); zoneParser.parseZones(outputFile); } }