Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 3
0
        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);
                }
        }
Ejemplo n.º 4
0
        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);
            }
        }