Exemplo n.º 1
0
        public void parseZones(WorldMapsTemplate world_maps)
        {
            Console.Write("Starting Zone Parse ...");

            Console.WriteLine("Loading level strings...");
            Utility.LoadLevelStrings(root);

            string outputPath = Path.Combine(root, @".\output");

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            var settings = new XmlWriterSettings()
            {
                CheckCharacters = false,
                CloseOutput     = false,
                Indent          = true,
                IndentChars     = "\t",
                NewLineChars    = "\n",
                Encoding        = new UTF8Encoding(false)
            };

            ZoneMapsTemplate outputFile = new ZoneMapsTemplate();

            outputFile.zones = new List <Zone>();

            // Create IEnumerable<Map> of passed templates
            var worlds = world_maps.world_maps.Where(n => n.id != 0);

            // Parse zones for each template
            foreach (var world in worlds)
            {
                // Other map / zone data must me loaded from individual level / mission files.
                try {
                    Console.WriteLine("Loading Zone Data: " + world.id.ToString());
                    Utility.LoadZoneDataFile(world_path + @"client_world_" + world.map.ToLower() + @".xml");

                    // Get List of zones in data file
                    var subzones = Utility.ZoneDataFile.subzones != null?Utility.ZoneDataFile.subzones.subzone.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    var iuzones = Utility.ZoneDataFile.attributes != null?Utility.ZoneDataFile.attributes.item_use_area.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    var artifactzones = Utility.ZoneDataFile.artifact_result_areas != null?Utility.ZoneDataFile.artifact_result_areas.artifact_result_area.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    var fortzones = Utility.ZoneDataFile.abyss_castle_areas != null?Utility.ZoneDataFile.abyss_castle_areas.abyss_castle_area.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    var limitzones = Utility.ZoneDataFile.limitareas != null?Utility.ZoneDataFile.limitareas.limitarea.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    var pvpzones = Utility.ZoneDataFile.attributes != null?Utility.ZoneDataFile.attributes.pvpzone.Where(n => n.points_info.points.data.Count() > 0) : new List <SubZone>();

                    foreach (var subzone in subzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "SUB"));
                    }

                    foreach (var subzone in iuzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "ITEM_USE"));
                    }

                    foreach (var subzone in artifactzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "ARTIFACT"));
                    }

                    foreach (var subzone in fortzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "FORT"));
                    }

                    foreach (var subzone in limitzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "LIMIT"));
                    }

                    foreach (var subzone in pvpzones)
                    {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "PVP"));
                    }

                    // Get fLy zones from level data
                    List <Zone> flyzones = getFlyZoneTemplates(world);
                    if (flyzones.Count > 0)
                    {
                        outputFile.zones.AddRange(flyzones);
                    }

                    using (var fs = new FileStream(Path.Combine(outputPath, @"zones_" + world.id.ToString() + @".xml"), FileMode.Create, FileAccess.Write))
                        using (var writer = XmlWriter.Create(fs, settings)) {
                            XmlSerializer ser = new XmlSerializer(typeof(ZoneMapsTemplate));
                            ser.Serialize(writer, outputFile);
                        }

                    // Clear zones for next world
                    outputFile.zones = new List <Zone>();
                }
                catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }

            // build zone enumeration file
            foreach (string zone in zoneList)
            {
                zonesEnumeration.Append("<xs:enumeration value=\"" + zone.ToUpper() + "\"/>" + Environment.NewLine);
            }

            StringBuilder zoneCrossReference = new StringBuilder();

            foreach (string description in zoneDescription)
            {
                zoneCrossReference.Append(description + Environment.NewLine);
            }

            // save enumertion for gameserver world type
            using (StreamWriter outfile = new StreamWriter(outputPath + @"\ZoneEnumeration.txt")) {
                outfile.Write(zonesEnumeration);
            }

            // save description cross reference
            using (StreamWriter outfile = new StreamWriter(outputPath + @"\ZoneDescriptionReference.txt")) {
                outfile.Write(zoneCrossReference);
            }
        }
