Exemple #1
0
        public override void AsyncLoad()
        {
            using (var file = FileManager.Instance.Provider.OpenFile(string.Format(@"World\Maps\{0}\{0}_{1}_{2}.adt", Continent, IndexX, IndexY)))
            {
                if (file == null)
                {
                    IsValid = false;
                    return;
                }

                var reader = new BinaryReader(file);
                reader.BaseStream.Position = 0;
                while (reader.BaseStream.Position + 8 <= reader.BaseStream.Length)
                {
                    var signature = reader.ReadUInt32();
                    var size      = reader.ReadInt32();
                    if (reader.BaseStream.Position + size > reader.BaseStream.Length)
                    {
                        break;
                    }

                    var bytes = reader.ReadBytes(size);
                    if (mSaveChunks.ContainsKey(signature))
                    {
                        continue;
                    }

                    mSaveChunks.Add(signature, new DataChunk {
                        Data = bytes, Signature = signature, Size = size
                    });
                }

                reader.BaseStream.Position = 0;
                if (SeekChunk(reader, 0x4D484452) == false)
                {
                    throw new InvalidOperationException("ADT has no header chunk");
                }

                reader.ReadInt32();
                mHeader = reader.Read <Mhdr>();
                InitChunkInfos(reader);
                InitTextures(reader);
                InitM2Models(reader);
                InitWmoModels(reader);
                InitChunks(reader);
            }
        }
Exemple #2
0
        public override void AsyncLoad()
        {
            using (var file = FileManager.Instance.Provider.OpenFile(string.Format(@"World\Maps\{0}\{0}_{1}_{2}.adt", Continent, IndexX, IndexY)))
            {
                if (file == null)
                {
                    IsValid = false;
                    return;
                }

                var reader = new BinaryReader(file);
                reader.BaseStream.Position = 0;
                while(reader.BaseStream.Position + 8 <= reader.BaseStream.Length)
                {
                    var signature = reader.ReadUInt32();
                    var size = reader.ReadInt32();
                    if (reader.BaseStream.Position + size > reader.BaseStream.Length)
                        break;

                    var bytes = reader.ReadBytes(size);
                    if (mSaveChunks.ContainsKey(signature))
                        continue;
                    
                    mSaveChunks.Add(signature, new DataChunk {Data = bytes, Signature = signature, Size = size});
                }

                reader.BaseStream.Position = 0;
                if (SeekChunk(reader, 0x4D484452) == false)
                    throw new InvalidOperationException("ADT has no header chunk");

                reader.ReadInt32();
                mHeader = reader.Read<Mhdr>();
                InitChunkInfos(reader);
                InitTextures(reader);
                InitM2Models(reader);
                InitWmoModels(reader);
                InitChunks(reader);
            }
        }