示例#1
0
        public void LoadData()
        {
            // File version, must be 18.
            Console.WriteLine("Reading file version...");
            if (!ReadMVER())
            {
                return;
            }

            // MapHeader
            Console.WriteLine("Reading map header...");
            if (!ReadMPHD())
            {
                return;
            }

            // Map tile table. Needs to contain 64x64 = 4096 entries of sizeof(SMAreaInfo)
            Console.WriteLine("Reading MAIN section...");
            if (!ReadMAIN())
            {
                return;
            }

            // Filenames Doodads. Zero-terminated strings with complete paths to models.
            Console.WriteLine("Reading Doodads file names...");
            if (!ReadMDNM())
            {
                return;
            }

            // Filenames WMOS. Zero-terminated strings with complete paths to models.
            Console.WriteLine("Reading WMOS file names...");
            if (!ReadMONM())
            {
                return;
            }

            // Only one instance is possible. It is usually used by WMO based maps which contain no ADT parts with the exception of RazorfenDowns.
            // If this chunk exists, the client marks the map as a dungeon and uses absolute positioning for lights.
            Console.WriteLine("Reading MODF section...");
            if (!ReadMODF())
            {
                return;
            }

            // The start of what is now the ADT files.
            Console.WriteLine($"Reading {SMAreaChunks.Length} Area chunks...");
            if (!LoadMapAreaChunks())
            {
                return;
            }

            Console.WriteLine();
            Console.WriteLine($"Map information:");
            Console.WriteLine($"ADT Version: {ADTVersion}");
            Console.Write(SMOHeader.ToString());
            Console.WriteLine($"DoodadsNames: {DoodadsNames.Count}");
            Console.WriteLine($"MapObjectsNames: {MapObjectsNames.Count}");
            Console.WriteLine($"SMAreaChunks: {SMAreaChunks.Length}");
            Console.WriteLine($"MapAreaChunks: {MapAreaChunks.Count}");

            Console.WriteLine();
            Console.WriteLine("Found data for the following Areas:");
            foreach (var area in GetUniqueAreaIDs())
            {
                if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                {
                    Console.WriteLine($" AreaNumber: {table.AreaNumber}\tAreaName: {table.AreaName_enUS}");
                }
                else
                {
                    Console.WriteLine($" No information found for Area id: {area}");
                }
            }


            Console.WriteLine("Map loading complete.");
            OnRead -= OnBinaryRead;
            Worker  = null;
        }
示例#2
0
        public SMChunk(byte[] chunk) : base(new MemoryStream(chunk))
        {
            flags           = this.ReadUInt32();
            indexX          = this.ReadUInt32();
            indexY          = this.ReadUInt32();
            radius          = this.ReadSingle();
            nLayers         = this.ReadUInt32();
            nDoodadRefs     = this.ReadUInt32();
            offsHeight      = this.ReadUInt32(); // MCVT
            offsNormal      = this.ReadUInt32(); // MCNR
            offsLayer       = this.ReadUInt32(); // MCLY
            offsRefs        = this.ReadUInt32(); // MCRF
            offsAlpha       = this.ReadUInt32(); // MCAL
            sizeAlpha       = this.ReadUInt32();
            offsShadow      = this.ReadUInt32(); // MCSH
            sizeShadow      = this.ReadUInt32();
            area            = this.ReadUInt32(); // in alpha: zone id (4) sub zone id (4)
            nMapObjRefs     = this.ReadUInt32();
            holes_low_res   = this.ReadUInt16();
            padding         = this.ReadUInt16();
            predTex         = this.ReadBytes(16); //It is used to determine which detail doodads to show.
            noEffectDoodad  = this.ReadBytes(8);
            offsSndEmitters = this.ReadUInt32();  // MCSE
            nSndEmitters    = this.ReadUInt32();
            offsLiquid      = this.ReadUInt32();  // MCLQ

            unused = this.ReadBytes(24);

            HeaderOffsetEnd = this.BaseStream.Position;

            // MCVT begin right after header.
            BuildSubMCVT(this, offsHeight);

            if (Globals.Verbose)
            {
                if (!MCVTS.Contains(area))
                {
                    if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                    {
                        Console.WriteLine($"Built MCVT SubChunk for Area: {table.AreaName_enUS}");
                    }
                    MCVTS.Add(area);
                }
            }

            if (offsNormal > 0) //Has MCNR SubChunk
            {
                BuildSubMCNR(this, offsNormal);

                if (Globals.Verbose)
                {
                    if (!MCNRS.Contains(area))
                    {
                        if (DBCStorage.TryGetByAreaNumber(area, out AreaTable table))
                        {
                            Console.WriteLine($"Built MCNR SubChunk for Area: {table.AreaName_enUS}");
                        }
                        MCNRS.Add(area);
                    }
                }
            }
        }