Exemplo n.º 2
0
        public void parseZones(WorldMapsTemplate world_maps)
        {
            Console.Write("Starting Zone Parse ...");

            Console.WriteLine("Loading level strings...");
            Utility.LoadLevelStrings(root);

            string outputPath = Path.Combine(root, @".\output");
            if (!Directory.Exists(outputPath))
                Directory.CreateDirectory(outputPath);

            var settings = new XmlWriterSettings() {
                CheckCharacters = false,
                CloseOutput = false,
                Indent = true,
                IndentChars = "\t",
                NewLineChars = "\n",
                Encoding = new UTF8Encoding(false)
            };

            ZoneMapsTemplate outputFile = new ZoneMapsTemplate();
            outputFile.zones = new List<Zone>();

            // Create IEnumerable<Map> of passed templates
            var worlds = world_maps.world_maps.Where(n => n.id != 0);

            // Parse zones for each template
            foreach (var world in worlds) {

                // Other map / zone data must me loaded from individual level / mission files.
                try {
                    Console.WriteLine("Loading Zone Data: " + world.id.ToString());
                    Utility.LoadZoneDataFile(world_path + @"client_world_" + world.map.ToLower() + @".xml");

                    // Get List of zones in data file
                    var subzones = Utility.ZoneDataFile.subzones != null ? Utility.ZoneDataFile.subzones.subzone.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();
                    var iuzones = Utility.ZoneDataFile.attributes != null ? Utility.ZoneDataFile.attributes.item_use_area.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();
                    var artifactzones = Utility.ZoneDataFile.artifact_result_areas != null ? Utility.ZoneDataFile.artifact_result_areas.artifact_result_area.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();
                    var fortzones = Utility.ZoneDataFile.abyss_castle_areas != null ? Utility.ZoneDataFile.abyss_castle_areas.abyss_castle_area.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();
                    var limitzones = Utility.ZoneDataFile.limitareas != null ? Utility.ZoneDataFile.limitareas.limitarea.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();
                    var pvpzones = Utility.ZoneDataFile.attributes != null ? Utility.ZoneDataFile.attributes.pvpzone.Where(n => n.points_info.points.data.Count() > 0) : new List<SubZone>();

                    foreach (var subzone in subzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "SUB"));
                    }

                    foreach (var subzone in iuzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "ITEM_USE"));
                    }

                    foreach (var subzone in artifactzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "ARTIFACT"));
                    }

                    foreach (var subzone in fortzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "FORT"));
                    }

                    foreach (var subzone in limitzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "LIMIT"));
                    }

                    foreach (var subzone in pvpzones) {
                        outputFile.zones.Add(getZoneTemplate(subzone, world, "PVP"));
                    }

                    // Get fLy zones from level data
                    List<Zone> flyzones = getFlyZoneTemplates(world);
                    if (flyzones.Count > 0) {
                        outputFile.zones.AddRange(flyzones);
                    }

                    using (var fs = new FileStream(Path.Combine(outputPath, @"zones_" + world.id.ToString() + @".xml"), FileMode.Create, FileAccess.Write))
                    using (var writer = XmlWriter.Create(fs, settings)) {
                        XmlSerializer ser = new XmlSerializer(typeof(ZoneMapsTemplate));
                        ser.Serialize(writer, outputFile);
                    }

                    // Clear zones for next world
                    outputFile.zones = new List<Zone>();
                }
                catch (Exception ex) {
                    Debug.Print(ex.ToString());
                }
            }

            // build zone enumeration file
            foreach (string zone in zoneList) {
                zonesEnumeration.Append("<xs:enumeration value=\"" + zone.ToUpper() + "\"/>" + Environment.NewLine);
            }

            StringBuilder zoneCrossReference = new StringBuilder();
            foreach (string description in zoneDescription) {
                zoneCrossReference.Append(description + Environment.NewLine);
            }

            // save enumertion for gameserver world type
            using (StreamWriter outfile = new StreamWriter(outputPath + @"\ZoneEnumeration.txt")) {
                outfile.Write(zonesEnumeration);
            }

            // save description cross reference
            using (StreamWriter outfile = new StreamWriter(outputPath + @"\ZoneDescriptionReference.txt")) {
                outfile.Write(zoneCrossReference);
            }
        }