コード例 #1
0
        private int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
        {
            BinaryReader reader1;
            int          num1;
            int          num2;
            int          num3;
            int          num4;
            int          num5;

            Tile[] tileArray1;
            int    num6;

            using (FileStream stream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream stream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    reader1 = new BinaryReader(stream2);
                    num1    = ((int)(reader1.BaseStream.Length / 4));
                    for (num2 = 0; (num2 < num1); ++num2)
                    {
                        num3 = reader1.ReadInt32();
                        num4 = (num3 / matrix.BlockHeight);
                        num5 = (num3 % matrix.BlockHeight);
                        stream1.Seek(4, SeekOrigin.Current);
                        tileArray1 = new Tile[64];
                        try
                        {
                            fixed(Tile *local1 = tileArray1)
                            {
                            }
                            TileMatrixPatch._lread(stream1.Handle, ((void *)local1), 192);
                        }
                        finally
                        {
                            local1 = ((pinned ref Tile)IntPtr.Zero);
                        }
                        matrix.SetLandBlock(num4, num5, tileArray1);
                    }
                    return(num1);
                }
            }
            return(num6);
        }
コード例 #2
0
        public TileMatrix( Map owner, int fileIndex, int mapID, int width, int height )
        {
            m_FileShare = new ArrayList();

            for ( int i = 0; i < m_Instances.Count; ++i )
            {
                TileMatrix tm = (TileMatrix)m_Instances[i];

                if ( tm.m_FileIndex == fileIndex )
                {
                    tm.m_FileShare.Add( this );
                    m_FileShare.Add( tm );
                }
            }

            m_Instances.Add( this );
            m_FileIndex = fileIndex;
            m_Width = width;
            m_Height = height;
            m_BlockWidth = width >> 3;
            m_BlockHeight = height >> 3;

            m_Owner = owner;

            if ( fileIndex != 0x7F )
            {
                string mapPath = Core.FindDataFile( "map{0}.mul", fileIndex );

                if ( File.Exists( mapPath ) )
                    m_Map = new FileStream( mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );

                string indexPath = Core.FindDataFile( "staidx{0}.mul", fileIndex );

                if ( File.Exists( indexPath ) )
                {
                    m_Index = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                    m_IndexReader = new BinaryReader( m_Index );
                }

                string staticsPath = Core.FindDataFile( "statics{0}.mul", fileIndex );

                if ( File.Exists( staticsPath ) )
                    m_Statics = new FileStream( staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
            }

            m_EmptyStaticBlock = new Tile[8][][];

            for ( int i = 0; i < 8; ++i )
            {
                m_EmptyStaticBlock[i] = new Tile[8][];

                for ( int j = 0; j < 8; ++j )
                    m_EmptyStaticBlock[i][j] = new Tile[0];
            }

            m_InvalidLandBlock = new Tile[196];

            m_LandTiles = new Tile[m_BlockWidth][][];
            m_StaticTiles = new Tile[m_BlockWidth][][][][];
            m_StaticPatches = new int[m_BlockWidth][];
            m_LandPatches = new int[m_BlockWidth][];

            m_Patch = new TileMatrixPatch( this, mapID );
        }
コード例 #3
0
ファイル: TileMatrix.cs プロジェクト: twlizer/runuo
        public TileMatrix(Map owner, int fileIndex, int mapID, int width, int height)
        {
            lock (m_Instances) {
                for (int i = 0; i < m_Instances.Count; ++i)
                {
                    TileMatrix tm = m_Instances[i];

                    if (tm.m_FileIndex == fileIndex)
                    {
                        lock (m_FileShare) {
                            lock (tm.m_FileShare) {
                                tm.m_FileShare.Add(this);
                                m_FileShare.Add(tm);
                            }
                        }
                    }
                }

                m_Instances.Add(this);
            }

            m_FileIndex   = fileIndex;
            m_Width       = width;
            m_Height      = height;
            m_BlockWidth  = width >> 3;
            m_BlockHeight = height >> 3;

            m_Owner = owner;

            if (fileIndex != 0x7F)
            {
                string mapPath = Core.FindDataFile("map{0}.mul", fileIndex);

                if (File.Exists(mapPath))
                {
                    m_Map = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                }
                else
                {
                    mapPath = Core.FindDataFile("map{0}LegacyMUL.uop", fileIndex);

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

                string indexPath = Core.FindDataFile("staidx{0}.mul", fileIndex);

                if (File.Exists(indexPath))
                {
                    m_Index       = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    m_IndexReader = new BinaryReader(m_Index);
                }

                string staticsPath = Core.FindDataFile("statics{0}.mul", fileIndex);

                if (File.Exists(staticsPath))
                {
                    m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                }
            }

            m_EmptyStaticBlock = new StaticTile[8][][];

            for (int i = 0; i < 8; ++i)
            {
                m_EmptyStaticBlock[i] = new StaticTile[8][];

                for (int j = 0; j < 8; ++j)
                {
                    m_EmptyStaticBlock[i][j] = new StaticTile[0];
                }
            }

            m_InvalidLandBlock = new LandTile[196];

            m_LandTiles     = new LandTile[m_BlockWidth][][];
            m_StaticTiles   = new StaticTile[m_BlockWidth][][][][];
            m_StaticPatches = new int[m_BlockWidth][];
            m_LandPatches   = new int[m_BlockWidth][];

            m_Patch = new TileMatrixPatch(this, mapID);
        }
コード例 #4
0
ファイル: TileMatrix.cs プロジェクト: theinfamousrj/ModernUO
        public TileMatrix(Map owner, int fileIndex, int mapID, int width, int height)
        {
            lock (m_Instances)
            {
                for (var i = 0; i < m_Instances.Count; ++i)
                {
                    var tm = m_Instances[i];

                    if (tm.m_FileIndex == fileIndex)
                    {
                        lock (m_FileShare)
                        {
                            lock (tm.m_FileShare)
                            {
                                tm.m_FileShare.Add(this);
                                m_FileShare.Add(tm);
                            }
                        }
                    }
                }

                m_Instances.Add(this);
            }

            m_FileIndex = fileIndex;
            BlockWidth  = width >> 3;
            BlockHeight = height >> 3;

            m_Owner = owner;

            if (fileIndex != 0x7F)
            {
                var mapPath = Core.FindDataFile($"map{fileIndex}LegacyMUL.uop", false, true);

                if (mapPath != null)
                {
                    m_MapStream = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    m_MapIndex  = new UOPIndex(m_MapStream);
                }
                else
                {
                    mapPath = Core.FindDataFile($"map{fileIndex}.mul", false, true);

                    if (mapPath != null)
                    {
                        m_MapStream = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    }
                }

                var indexPath = Core.FindDataFile($"staidx{fileIndex}.mul", false, true);

                if (indexPath != null)
                {
                    IndexStream   = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    m_IndexReader = new BinaryReader(IndexStream);
                }

                var staticsPath = Core.FindDataFile($"statics{fileIndex}.mul", false, true);

                if (staticsPath != null)
                {
                    DataStream = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                }
            }

            EmptyStaticBlock = new StaticTile[8][][];

            for (var i = 0; i < 8; ++i)
            {
                EmptyStaticBlock[i] = new StaticTile[8][];

                for (var j = 0; j < 8; ++j)
                {
                    EmptyStaticBlock[i][j] = Array.Empty <StaticTile>();
                }
            }

            m_InvalidLandBlock = new LandTile[196];

            m_LandTiles     = new LandTile[BlockWidth][][];
            m_StaticTiles   = new StaticTile[BlockWidth][][][][];
            m_StaticPatches = new int[BlockWidth][];
            m_LandPatches   = new int[BlockWidth][];

            Patch = new TileMatrixPatch(this, mapID);
        }
コード例 #5
0
        private int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
        {
            BinaryReader reader1;
            BinaryReader reader2;
            int          num1;

            TileList[][] listArrayArray1;
            int          num2;
            int          num3;
            int          num4;
            int          num5;
            int          num6;
            int          num7;
            int          num8;
            int          num9;
            int          num10;

            StaticTile[] tileArray1;
            StaticTile * tilePtr1;
            StaticTile * tilePtr2;

            Tile[][][] tileArrayArrayArray1;
            int        num11;
            int        num12;
            int        num13;

            using (FileStream stream1 = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream stream2 = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (FileStream stream3 = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        reader1         = new BinaryReader(stream2);
                        reader2         = new BinaryReader(stream3);
                        num1            = ((int)(reader1.BaseStream.Length / 4));
                        listArrayArray1 = new TileList[8][];
                        for (num2 = 0; (num2 < 8); ++num2)
                        {
                            listArrayArray1[num2] = new TileList[8];
                            for (num3 = 0; (num3 < 8); ++num3)
                            {
                                listArrayArray1[num2][num3] = new TileList();
                            }
                        }
                        for (num4 = 0; (num4 < num1); ++num4)
                        {
                            num5 = reader1.ReadInt32();
                            num6 = (num5 / matrix.BlockHeight);
                            num7 = (num5 % matrix.BlockHeight);
                            num8 = reader2.ReadInt32();
                            num9 = reader2.ReadInt32();
                            reader2.ReadInt32();
                            if ((num8 < 0) || (num9 <= 0))
                            {
                                matrix.SetStaticBlock(num6, num7, matrix.EmptyStaticBlock);
                            }
                            else
                            {
                                stream1.Seek(num8, SeekOrigin.Begin);
                                num10 = (num9 / 7);
                                if (TileMatrixPatch.m_TileBuffer.Length < num10)
                                {
                                    TileMatrixPatch.m_TileBuffer = new StaticTile[num10];
                                }
                                tileArray1 = TileMatrixPatch.m_TileBuffer;
                                try
                                {
                                    fixed(StaticTile *local1 = tileArray1)
                                    {
                                    }
                                    TileMatrixPatch._lread(stream1.Handle, ((void *)local1), num9);
                                    tilePtr1 = local1;
                                    tilePtr2 = (local1 + (num10 * sizeof(StaticTile)));
                                    while ((tilePtr1 < tilePtr2))
                                    {
                                        listArrayArray1[(tilePtr1.m_X & 7)][(tilePtr1.m_Y & 7)].Add(((short)((tilePtr1.m_ID & 16383) + 16384)), tilePtr1.m_Z);
                                        tilePtr1 += sizeof(StaticTile);
                                    }
                                    tileArrayArrayArray1 = new Tile[8][][];
                                    for (num11 = 0; (num11 < 8); ++num11)
                                    {
                                        tileArrayArrayArray1[num11] = new Tile[8][];
                                        for (num12 = 0; (num12 < 8); ++num12)
                                        {
                                            tileArrayArrayArray1[num11][num12] = listArrayArray1[num11][num12].ToArray();
                                        }
                                    }
                                    matrix.SetStaticBlock(num6, num7, tileArrayArrayArray1);
                                }
                                finally
                                {
                                    local1 = ((pinned ref StaticTile)IntPtr.Zero);
                                }
                            }
                        }
                        return(num1);
                    }
                }
            }
            return(num13);
        }