bool LoadMapStream(uint index, out FileStream mapDataStream, out UOPIndex uopIndex)
        {
            mapDataStream = null;
            uopIndex      = null;
            string path = FileManager.GetFilePath($"map{index}.mul");

            if (File.Exists(path))
            {
                mapDataStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                return(true);
            }
            path = FileManager.GetFilePath($"map{index}LegacyMUL.uop");
            if (File.Exists(path))
            {
                mapDataStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                uopIndex      = new UOPIndex(m_MapDataStream);
                return(true);
            }
            return(false);
        }
Example #2
0
        public TileMatrixData(uint index)
        {
            FileStream staticIndexStream;

            var mapPath = FileManager.GetFilePath(String.Format("map{0}.mul", index));

            if (File.Exists(mapPath))
            {
                m_MapDataStream = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            }
            else
            {
                mapPath = FileManager.GetFilePath(String.Format("map{0}LegacyMUL.uop", index));

                if (File.Exists(mapPath))
                {
                    m_MapDataStream = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    m_MapIndex      = new UOPIndex(m_MapDataStream);
                }
            }

            staticIndexStream  = FileManager.GetFile("staidx{0}.mul", index);
            m_StaticDataStream = FileManager.GetFile("statics{0}.mul", index);

            if (m_MapDataStream == null)
            {
                // the map we tried to load does not exist. Try alternate for felucca / trammel ?
                if (index == 1)
                {
                    uint trammel  = 0;
                    var  mapPath2 = FileManager.GetFilePath(String.Format("map{0}.mul", trammel));

                    if (File.Exists(mapPath2))
                    {
                        m_MapDataStream = new FileStream(mapPath2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    }
                    else
                    {
                        mapPath2 = FileManager.GetFilePath(String.Format("map{0}LegacyMUL.uop", trammel));

                        if (File.Exists(mapPath2))
                        {
                            m_MapDataStream = new FileStream(mapPath2, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            m_MapIndex      = new UOPIndex(m_MapDataStream);
                        }
                    }
                    staticIndexStream  = FileManager.GetFile("staidx{0}.mul", trammel);
                    m_StaticDataStream = FileManager.GetFile("statics{0}.mul", trammel);
                }
                else
                {
                    Tracer.Critical("Unknown map index {0}", index);
                }
            }

            m_StaticIndexReader = new BinaryReader(staticIndexStream);

            ChunkHeight = m_MapChunkHeightList[index];
            ChunkWidth  = (uint)m_MapDataStream.Length / (ChunkHeight * m_SizeLandChunk);

            m_EmptyStaticsChunk       = new byte[0];
            m_InvalidLandChunk        = new byte[m_SizeLandChunkData];
            m_bufferedLandChunks_Keys = new uint[m_bufferedLandChunksMaxCount];
            m_bufferedLandChunks      = new byte[m_bufferedLandChunksMaxCount][];
            for (uint i = 0; i < m_bufferedLandChunksMaxCount; i++)
            {
                m_bufferedLandChunks[i] = new byte[m_SizeLandChunkData];
            }

            m_StaticTileLoadingBuffer = new byte[2048];

            m_Patch = new TileMatrixDataPatch(this, index);
        }