Пример #1
0
        public void Load(FileStream Stream)
        {
            if (Stream == null)
                throw new ArgumentNullException();

            fixed(Byte *ptr = AniFile)
            Stream.Read(ptr, 256);

            fixed(Byte *ptr = AniTitle)
            Stream.Read(ptr, 64);

            fixed(MyPos *ptr = &PosOffset)
            Stream.Read(ptr, sizeof(MyPos));

            fixed(UInt32 *ptr = &AniInterval)
            Stream.Read(ptr, sizeof(UInt32));

            fixed(MySize *ptr = &SizeBase)
            Stream.Read(ptr, sizeof(MySize));

            fixed(Int32 *ptr = &Thick)
            Stream.Read(ptr, sizeof(Int32));

            fixed(MyPos *ptr = &PosSceneOffset)
            Stream.Read(ptr, sizeof(MyPos));

            fixed(Int32 *ptr = &Height)
            Stream.Read(ptr, sizeof(Int32));

            Cells = new LayerInfo[SizeBase.Width, SizeBase.Height];
            for (Int32 i = 0; i < SizeBase.Height; i++)
            {
                for (Int32 j = 0; j < SizeBase.Width; j++)
                {
                    LayerInfo Layer = Cells[j, i];

                    UInt32 Mask;
                    Int32  Terrain;
                    Int32  Altitude;
                    Stream.Read(&Mask, sizeof(UInt32));
                    Stream.Read(&Terrain, sizeof(Int32));
                    Stream.Read(&Altitude, sizeof(Int32));
                    Layer.Terrain  = (UInt16)Terrain;
                    Layer.Mask     = (UInt16)Mask;
                    Layer.Altitude = (Int16)Altitude;
                }
            }
        }
Пример #2
0
        private void LoadDataMap(String Path)
        {
            if (String.IsNullOrEmpty(Path))
            {
                throw new ArgumentNullException();
            }

            //Load the DMap file...
            using (var Stream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                UInt32 Version; //Currently 1004?
                UInt32 Data;

                Stream.Read(&Version, sizeof(UInt32));
                Stream.Read(&Data, sizeof(UInt32));
                //Console.WriteLine("Version: {0} Data: {1}", Version, Data);

                Byte *pFileName = stackalloc Byte[MAX_PATH];
                Stream.Read(pFileName, MAX_PATH);

                var FullFileName = Folder + new String((SByte *)pFileName);

                //LoadPuzzle(FullFileName);
                //Console.WriteLine("Puzzle: {0} [{1}]", FullFileName, MAX_PATH);

                fixed(MySize *pMapSize = &MapSize)
                Stream.Read(pMapSize, sizeof(MySize));

                //Console.WriteLine("Width = {0}, Height = {1}", MapSize.Width, MapSize.Height);

                Cells = new Cell[MapSize.Width, MapSize.Height];
                for (var i = 0; i < MapSize.Height; i++)
                {
                    UInt32 CheckData = 0;
                    for (var j = 0; j < MapSize.Width; j++)
                    {
                        var Layer = new LayerInfo();

                        Stream.Read(&Layer.Mask, sizeof(UInt16));
                        Stream.Read(&Layer.Terrain, sizeof(UInt16));
                        Stream.Read(&Layer.Altitude, sizeof(Int16));
                        CheckData += (UInt32)((Layer.Mask * (Layer.Terrain + i + 1)) +
                                              ((Layer.Altitude + 2) * (j + 1 + Layer.Terrain)));

                        //Console.WriteLine("Cell({0}, {1}) MASK[{2}] TERRAIN[{3}] ALTITUDE[{4}]", j, i, Layer.Mask, Layer.Terrain, Layer.Altitude);
                        Cells[j, i] = new Cell(Layer);
                    }
                    UInt32 MapCheckData;
                    Stream.Read(&MapCheckData, sizeof(UInt32));

                    if (MapCheckData != CheckData)
                    {
                        throw new Exception("Map checksum failed!");
                    }
                }

                LoadDataPassage(Stream);

                /*if (Version == 1003)
                 *  LoadDataRegion(Stream);*/
                LoadDataLayer(Stream);

                //The rest are LAYER_SCENE, but useless for a server. I'll not implement the rest as it would only
                //slow down the loading.
            }
        }
Пример #3
0
 public Cell(LayerInfo Info)
 {
     this.Accessible = Info.Mask != 0; this.Altitude = Info.Altitude;
 }