コード例 #1
0
        private bool MapVersionCheck(string path)
        {
            if (!File.Exists(_HEIGHT_MAP_PATH))
            {
                return(false);
            }

            var file = File.ReadAllBytes(path);



            BinaryReader reader = new BinaryReader(new MemoryStream(file));

            MapVersion version       = GameObject.Find("map").GetComponent <MapVersion>();
            String     final_version = version.GetVersionString();


            string version_string = reader.ReadString();
            char   nl             = reader.ReadChar();


            if (version_string != final_version || nl != '\n')
            {
                reader.Close();
                return(false);
            }

            return(true);
        }
コード例 #2
0
ファイル: MapModel.cs プロジェクト: WayneMark/MapLoader
        public bool MapSelfCheck()
        {
            if (MapCells == null || MapCells.Length > (MapSize.X * MapSize.Y))
            {
                throw new Exception("Structure check failed");
            }
            IEnumerator cellEnumerator = MapCells.GetEnumerator();

            while (cellEnumerator.Current != null)
            {
                Cell cell = (Cell)cellEnumerator.Current;
                if (cell.X < 0 || cell.Y < 0 || cell.X >= MapSize.X || cell.Y >= MapSize.Y)
                {
                    throw new Exception("Map cell out of size limitations.");
                }
                cellEnumerator.MoveNext();
            }
            string[] versionSegment = MapVersion.Split('.');
            int      i     = 0;
            int      value = -1;

            while (i < versionSegment.Length)
            {
                if (!int.TryParse(versionSegment[i], out value))
                {
                    throw new Exception("Version not correct.");
                }
                i++;
            }
            return(true);
        }
コード例 #3
0
ファイル: MapVersionEditor.cs プロジェクト: deathlef/AOMC2
        public MapVersionEditor(MapVersion mapVersion, string[] availableImages)
            : this()
        {
            this.NameTextBox.Text       = mapVersion.Name;
            this.CoordsFileTextBox.Text = mapVersion.CoordsFile;
            this.AvailableImages.Items.Clear();
            switch (mapVersion.Type)
            {
            case MapType.Rubika:
                this.TypeRadioRubika.Checked = true;
                break;

            case MapType.Shadowlands:
                this.TypeRadioShadowlands.Checked = true;
                break;
            }

            for (int i = 0; i < availableImages.Length; i++)
            {
                if (!mapVersion.Images.Contains(availableImages[i]))
                {
                    this.AvailableImages.Items.Add(availableImages[i]);
                }
                else
                {
                    this.SelectedImages.Items.Add(availableImages[i]);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Takes the sampled height from the terrain and packs/compresses it to a binary file with the format of:
        /// <height><number_of_times_it_occurs_consecutively>["\n"]
        /// <4bytes><4bytes><4bytes>
        /// This can possibly be compressed more by creating a range of height to be included when it writes
        /// the number of times the height occurs. For example, if height is 1.5 and 1.7 and our range is +- .2.. we
        /// would combine 1.5 and 1.7 to be 1.5 because they are so close together.
        ///
        /// </summary>
        /// <param name="path"></param>
        public IEnumerator WriteHeightMap(string path)
        {
            MapVersion version       = GameObject.Find("map").GetComponent <MapVersion>();
            String     final_version = version.GetVersionString();;

            int          nEntry = 2 * _mapSize + 2 * EXTENSION;
            BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read));

            // write the version so at least we can verify
            writer.Write(final_version);
            writer.Write('\n');


            for (int x = 0; x < nEntry; x++)
            {
                float temp    = 0;
                float last    = 0;
                int   lastcnt = 0;

                for (int z = 0; z < nEntry; z++)
                {
                    //Terrain terrain = GetTerrainAtPos(PositionOf(x, z));
                    temp = GetTerrainHeight(PositionOf(x, z));//terrain.SampleHeight(PositionOf(x, z));

                    //map[x, z] = (byte)(terrain.SampleHeight(PositionOf(x, z)) > waterHeight ? PLAIN : WATER);

                    if (last == temp || lastcnt == 0)
                    {
                        lastcnt++;
                    }
                    else
                    {
                        writer.Write(last);
                        writer.Write(lastcnt);

                        lastcnt = 1;
                    }

                    last = temp;
                }

                writer.Write(temp);
                writer.Write(lastcnt);


                writer.Write((int)'\n');

                SetPercentComplete(((double)x / (double)_map.GetLength(0)) * 100.0);

                if ((int)GetPercentComplete() % 2 == 0)
                {
                    yield return(null);
                }
            }



            writer.Close();
        }
コード例 #5
0
        public static MapVersion GetMapVersion(string filename)
        {
            MapVersion version = MapVersion.Halo2;

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                version = GetMapVersion(fs);
            return(version);
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new <see cref="HaloAddOnContainer{TMap, TEntry, TXbox}"/>
 /// </summary>
 public HaloAddOnContainer(MapVersion version)
 {
     //Initialize
     this.version     = version;
     addOns           = new List <IAddOn>();
     haloAddOns       = new List <IHaloAddOn <TMap, TEntry> >();
     xboxAddOns       = new List <IDebugXboxAddOn <TXbox> >();
     tabPages         = new List <ITabPage <TMap, TEntry, TXbox> >();
     menuButtons      = new List <IMenuButton <TMap, TEntry, TXbox> >();
     contextMenuItems = new List <IContextMenuItem <TMap, TEntry, TXbox> >();
     tools            = new List <ITool <TMap, TEntry, TXbox> >();
     errors           = new Dictionary <AddOnFactory, List <Exception> >();
 }
コード例 #7
0
ファイル: MapUserControl.cs プロジェクト: deathlef/AOMC2
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MapVersion mv  = new MapVersion();
            var        box = new MapVersionEditor(mv, this.MainWindow.ImagesUserControl.AvailableImages);
            var        dr  = box.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return;
            }
            box.StoreConfig(mv);
            this.MapVersionList.Items.Add(this.CreateLvi(mv));
        }
