Ejemplo n.º 1
0
        /**
         * Adds additional port towns to the list.
         * These are only port towns in the context of TediousTravel, Daggerfall knows nothing about them.
         */
        private void AddAditionalPortTowns(PortTowns portTowns)
        {
            var reader = DaggerfallUnity.Instance.ContentReader.MapFileReader;

            foreach (KeyValuePair <string, string> i in additionalPorts)
            {
                var location = reader.GetLocation(i.Key, i.Value);
                Debug.Log("Adding " + location.RegionName + ", " + location.Name + " as additional port town: " + location.RegionIndex + ", " + location.LocationIndex);
                portTowns.locations.Add(new PortTown(location.RegionIndex, location.LocationIndex));
            }
        }
Ejemplo n.º 2
0
        /**
         * Exports port towns from BSA files, because you essentially have to load the entire town exterior
         * before you can see whether it's a port town.
         */
        public void GeneratePortTownData(string dataPath)
        {
            if (!File.Exists(dataPath))
            {
                System.IO.Directory.CreateDirectory(dataPath);
            }
            DaggerfallUI.Instance.DaggerfallHUD.SetMidScreenText("Tedious data export complete. This won't be necessary in the future...");

            var reader    = DaggerfallUnity.Instance.ContentReader.MapFileReader;
            var portTowns = new PortTowns();

            Debug.Log("Regions: " + reader.RegionCount);

            // walk through all existing locations and check if they're a port town.
            for (int i = 0; i < reader.RegionCount; ++i)
            {
                var region = reader.GetRegion(i);
                Debug.Log("towns in " + region.Name + ": " + region.LocationCount);
                var regionPorts     = 0;
                var regionLocations = region.MapNames;
                for (int j = 0; j < region.LocationCount; ++j)
                {
                    var location = reader.GetLocation(region.Name, regionLocations[j]);
                    if (location.Exterior.ExteriorData.PortTownAndUnknown != 0)
                    {
                        portTowns.locations.Add(new PortTown(location.RegionIndex, location.LocationIndex));
                        Debug.Log("port town found in " + region.Name + ": " + location.Name);
                        regionPorts++;
                    }
                }
                Debug.Log("ports in region " + region.Name + ": " + regionPorts);
            }

            AddAditionalPortTowns(portTowns);
            Debug.Log("number of port towns: " + portTowns.locations.Count);
            var serializer = new XmlSerializer(typeof(PortTowns));
            var stream     = new FileStream(dataPath + "//" + PORTTOWNS_FILE, FileMode.CreateNew);

            serializer.Serialize(stream, portTowns);
            stream.Close();
        }