Represents land tile data. ItemData LandData
示例#1
0
 public static void ApplyFilterLand(LandData land)
 {
     refMarker.treeViewLand.BeginUpdate();
     refMarker.treeViewLand.Nodes.Clear();
     List<TreeNode> nodes = new List<TreeNode>();
     for (int i = 0; i < TileData.LandTable.Length; ++i)
     {
         if (!String.IsNullOrEmpty(land.Name))
         {
             if (!TileData.ItemTable[i].Name.ToLower().Contains(land.Name.ToLower()))
                 continue;
         }
         if (land.TextureID != 0)
         {
             if (TileData.LandTable[i].TextureID != land.TextureID)
                 continue;
         }
         if (land.Flags != 0)
         {
             if ((TileData.LandTable[i].Flags & land.Flags) == 0)
                 continue;
         }
         TreeNode node = new TreeNode(String.Format("0x{0:X4} ({0}) {1}", i, TileData.LandTable[i].Name));
         node.Tag = i;
         nodes.Add(node);
     }
     refMarker.treeViewLand.Nodes.AddRange(nodes.ToArray());
     refMarker.treeViewLand.EndUpdate();
     if (refMarker.treeViewLand.Nodes.Count > 0)
         refMarker.treeViewLand.SelectedNode = refMarker.treeViewLand.Nodes[0];
 }