コード例 #8
0
ファイル: MapUserControl.cs プロジェクト: deathlef/AOMC2
        private ListViewItem CreateLvi(MapVersion mv)
        {
            ListViewItem lvi = new ListViewItem(new string[]
            {
                mv.Name,
                mv.Type.ToString(),
                mv.File,
                mv.CoordsFile,
                String.Join(", ", mv.Images)
            });

            lvi.Tag = mv;
            return(lvi);
        }
コード例 #9
0
ファイル: MapUserControl.cs プロジェクト: deathlef/AOMC2
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in this.MapVersionList.SelectedItems)
            {
                MapVersion mapVersion = (MapVersion)lvi.Tag;
                var        box        = new MapVersionEditor(mapVersion, this.MainWindow.ImagesUserControl.AvailableImages);

                var dr = box.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                box.StoreConfig(mapVersion);
                lvi.SubItems[0].Text = mapVersion.Name;
                lvi.SubItems[1].Text = mapVersion.Type.ToString();
                lvi.SubItems[2].Text = mapVersion.File;
                lvi.SubItems[3].Text = mapVersion.CoordsFile;
                lvi.SubItems[4].Text = String.Join(", ", mapVersion.Name);
            }
        }
コード例 #10
0
ファイル: MapUserControl.cs プロジェクト: deathlef/AOMC2
 internal void RenameImage(string oldName, string newName)
 {
     foreach (ListViewItem lvi in this.MapVersionList.Items)
     {
         MapVersion mapVersion = (MapVersion)lvi.Tag;
         bool       change     = false;
         for (int i = 0; i < mapVersion.Images.Length; i++)
         {
             if (mapVersion.Images[i] == oldName)
             {
                 mapVersion.Images[i] = newName;
                 change = true;
             }
         }
         if (change)
         {
             lvi.SubItems[2].Text = String.Join(", ", mapVersion.Images);
         }
     }
 }
コード例 #11
0
        // Start is called before the first frame update
        private void Start()
        {
            _slider     = transform.Find("Slider").GetComponent <Slider>();
            _descLbl    = GameObject.Find("LoadingLbl").GetComponent <TextMeshProUGUI>();
            _versionLbl = GameObject.Find("MapVersionLbl").GetComponent <TextMeshProUGUI>();


            Instantiate(_loadedData);
            LoadedData.SceneBuildId = SceneBuildId;

            MapVersion version = GameObject.Find("map").GetComponent <MapVersion>();

            if (version)
            {
                _versionLbl.SetText("Map Name: " + version.Name + "\nVersion:" + version.Version);
            }
            else
            {
                _versionLbl.SetText("Unable to locate map version info");
            }
        }
コード例 #12
0
ファイル: MapVersionEditor.cs プロジェクト: deathlef/AOMC2
        internal void StoreConfig(MapVersion mv)
        {
            mv.CoordsFile = this.CoordsFileTextBox.Text;
            mv.File       = this.FileTextBox.Text;
            mv.Name       = this.NameTextBox.Text;
            if (this.TypeRadioRubika.Checked)
            {
                mv.Type = MapType.Rubika;
            }
            else
            {
                mv.Type = MapType.Shadowlands;
            }

            List <string> selectedImages = new List <string>();

            foreach (var item in this.SelectedImages.Items)
            {
                selectedImages.Add((string)item);
            }
            mv.Images = selectedImages.ToArray();
        }
コード例 #13
0
        public static MapVersion GetMapVersion(Stream inStream)
        {
            //Prepare
            MapVersion version     = MapVersion.None;
            string     buildString = null;
            int        mapVersion  = 0;

            //Check stream
            if (inStream.Length < 2048 + 4096)
            {
                return(version);
            }
            if (!inStream.CanRead)
            {
                throw new ArgumentException("Stream does not support reading.", nameof(inStream));
            }

            //Create Reader
            using (BinaryReader reader = new BinaryReader(inStream))
            {
                //Read
                TagFourCc Tag = new string(reader.ReadChars(4));
                if (Tag == "daeh")
                {
                    //Read Version
                    inStream.Seek(4, SeekOrigin.Begin);
                    mapVersion = reader.ReadInt32();

                    //Check
                    if (mapVersion == 8) //Some type of Halo 2 map...
                    {
                        //Vista is weird
                        bool mightBeVista = false;

                        //Read build string
                        inStream.Seek(288, SeekOrigin.Begin);
                        buildString = new string(reader.ReadChars(32)).Trim('\0');

                        //Check build
                        switch (buildString)
                        {
                        case "02.09.27.09809": version = MapVersion.Halo2; break;

                        case "02.06.28.07902": version = MapVersion.Halo2b; break;

                        default: mightBeVista = true; break;
                        }

                        //Check
                        if (mightBeVista)
                        {
                            inStream.Seek(304, SeekOrigin.Begin);
                            buildString = new string(reader.ReadChars(32)).Trim('\0');
                            if (buildString == "1.07.04.30.0934.main")
                            {
                                version = MapVersion.Halo2v;
                            }
                        }
                    }
                }
            }

            //Return
            return(version);
        }