Beispiel #1
0
        private void ReadObjFile(string filename, Stream adtObjStream, ref BlizzHeader chunk)
        {
            var  bin      = new BinaryReader(adtObjStream);
            long position = 0;

            adtfile.objects = new Obj();

            while (position < adtObjStream.Length)
            {
                adtObjStream.Position = position;
                chunk = new BlizzHeader(bin.ReadChars(4), bin.ReadUInt32());
                chunk.Flip();
                position = adtObjStream.Position + chunk.Size;

                if (chunk.Is("MVER"))
                {
                    if (bin.ReadUInt32() != 18)
                    {
                        throw new Exception("Unsupported ADT version!");
                    }
                    continue;
                }
                if (chunk.Is("MMDX"))
                {
                    adtfile.objects.m2Names = ReadMMDXChunk(chunk, bin); continue;
                }
                if (chunk.Is("MMID"))
                {
                    adtfile.objects.m2NameOffsets = ReadMMIDChunk(chunk, bin); continue;
                }
                if (chunk.Is("MWMO"))
                {
                    adtfile.objects.wmoNames = ReadMWMOChunk(chunk, bin); continue;
                }
                if (chunk.Is("MWID"))
                {
                    adtfile.objects.wmoNameOffsets = readMWIDChunk(chunk, bin);  continue;
                }
                if (chunk.Is("MDDF"))
                {
                    adtfile.objects.models = ReadMWIDChunk(chunk, bin); continue;
                }
                if (chunk.Is("MODF"))
                {
                    adtfile.objects.worldModels = ReadMODFChunk(chunk, bin); continue;
                }
                if (chunk.Is("MCNK"))
                {
                    continue;
                }                                   // Only has MCRD and other useless things nobody cares about!

                throw new Exception(String.Format("{2} Found unknown header at offset {1} \"{0}\" while we should've already read them all!", chunk.ToString(), position.ToString(), filename));
            }
        }
Beispiel #2
0
        private void ReadTexFile(string filename, Stream adtTexStream, ref BlizzHeader chunk)
        {
            var  bin      = new BinaryReader(adtTexStream);
            long position = 0;
            int  MCNKi    = 0;

            adtfile.texChunks = new TexMCNK[16 * 16];

            while (position < adtTexStream.Length)
            {
                adtTexStream.Position = position;
                chunk = new BlizzHeader(bin.ReadChars(4), bin.ReadUInt32());
                chunk.Flip();
                position = adtTexStream.Position + chunk.Size;
                if (chunk.Is("MVER"))
                {
                    if (bin.ReadUInt32() != 18)
                    {
                        throw new Exception("Unsupported ADT version!");
                    }
                    continue;
                }
                if (chunk.Is("MAMP"))
                {
                    continue;
                }
                if (chunk.Is("MTEX"))
                {
                    adtfile.textures = ReadMTEXChunk(chunk, bin); continue;
                }
                if (chunk.Is("MCNK"))
                {
                    adtfile.texChunks[MCNKi] = ReadTexMCNKChunk(chunk, bin); MCNKi++;  continue;
                }
                if (chunk.Is("MTXP"))
                {
                    continue;
                }

                throw new Exception(String.Format("{2} Found unknown header at offset {1} \"{0}\" while we should've already read them all!", chunk.ToString(), position.ToString(), filename));
            }
        }