示例#1
0
        public ADT(IBinaryReader reader)
        {
            string[]? worldMapObjectsIds = null;
            string[]? m2Ids = null;
            Dictionary <int, string>?wmosNameOffsets = null;
            Dictionary <int, string>?m2NameOffsets   = null;
            int chunkId = 0;

            while (!reader.IsFinished())
            {
                var chunkName = reader.ReadChunkName();
                var size      = reader.ReadInt32();

                var offset = reader.Offset;

                var partialReader = new LimitedReader(reader, size);

                if (chunkName == "MTEX")
                {
                    Textures = ChunkedUtils.ReadZeroTerminatedStringArrays(partialReader, false, out _);
                }
                else if (chunkName == "MWMO")
                {
                    ChunkedUtils.ReadZeroTerminatedStringArrays(partialReader, true, out wmosNameOffsets);
                }
                else if (chunkName == "MWID")
                {
                    worldMapObjectsIds = ReadNameOffsets(partialReader, wmosNameOffsets);
                }
                else if (chunkName == "MODF")
                {
                    WorldMapObjects = ReadWorldMapObjectPlacementData(partialReader, worldMapObjectsIds);
                }
                else if (chunkName == "MMDX")
                {
                    ChunkedUtils.ReadZeroTerminatedStringArrays(partialReader, true, out m2NameOffsets);
                }
                else if (chunkName == "MMID")
                {
                    m2Ids = ReadNameOffsets(partialReader, m2NameOffsets);
                }
                else if (chunkName == "MDDF")
                {
                    M2Objects = ReadM2PlacementData(partialReader, m2Ids);
                }
                else if (chunkName == "MCNK")
                {
                    Chunks[chunkId++] = new AdtChunk(partialReader);
                }

                reader.Offset = offset + size;
            }
        }
示例#2
0
        public WDT(IBinaryReader reader)
        {
            int chunkId = 0;
            Dictionary <int, string>?mwmosNameOffsets = null;

            while (!reader.IsFinished())
            {
                var chunkName = reader.ReadChunkName();
                var size      = reader.ReadInt32();

                var offset = reader.Offset;

                var partialReader = new LimitedReader(reader, size);

                if (chunkName == "MVER")
                {
                    Version = reader.ReadUInt32();
                }
                else if (chunkName == "MPHD")
                {
                    Header = WDTHeader.Read(partialReader);
                }
                else if (chunkName == "MAIN")
                {
                    Chunks[chunkId++] = new WDTChunk(partialReader);
                }
                else if (chunkName == "MWMO")
                {
                    Mwmo = ChunkedUtils.ReadZeroTerminatedStringArrays(partialReader, true, out mwmosNameOffsets)[0];
                }
                else if (chunkName == "MODF")
                {
                    WorldMapObject = MODF.Read(partialReader);
                }
                reader.Offset = offset + size;
            }
        }