示例#2
0
        public static unsafe void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[] buffer = new byte[fs.Length];
                    GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        if (Ultima.Art.IsUOHS) // TileData после HS
                        {
                            for (int i = 0; i < 0x4000; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));

                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(LandTileDataMul);
                                    LandTileDataMul cur = (LandTileDataMul)Marshal.PtrToStructure(ptr, typeof(LandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }
                        else // TileData до HS
                        {
                            for (int i = 0; i < 0x4000; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));

                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(LandTileOldDataMul);
                                    LandTileOldDataMul cur = (LandTileOldDataMul)Marshal.PtrToStructure(ptr, typeof(LandTileOldDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        int remaining = (int)(buffer.Length - currpos);
                        int itemlength; // 32 записи длиной 41/37 байт в блоке с шапкой 4 байта
                        itemlength = 32 * remaining / (4 + 32 * (Ultima.Art.IsUOHS ? 41 : 37));
                        itemheader = new int[itemlength / 32];
                        //itemlength = Math.Min(Art.StaticLength, itemlength);

                        m_ItemData = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        if (Ultima.Art.IsUOHS) // TileData после HS
                        {
                            for (int i = 0; i < itemlength; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(ItemTileDataMul);
                                    ItemTileDataMul cur = (ItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(ItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                        else // TileData до HS
                        {
                            for (int i = 0; i < itemlength; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(ItemTileOldDataMul);
                                    ItemTileOldDataMul cur = (ItemTileOldDataMul)Marshal.PtrToStructure(ptr, typeof(ItemTileOldDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }

                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }
示例#3
0
文件: TileData.cs 项目: credzba/Razor
        public unsafe static void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    bool useNeWTileDataFormat = Art.IsUOAHS();
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[]   buffer  = new byte[fs.Length];
                    GCHandle gc      = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long     currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        for (int i = 0; i < 0x4000; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos        += 4;
                            landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewLandTileDataMul);
                                    NewLandTileDataMul cur =
                                        (NewLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                                else
                                {
                                    currpos += sizeof(OldLandTileDataMul);
                                    OldLandTileDataMul cur =
                                        (OldLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        long remaining  = buffer.Length - currpos;
                        int  structsize = useNeWTileDataFormat ? sizeof(NewItemTileDataMul) : sizeof(OldItemTileDataMul);
                        itemheader = new int[(remaining / ((structsize * 32) + 4))];
                        int itemlength = itemheader.Length * 32;

                        m_ItemData    = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        for (int i = 0; i < itemlength; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos        += 4;
                            itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewItemTileDataMul);
                                    NewItemTileDataMul cur =
                                        (NewItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewItemTileDataMul));
                                    m_ItemData[i + count]    = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                                else
                                {
                                    currpos += sizeof(OldItemTileDataMul);
                                    OldItemTileDataMul cur =
                                        (OldItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldItemTileDataMul));
                                    m_ItemData[i + count]    = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }
示例#4
0
        public static unsafe void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    bool useNeWTileDataFormat = Art.IsUOAHS();
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[] buffer = new byte[fs.Length];
                    GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        for (int i = 0; i < 0x4000; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos += 4;
                            landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewLandTileDataMul);
                                    NewLandTileDataMul cur = (NewLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                                else
                                {
                                    currpos += sizeof(OldLandTileDataMul);
                                    OldLandTileDataMul cur = (OldLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        long remaining = buffer.Length - currpos;
                        int structsize = useNeWTileDataFormat ? sizeof(NewItemTileDataMul) : sizeof(OldItemTileDataMul);
                        itemheader = new int[(remaining / ((structsize * 32) + 4))];
                        int itemlength = itemheader.Length * 32;

                        m_ItemData = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        for (int i = 0; i < itemlength; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos += 4;
                            itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewItemTileDataMul);
                                    NewItemTileDataMul cur = (NewItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                                else
                                {
                                    currpos += sizeof(OldItemTileDataMul);
                                    OldItemTileDataMul cur = (OldItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }
示例#5
0
        private void OnClickApplyFilterLand(object sender, EventArgs e)
        {
            LandData land = new LandData();
            string name = textBoxNameLand.Text;
            if (name.Length > 20)
                name = name.Substring(0, 20);
            land.Name = name;
            short shortres;
            if (short.TryParse(textBoxTexID.Text, out shortres))
                land.TextureID = shortres;
            land.Flags = TileFlag.None;
            if (checkedListBox2.GetItemChecked(0))
                land.Flags |= TileFlag.Damaging;
            if (checkedListBox2.GetItemChecked(1))
                land.Flags |= TileFlag.Wet;
            if (checkedListBox2.GetItemChecked(2))
                land.Flags |= TileFlag.Impassable;
            if (checkedListBox2.GetItemChecked(3))
                land.Flags |= TileFlag.Wall;
            if (checkedListBox2.GetItemChecked(4))
                land.Flags |= TileFlag.Unknown3;

            TileDatas.ApplyFilterLand(land);
        }
示例#6
0
        static TileData()
        {
            string filePath = Client.GetFilePath( "tiledata.mul" );

            if ( filePath != null )
            {
                using ( FileStream fs = new FileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                {
                    BinaryReader bin = new BinaryReader( fs );

                    m_LandData = new LandData[0x4000];

                    for ( int i = 0; i < 0x4000; ++i )
                    {
                        if ( (i & 0x1F) == 0 )
                        {
                            bin.ReadInt32(); // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16(); // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData( ReadNameString( bin ), flags );
                    }

                    m_ItemData = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for ( int i = 0; i < 0x4000; ++i )
                    {
                        if ( (i & 0x1F) == 0 )
                            bin.ReadInt32(); // header

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        int weight = bin.ReadByte();
                        int quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height, anim );
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
示例#7
0
        static TileData()
        {
            string filePath = Client.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    // Client Version : 7.0.9.0
                    if (fs.Length == 3188736)
                    {
                        m_LandData = new LandData[0x4000];

                        for (int i = 0; i < 0x4000; ++i)
                        {
                            if (i == 1 || (i > 0 && (i & 0x1F) == 0))
                            {
                                bin.ReadInt32(); // header
                            }

                            TileFlag flags = (TileFlag)bin.ReadInt64();
                            bin.ReadInt16(); // skip 2 bytes -- textureID

                            m_LandData[i] = new LandData(ReadNameString(bin), flags);
                        }

                        m_ItemData = new ItemData[0x10000];

                        for (int i = 0; i < 0x10000; ++i)
                        {
                            if ((i & 0x1F) == 0)
                            {
                                bin.ReadInt32(); // header
                            }

                            TileFlag flags   = (TileFlag)bin.ReadInt64();
                            int      weight  = bin.ReadByte();
                            int      quality = bin.ReadByte();
                            bin.ReadInt16();
                            bin.ReadByte();
                            int quantity = bin.ReadByte();
                            bin.ReadInt32();
                            bin.ReadByte();
                            int value  = bin.ReadByte();
                            int height = bin.ReadByte();

                            m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                        }
                    }
                    else
                    {
                        m_LandData = new LandData[0x4000];

                        for (int i = 0; i < 0x4000; ++i)
                        {
                            if ((i & 0x1F) == 0)
                            {
                                bin.ReadInt32(); // header
                            }

                            TileFlag flags = (TileFlag)bin.ReadInt32();
                            bin.ReadInt16(); // skip 2 bytes -- textureID

                            m_LandData[i] = new LandData(ReadNameString(bin), flags);
                        }

                        // Client Version : 7.0.0.0
                        if (fs.Length == 1644544)
                        {
                            m_ItemData = new ItemData[0x8000];

                            for (int i = 0; i < 0x8000; ++i)
                            {
                                if ((i & 0x1F) == 0)
                                {
                                    bin.ReadInt32(); // header
                                }

                                TileFlag flags   = (TileFlag)bin.ReadInt32();
                                int      weight  = bin.ReadByte();
                                int      quality = bin.ReadByte();
                                bin.ReadInt16();
                                bin.ReadByte();
                                int quantity = bin.ReadByte();
                                bin.ReadInt32();
                                bin.ReadByte();
                                int value  = bin.ReadByte();
                                int height = bin.ReadByte();

                                m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                            }
                        }
                        else
                        {
                            m_ItemData = new ItemData[0x4000];

                            for (int i = 0; i < 0x4000; ++i)
                            {
                                if ((i & 0x1F) == 0)
                                {
                                    bin.ReadInt32(); // header
                                }

                                TileFlag flags   = (TileFlag)bin.ReadInt32();
                                int      weight  = bin.ReadByte();
                                int      quality = bin.ReadByte();
                                bin.ReadInt16();
                                bin.ReadByte();
                                int quantity = bin.ReadByte();
                                bin.ReadInt32();
                                bin.ReadByte();
                                int value  = bin.ReadByte();
                                int height = bin.ReadByte();

                                m_ItemData[i] = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height);
                            }
                        }
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }