LoadMap() private method

reads info from the current open map file and stores in it this map object
private LoadMap ( ) : void
return void
Example #1
0
        /// <summary>
        /// Loads a .map file and returns it as
        /// a map object
        /// </summary>
        /// <param name="fileName">The file Name.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static Map LoadFromFile(string fileName)
        {
            // create the map object and give it the map filename
            Map map = new Map(fileName);

            // open the map
            map.OpenMap(MapTypes.Internal);

            // if the open failed, nothing we can do further
            if (!map.isOpen)
            {
                return(null);
            }

            // Get map version, (what halo this is)
            map.BR.BaseStream.Position = 4;
            int version = map.BR.ReadInt32();

            // set the halo game type in the map object
            switch (version)
            {
            case 609:
                map.HaloVersion = HaloVersionEnum.HaloCE;
                break;

            case 8:
                map.HaloVersion            = HaloVersionEnum.Halo2;
                map.BR.BaseStream.Position = 0x24;
                switch (map.BR.ReadInt32())
                {
                case -1:
                    map.HaloVersion = HaloVersionEnum.Halo2Vista;
                    break;

                case 0:
                    map.HaloVersion = HaloVersionEnum.Halo2;
                    break;
                }
                break;

            case 5:
                map.HaloVersion = HaloVersionEnum.Halo1;
                break;

            // if we dont support the map, dont open it
            default:
                MessageBox.Show("This is not a supported map type.");
                map.CloseMap();
                return(null);
            }

            // read from the map
            map.LoadMap();

            // close file and return map obj
            map.CloseMap();
            return(map);
        }
Example #2
0
        /// <summary>
        /// Loads a .map file and returns it as
        /// a map object
        /// </summary>
        /// <param name="fileName">The file Name.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static Map LoadFromFile(string fileName)
        {
            // create the map object and give it the map filename
            Map map = new Map(fileName);

            // open the map
            map.OpenMap(MapTypes.Internal);

            // if the open failed, nothing we can do further
            if (!map.isOpen)
            {
                return null;
            }

            // Get map version, (what halo this is)
            map.BR.BaseStream.Position = 4;
            int version = map.BR.ReadInt32();

            // set the halo game type in the map object
            switch (version)
            {
                case 609:
                    map.HaloVersion = HaloVersionEnum.HaloCE;
                    break;
                case 8:
                    map.HaloVersion = HaloVersionEnum.Halo2;
                    map.BR.BaseStream.Position = 0x24;
                    switch (map.BR.ReadInt32())
                    {
                        case -1:
                            map.HaloVersion = HaloVersionEnum.Halo2Vista;
                            break;
                        case 0:
                            map.HaloVersion = HaloVersionEnum.Halo2;
                            break;
                    }
                    break;
                case 5:
                    map.HaloVersion = HaloVersionEnum.Halo1;
                    break;

                    // if we dont support the map, dont open it
                default:
                    MessageBox.Show("This is not a supported map type.");
                    map.CloseMap();
                    return null;
            }

            // read from the map
            map.LoadMap();

            // close file and return map obj
            map.CloseMap();
            return map;
        }