示例#1
0
        static Verdata()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "verdata.mul");

            if (!System.IO.File.Exists(path))
            {
                Patches = new UOFileIndex5D[0];
                File    = null;
            }
            else
            {
                File    = new UOFileMul(path);
                Patches = new UOFileIndex5D[File.ReadInt()];
                Patches = File.ReadArray <UOFileIndex5D>(File.ReadInt());

                /* for (int i = 0; i < Patches.Length; i++)
                 * {
                 *   Patches[i].File = File.ReadInt();
                 *   Patches[i].Index = File.ReadInt();
                 *   Patches[i].Offset = File.ReadInt();
                 *   Patches[i].Length = File.ReadInt();
                 *   Patches[i].Extra = File.ReadInt();
                 * }*/
            }
        }
示例#2
0
        public static void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "tiledata.mul");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException();
            }

            UOFileMul tiledata = new UOFileMul(path);


            bool isold = FileManager.ClientVersion < ClientVersions.CV_7090;

            int staticscount = !isold ?
                               (int)(tiledata.Length - (512 * Marshal.SizeOf <LandGroupNew>())) / Marshal.SizeOf <StaticGroupNew>()
                :
                               (int)(tiledata.Length - (512 * Marshal.SizeOf <LandGroupOld>())) / Marshal.SizeOf <StaticGroupOld>();

            if (staticscount > 2048)
            {
                staticscount = 2048;
            }

            tiledata.Seek(0);

            _landData   = new LandTiles[512 * 32];
            _staticData = new StaticTiles[staticscount * 32];

            for (int i = 0; i < 512; i++)
            {
                tiledata.Skip(4);
                for (int j = 0; j < 32; j++)
                {
                    int idx = (i * 32) + j;
                    _landData[idx].Flags = (TileFlag)(isold ? tiledata.ReadUInt() : tiledata.ReadULong());
                    _landData[idx].TexID = tiledata.ReadUShort();
                    _landData[idx].Name  = Encoding.UTF8.GetString(tiledata.ReadArray(20));
                }
            }

            for (int i = 0; i < staticscount; i++)
            {
                tiledata.Skip(4);
                for (int j = 0; j < 32; j++)
                {
                    int idx = (i * 32) + j;
                    _staticData[idx].Flags      = (TileFlag)(isold ? tiledata.ReadUInt() : tiledata.ReadULong());
                    _staticData[idx].Weight     = tiledata.ReadByte();
                    _staticData[idx].Layer      = tiledata.ReadByte();
                    _staticData[idx].Count      = tiledata.ReadInt();
                    _staticData[idx].AnimID     = tiledata.ReadUShort();
                    _staticData[idx].Hue        = tiledata.ReadUShort();
                    _staticData[idx].LightIndex = tiledata.ReadUShort();
                    _staticData[idx].Height     = tiledata.ReadByte();
                    _staticData[idx].Name       = Encoding.UTF8.GetString(tiledata.ReadArray(20));
                }
            }
        }
示例#3
0
        static Verdata()
        {
            string path = UOFileManager.GetUOFilePath("verdata.mul");

            if (!System.IO.File.Exists(path))
            {
                Patches = new UOFileIndex5D[0];
                File    = null;
            }
            else
            {
                File = new UOFileMul(path);

                // the scope of this try/catch is to avoid unexpected crashes if servers redestribuite wrong verdata
                try
                {
                    Patches = File.ReadArray <UOFileIndex5D>(File.ReadInt());
                }
                catch
                {
                    Patches = new UOFileIndex5D[0];
                }
            }
        }
示例#4
0
        public static void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "tiledata.mul");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException();
            }
            UOFileMul tiledata     = new UOFileMul(path, false);
            bool      isold        = FileManager.ClientVersion < ClientVersions.CV_7090;
            int       staticscount = !isold ? (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupNew>()) / UnsafeMemoryManager.SizeOf <StaticGroupNew>() : (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupOld>()) / UnsafeMemoryManager.SizeOf <StaticGroupOld>();

            if (staticscount > 2048)
            {
                staticscount = 2048;
            }
            tiledata.Seek(0);
            LandData   = new LandTiles[512 * 32];
            StaticData = new StaticTiles[staticscount * 32];
            byte[] bufferString = new byte[20];

            for (int i = 0; i < 512; i++)
            {
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 2 + 20 > tiledata.Length)
                    {
                        goto END;
                    }
                    int idx = i * 32 + j;
                    LandData[idx].Flags = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    LandData[idx].TexID = tiledata.ReadUShort();
                    tiledata.Fill(bufferString, 20);
                    LandData[idx].Name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));
                }
            }

END:

            for (int i = 0; i < staticscount; i++)
            {
                if (tiledata.Position >= tiledata.Length)
                {
                    goto END_2;
                }
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 13 + 20 > tiledata.Length)
                    {
                        goto END_2;
                    }
                    int idx = i * 32 + j;
                    StaticData[idx].Flags      = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    StaticData[idx].Weight     = tiledata.ReadByte();
                    StaticData[idx].Layer      = tiledata.ReadByte();
                    StaticData[idx].Count      = tiledata.ReadInt();
                    StaticData[idx].AnimID     = tiledata.ReadUShort();
                    StaticData[idx].Hue        = tiledata.ReadUShort();
                    StaticData[idx].LightIndex = tiledata.ReadUShort();
                    StaticData[idx].Height     = tiledata.ReadByte();
                    tiledata.Fill(bufferString, 20);
                    StaticData[idx].Name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));
                }
            }

END_2:
            tiledata.Dispose();

            //string pathdef = Path.Combine(FileManager.UoFolderPath, "art.def");
            //if (!File.Exists(pathdef))
            //    return;

            //using (StreamReader reader = new StreamReader(File.OpenRead(pathdef)))
            //{
            //    string line;
            //    while ((line = reader.ReadLine()) != null)
            //    {
            //        line = line.Trim();
            //        if (line.Length <= 0 || line[0] == '#')
            //            continue;
            //        string[] defs = line.Split(new[] { '\t', ' ', '#' }, StringSplitOptions.RemoveEmptyEntries);
            //        if (defs.Length < 2)
            //            continue;

            //        int index = int.Parse(defs[0]);

            //        if (index < 0 || index >= MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
            //            continue;

            //        int first = defs[1].IndexOf("{");
            //        int last = defs[1].IndexOf("}");

            //        string[] newdef = defs[1].Substring(first + 1, last - 1).Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);

            //        foreach (string s in newdef)
            //        {
            //            int checkindex = int.Parse(s);

            //            if (checkindex < 0 || checkindex >= MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
            //                continue;

            //            //_file.Entries[index] = _file.Entries[checkindex];

            //            if (index < MAX_LAND_DATA_INDEX_COUNT && checkindex < MAX_LAND_DATA_INDEX_COUNT && LandData.Length > checkindex && !LandData[checkindex].Equals(default) && (LandData.Length <= index  || LandData[index].Equals(default)))
            //            {
            //                LandData[index] = LandData[checkindex];
            //            }
            //            else if (index >= MAX_LAND_DATA_INDEX_COUNT && checkindex >= MAX_LAND_DATA_INDEX_COUNT)
            //            {
            //                checkindex -= MAX_LAND_DATA_INDEX_COUNT;
            //                checkindex &= 0x3FFF;
            //                index -= MAX_LAND_DATA_INDEX_COUNT;

            //                if ( (StaticData.Length <= index || StaticData[index].Equals(default)) &&
            //                    StaticData.Length > checkindex && !StaticData[checkindex].Equals(default))
            //                {

            //                    StaticData[index] = StaticData[checkindex];

            //                    break;
            //                }

            //            }
            //        }
            //    }
            //}
        }
示例#5
0
        public TileMatrix(int map, int width, int height)
        {
            Width       = width; Height = height;
            BlockWidth  = width >> 3;
            BlockHeight = height >> 3;

            string pathmap = Path.Combine(FileManager.UoFolderPath, string.Format("map{0}LegacyMUL.uop", map));

            if (File.Exists(pathmap))
            {
                _file = new UOFileUop(pathmap, ".dat");
            }
            else
            {
                pathmap = Path.Combine(FileManager.UoFolderPath, string.Format("map{0}.mul", map));
                if (!File.Exists(pathmap))
                {
                    throw new FileNotFoundException();
                }
                _file = new UOFileMul(pathmap);
            }

            string pathstaidx = Path.Combine(FileManager.UoFolderPath, string.Format("staidx{0}.mul", map));

            if (!File.Exists(pathstaidx))
            {
                throw new FileNotFoundException();
            }
            _filestaidx = new UOFileMul(pathstaidx);


            string pathstatics = Path.Combine(FileManager.UoFolderPath, string.Format("statics{0}.mul", map));

            if (!File.Exists(pathstatics))
            {
                throw new FileNotFoundException();
            }
            _filestatics = new UOFileMul(pathstatics);


            EmptyStaticBlock = new HuedTile[8][][];

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

            InvalidLandBlock = new Tile[196];

            _landTiles   = new Tile[BlockWidth][][];
            _staticTiles = new HuedTile[BlockWidth][][][][];

            Patch = new TileMatrixPatch(this, map);


            _staticIndex = new UOFileIndex3D[BlockHeight * BlockWidth];

            int count  = (int)_filestaidx.Length / 12;
            int minlen = (int)Math.Min(_filestaidx.Length, BlockHeight * BlockWidth);

            for (int i = 0; i < count; i++)
            {
                _staticIndex[i].Offset = _filestaidx.ReadInt();
                _staticIndex[i].Length = _filestaidx.ReadInt();
                _staticIndex[i].Extra  = _filestaidx.ReadInt();
            }

            for (int i = minlen; i < BlockHeight * BlockWidth; i++)
            {
                _staticIndex[i].Offset = -1;
                _staticIndex[i].Length = -1;
                _staticIndex[i].Extra  = -1;
            }
        }
示例#6
0
        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "tiledata.mul");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException();
            }
            UOFileMul tiledata     = new UOFileMul(path, true);
            bool      isold        = FileManager.ClientVersion < ClientVersions.CV_7090;
            int       staticscount = !isold ? (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupNew>()) / UnsafeMemoryManager.SizeOf <StaticGroupNew>() : (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupOld>()) / UnsafeMemoryManager.SizeOf <StaticGroupOld>();

            if (staticscount > 2048)
            {
                staticscount = 2048;
            }
            tiledata.Seek(0);
            _landData   = new LandTiles[Constants.MAX_LAND_DATA_INDEX_COUNT];
            _staticData = new StaticTiles[staticscount * 32];
            byte[] bufferString = new byte[20];

            for (int i = 0; i < 512; i++)
            {
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 2 + 20 > tiledata.Length)
                    {
                        goto END;
                    }
                    int    idx    = i * 32 + j;
                    ulong  flags  = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    ushort textId = tiledata.ReadUShort();
                    tiledata.Fill(ref bufferString, 20);
                    string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));
                    LandData[idx] = new LandTiles(flags, textId, name);
                }
            }

END:

            for (int i = 0; i < staticscount; i++)
            {
                if (tiledata.Position >= tiledata.Length)
                {
                    break;
                }
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 13 + 20 > tiledata.Length)
                    {
                        goto END_2;
                    }
                    int idx = i * 32 + j;

                    ulong  flags      = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    byte   weight     = tiledata.ReadByte();
                    byte   layer      = tiledata.ReadByte();
                    int    count      = tiledata.ReadInt();
                    ushort animId     = tiledata.ReadUShort();
                    ushort hue        = tiledata.ReadUShort();
                    ushort lightIndex = tiledata.ReadUShort();
                    byte   height     = tiledata.ReadByte();
                    tiledata.Fill(ref bufferString, 20);
                    string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));

                    StaticData[idx] = new StaticTiles(flags, weight, layer, count, animId, hue, lightIndex, height, name);
                }
            }



            //path = Path.Combine(FileManager.UoFolderPath, "tileart.uop");

            //if (File.Exists(path))
            //{
            //    UOFileUop uop = new UOFileUop(path, ".bin");
            //    DataReader reader = new DataReader();
            //    for (int i = 0; i < uop.Entries.Length; i++)
            //    {
            //        long offset = uop.Entries[i].Offset;
            //        int csize = uop.Entries[i].Length;
            //        int dsize = uop.Entries[i].DecompressedLength;

            //        if (offset == 0)
            //            continue;

            //        uop.Seek(offset);
            //        byte[] cdata = uop.ReadArray<byte>(csize);
            //        byte[] ddata = new byte[dsize];

            //        ZLib.Decompress(cdata, 0, ddata, dsize);

            //        reader.SetData(ddata, dsize);

            //        ushort version = reader.ReadUShort();
            //        uint stringDicOffset = reader.ReadUInt();
            //        uint tileID = reader.ReadUInt();

            //        reader.Skip(1 + // bool unk
            //                    1 + // unk
            //                    4 + // float unk
            //                    4 + // float unk
            //                    4 + // fixed zero ?
            //                    4 + // old id ?
            //                    4 + // unk
            //                    4 + // unk
            //                    1 + // unk
            //                    4 + // 3F800000
            //                    4 + // unk
            //                    4 + // float light
            //                    4 + // float light
            //                    4   // unk
            //                    );

            //        ulong flags = reader.ReadULong();
            //        ulong flags2 = reader.ReadULong();

            //        reader.Skip(4); // unk

            //        reader.Skip(24); // EC IMAGE OFFSET
            //        byte[] imageOffset = reader.ReadArray(24); // 2D IMAGE OFFSET


            //        if (tileID + 0x4000 == 0xa28d)
            //        {
            //            TileFlag f = (TileFlag) flags;

            //        }

            //        int count = reader.ReadByte();
            //        for (int j = 0; j < count; j++)
            //        {
            //            byte prop = reader.ReadByte();
            //            uint value = reader.ReadUInt();
            //        }

            //        count = reader.ReadByte();
            //        for (int j = 0; j < count; j++)
            //        {
            //            byte prop = reader.ReadByte();
            //            uint value = reader.ReadUInt();
            //        }

            //        count = reader.ReadInt(); // Gold Silver
            //        for (int j = 0; j < count; j++)
            //        {
            //            uint amount = reader.ReadUInt();
            //            uint id = reader.ReadUInt();
            //        }

            //        count = reader.ReadInt();

            //        for (int j = 0; j < count; j++)
            //        {
            //            byte val = reader.ReadByte();

            //            if (val != 0)
            //            {
            //                if (val == 1)
            //                {
            //                    byte unk = reader.ReadByte();
            //                    uint unk1 = reader.ReadUInt();
            //                }

            //            }
            //            else
            //            {
            //                int subCount = reader.ReadInt();

            //                for (int k = 0; k < subCount; k++)
            //                {
            //                    uint unk = reader.ReadUInt();
            //                    uint unk1 = reader.ReadUInt();
            //                }
            //            }
            //        }

            //        count = reader.ReadByte();

            //        if (count != 0)
            //        {
            //            uint unk = reader.ReadUInt();
            //            uint unk1 = reader.ReadUInt();
            //            uint unk2 = reader.ReadUInt();
            //            uint unk3 = reader.ReadUInt();
            //        }



            //        if (StaticData[tileID].AnimID == 0)
            //        {
            //            //StaticData[tileID] = new StaticTiles(flags, 0, 0, 0, );
            //        }


            //    }

            //    uop.Dispose();
            //    reader.ReleaseData();
            //}

            string pathdef = Path.Combine(FileManager.UoFolderPath, "art.def");

            if (File.Exists(pathdef))
            {
                using (DefReader reader = new DefReader(pathdef, 1))
                {
                    while (reader.Next())
                    {
                        int index = reader.ReadInt();

                        if (index < 0 || index >= Constants.MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
                        {
                            continue;
                        }

                        int[] group = reader.ReadGroup();

                        for (int i = 0; i < group.Length; i++)
                        {
                            int checkIndex = group[i];

                            if (checkIndex < 0 || checkIndex >= Constants.MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
                            {
                                continue;
                            }

                            if (index < Constants.MAX_LAND_DATA_INDEX_COUNT && checkIndex < Constants.MAX_LAND_DATA_INDEX_COUNT && checkIndex < LandData.Length && index < LandData.Length && !LandData[checkIndex].Equals(default) && LandData[index].Equals(default))
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string path = UOFileManager.GetUOFilePath("tiledata.mul");

                FileSystemHelper.EnsureFileExists(path);

                UOFileMul tileData = new UOFileMul(path);


                bool isold = Client.Version < ClientVersion.CV_7090;
                const int LAND_SIZE = 512;

                int land_group = isold ? Marshal.SizeOf <LandGroupOld>() : Marshal.SizeOf <LandGroupNew>();
                int static_group = isold ? Marshal.SizeOf <StaticGroupOld>() : Marshal.SizeOf <StaticGroupNew>();
                int staticscount = (int)((tileData.Length - LAND_SIZE * land_group) / static_group);

                if (staticscount > 2048)
                {
                    staticscount = 2048;
                }

                tileData.Seek(0);

                _landData = new LandTiles[Constants.MAX_LAND_DATA_INDEX_COUNT];
                _staticData = new StaticTiles[staticscount * 32];
                byte[] bufferString = new byte[20];

                for (int i = 0; i < 512; i++)
                {
                    tileData.Skip(4);

                    for (int j = 0; j < 32; j++)
                    {
                        if (tileData.Position + (isold ? 4 : 8) + 2 + 20 > tileData.Length)
                        {
                            goto END;
                        }

                        int idx = i * 32 + j;
                        ulong flags = isold ? tileData.ReadUInt() : tileData.ReadULong();
                        ushort textId = tileData.ReadUShort();
                        tileData.Fill(ref bufferString, 20);

                        string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));

                        LandData[idx] = new LandTiles(flags, textId, name);
                    }
                }

                END:

                for (int i = 0; i < staticscount; i++)
                {
                    if (tileData.Position >= tileData.Length)
                    {
                        break;
                    }

                    tileData.Skip(4);

                    for (int j = 0; j < 32; j++)
                    {
                        if (tileData.Position + (isold ? 4 : 8) + 13 + 20 > tileData.Length)
                        {
                            goto END_2;
                        }

                        int idx = i * 32 + j;

                        ulong flags = isold ? tileData.ReadUInt() : tileData.ReadULong();
                        byte weight = tileData.ReadByte();
                        byte layer = tileData.ReadByte();
                        int count = tileData.ReadInt();
                        ushort animId = tileData.ReadUShort();
                        ushort hue = tileData.ReadUShort();
                        ushort lightIndex = tileData.ReadUShort();
                        byte height = tileData.ReadByte();
                        tileData.Fill(ref bufferString, 20);

                        string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));

                        StaticData[idx] = new StaticTiles
                                          (
                            flags,
                            weight,
                            layer,
                            count,
                            animId,
                            hue,
                            lightIndex,
                            height,
                            name
                                          );
                    }
                }


                //path = Path.Combine(FileManager.UoFolderPath, "tileart.uop");

                //if (File.Exists(path))
                //{
                //    UOFileUop uop = new UOFileUop(path, ".bin");
                //    DataReader reader = new DataReader();
                //    for (int i = 0; i < uop.Entries.Length; i++)
                //    {
                //        long offset = uop.Entries[i].Offset;
                //        int csize = uop.Entries[i].Length;
                //        int dsize = uop.Entries[i].DecompressedLength;

                //        if (offset == 0)
                //            continue;

                //        uop.Seek(offset);
                //        byte[] cdata = uop.ReadArray<byte>(csize);
                //        byte[] ddata = new byte[dsize];

                //        ZLib.Decompress(cdata, 0, ddata, dsize);

                //        reader.SetData(ddata, dsize);

                //        ushort version = reader.ReadUShort();
                //        uint stringDicOffset = reader.ReadUInt();
                //        uint tileID = reader.ReadUInt();

                //        reader.Skip(1 + // bool unk
                //                    1 + // unk
                //                    4 + // float unk
                //                    4 + // float unk
                //                    4 + // fixed zero ?
                //                    4 + // old id ?
                //                    4 + // unk
                //                    4 + // unk
                //                    1 + // unk
                //                    4 + // 3F800000
                //                    4 + // unk
                //                    4 + // float light
                //                    4 + // float light
                //                    4   // unk
                //                    );

                //        ulong flags = reader.ReadULong();
                //        ulong flags2 = reader.ReadULong();

                //        reader.Skip(4); // unk

                //        reader.Skip(24); // EC IMAGE OFFSET
                //        byte[] imageOffset = reader.ReadArray(24); // 2D IMAGE OFFSET


                //        if (tileID + 0x4000 == 0xa28d)
                //        {
                //            TileFlag f = (TileFlag) flags;

                //        }

                //        int count = reader.ReadByte();
                //        for (int j = 0; j < count; j++)
                //        {
                //            byte prop = reader.ReadByte();
                //            uint value = reader.ReadUInt();
                //        }

                //        count = reader.ReadByte();
                //        for (int j = 0; j < count; j++)
                //        {
                //            byte prop = reader.ReadByte();
                //            uint value = reader.ReadUInt();
                //        }

                //        count = reader.ReadInt(); // Gold Silver
                //        for (int j = 0; j < count; j++)
                //        {
                //            uint amount = reader.ReadUInt();
                //            uint id = reader.ReadUInt();
                //        }

                //        count = reader.ReadInt();

                //        for (int j = 0; j < count; j++)
                //        {
                //            byte val = reader.ReadByte();

                //            if (val != 0)
                //            {
                //                if (val == 1)
                //                {
                //                    byte unk = reader.ReadByte();
                //                    uint unk1 = reader.ReadUInt();
                //                }

                //            }
                //            else
                //            {
                //                int subCount = reader.ReadInt();

                //                for (int k = 0; k < subCount; k++)
                //                {
                //                    uint unk = reader.ReadUInt();
                //                    uint unk1 = reader.ReadUInt();
                //                }
                //            }
                //        }

                //        count = reader.ReadByte();

                //        if (count != 0)
                //        {
                //            uint unk = reader.ReadUInt();
                //            uint unk1 = reader.ReadUInt();
                //            uint unk2 = reader.ReadUInt();
                //            uint unk3 = reader.ReadUInt();
                //        }


                //        if (StaticData[tileID].AnimID == 0)
                //        {
                //            //StaticData[tileID] = new StaticTiles(flags, 0, 0, 0, );
                //        }


                //    }

                //    uop.Dispose();
                //    reader.ReleaseData();
                //}



                END_2:
                tileData.Dispose();
            }
                   ));
        }
示例#8
0
        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "tiledata.mul");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException();
            }
            UOFileMul tiledata     = new UOFileMul(path, false);
            bool      isold        = FileManager.ClientVersion < ClientVersions.CV_7090;
            int       staticscount = !isold ? (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupNew>()) / UnsafeMemoryManager.SizeOf <StaticGroupNew>() : (int)(tiledata.Length - 512 * UnsafeMemoryManager.SizeOf <LandGroupOld>()) / UnsafeMemoryManager.SizeOf <StaticGroupOld>();

            if (staticscount > 2048)
            {
                staticscount = 2048;
            }
            tiledata.Seek(0);
            LandData   = new LandTiles[Constants.MAX_LAND_DATA_INDEX_COUNT];
            StaticData = new StaticTiles[staticscount * 32];
            byte[] bufferString = new byte[20];

            for (int i = 0; i < 512; i++)
            {
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 2 + 20 > tiledata.Length)
                    {
                        goto END;
                    }
                    int    idx    = i * 32 + j;
                    ulong  flags  = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    ushort textId = tiledata.ReadUShort();
                    tiledata.Fill(ref bufferString, 20);
                    string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));
                    LandData[idx] = new LandTiles(flags, textId, name);
                }
            }

END:

            for (int i = 0; i < staticscount; i++)
            {
                if (tiledata.Position >= tiledata.Length)
                {
                    goto END_2;
                }
                tiledata.Skip(4);

                for (int j = 0; j < 32; j++)
                {
                    if (tiledata.Position + (isold ? 4 : 8) + 13 + 20 > tiledata.Length)
                    {
                        goto END_2;
                    }
                    int idx = i * 32 + j;

                    ulong  flags      = isold ? tiledata.ReadUInt() : tiledata.ReadULong();
                    byte   weight     = tiledata.ReadByte();
                    byte   layer      = tiledata.ReadByte();
                    int    count      = tiledata.ReadInt();
                    ushort animId     = tiledata.ReadUShort();
                    ushort hue        = tiledata.ReadUShort();
                    ushort lightIndex = tiledata.ReadUShort();
                    byte   height     = tiledata.ReadByte();
                    tiledata.Fill(ref bufferString, 20);
                    string name = string.Intern(Encoding.UTF8.GetString(bufferString).TrimEnd('\0'));

                    StaticData[idx] = new StaticTiles(flags, weight, layer, count, animId, hue, lightIndex, height, name);
                }
            }

END_2:
            tiledata.Dispose();



            //path = Path.Combine(FileManager.UoFolderPath, "tileart.uop");

            //if (File.Exists(path))
            //{
            //    UOFileUop uop = new UOFileUop(path, ".bin");
            //    DataReader reader = new DataReader();
            //    for (int i = 0; i < uop.Entries.Length; i++)
            //    {
            //        long offset = uop.Entries[i].Offset;
            //        int csize = uop.Entries[i].Length;
            //        int dsize = uop.Entries[i].DecompressedLength;

            //        if (offset == 0)
            //            continue;

            //        uop.Seek(offset);
            //        byte[] cdata = uop.ReadArray<byte>(csize);
            //        byte[] ddata = new byte[dsize];

            //        ZLib.Decompress(cdata, 0, ddata, dsize);

            //        reader.SetData(ddata, dsize);

            //        ushort version = reader.ReadUShort();
            //        uint stringDicOffset = reader.ReadUInt();
            //        uint tileID = reader.ReadUInt();

            //        reader.Skip(1 + // bool unk
            //                    1 + // unk
            //                    4 + // float unk
            //                    4 + // float unk
            //                    4 + // fixed zero ?
            //                    4 + // old id ?
            //                    4 + // unk
            //                    4 + // unk
            //                    1 + // unk
            //                    4 + // 3F800000
            //                    4 + // unk
            //                    4 + // float light
            //                    4 + // float light
            //                    4   // unk
            //                    );

            //        ulong flags = reader.ReadULong();
            //        ulong flags2 = reader.ReadULong();

            //        reader.Skip(4); // unk

            //        reader.Skip(24); // EC IMAGE OFFSET
            //        byte[] imageOffset = reader.ReadArray(24); // 2D IMAGE OFFSET


            //        if (tileID + 0x4000 == 0xa28d)
            //        {
            //            TileFlag f = (TileFlag) flags;

            //        }

            //        int count = reader.ReadByte();
            //        for (int j = 0; j < count; j++)
            //        {
            //            byte prop = reader.ReadByte();
            //            uint value = reader.ReadUInt();
            //        }

            //        count = reader.ReadByte();
            //        for (int j = 0; j < count; j++)
            //        {
            //            byte prop = reader.ReadByte();
            //            uint value = reader.ReadUInt();
            //        }

            //        count = reader.ReadInt(); // Gold Silver
            //        for (int j = 0; j < count; j++)
            //        {
            //            uint amount = reader.ReadUInt();
            //            uint id = reader.ReadUInt();
            //        }

            //        count = reader.ReadInt();

            //        for (int j = 0; j < count; j++)
            //        {
            //            byte val = reader.ReadByte();

            //            if (val != 0)
            //            {
            //                if (val == 1)
            //                {
            //                    byte unk = reader.ReadByte();
            //                    uint unk1 = reader.ReadUInt();
            //                }

            //            }
            //            else
            //            {
            //                int subCount = reader.ReadInt();

            //                for (int k = 0; k < subCount; k++)
            //                {
            //                    uint unk = reader.ReadUInt();
            //                    uint unk1 = reader.ReadUInt();
            //                }
            //            }
            //        }

            //        count = reader.ReadByte();

            //        if (count != 0)
            //        {
            //            uint unk = reader.ReadUInt();
            //            uint unk1 = reader.ReadUInt();
            //            uint unk2 = reader.ReadUInt();
            //            uint unk3 = reader.ReadUInt();
            //        }



            //        if (StaticData[tileID].AnimID == 0)
            //        {
            //            //StaticData[tileID] = new StaticTiles(flags, 0, 0, 0, );
            //        }


            //    }

            //    uop.Dispose();
            //    reader.ReleaseData();
            //}

            //string pathdef = Path.Combine(FileManager.UoFolderPath, "FileManager.Art.def");
            //if (!File.Exists(pathdef))
            //    return;

            //using (StreamReader reader = new StreamReader(File.OpenRead(pathdef)))
            //{
            //    string line;
            //    while ((line = reader.ReadLine()) != null)
            //    {
            //        line = line.Trim();
            //        if (line.Length <= 0 || line[0] == '#')
            //            continue;
            //        string[] defs = line.Split(new[] { '\t', ' ', '#' }, StringSplitOptions.RemoveEmptyEntries);
            //        if (defs.Length < 2)
            //            continue;

            //        int index = int.Parse(defs[0]);

            //        if (index < 0 || index >= MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
            //            continue;

            //        int first = defs[1].IndexOf("{");
            //        int last = defs[1].IndexOf("}");

            //        string[] newdef = defs[1].Substring(first + 1, last - 1).Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);

            //        foreach (string s in newdef)
            //        {
            //            int checkindex = int.Parse(s);

            //            if (checkindex < 0 || checkindex >= MAX_LAND_DATA_INDEX_COUNT + StaticData.Length)
            //                continue;

            //            //_file.Entries[index] = _file.Entries[checkindex];

            //            if (index < MAX_LAND_DATA_INDEX_COUNT && checkindex < MAX_LAND_DATA_INDEX_COUNT && LandData.Length > checkindex && !LandData[checkindex].Equals(default) && (LandData.Length <= index  || LandData[index].Equals(default)))
            //            {
            //                LandData[index] = LandData[checkindex];
            //            }
            //            else if (index >= MAX_LAND_DATA_INDEX_COUNT && checkindex >= MAX_LAND_DATA_INDEX_COUNT)
            //            {
            //                checkindex -= MAX_LAND_DATA_INDEX_COUNT;
            //                checkindex &= 0x3FFF;
            //                index -= MAX_LAND_DATA_INDEX_COUNT;

            //                if ( (StaticData.Length <= index || StaticData[index].Equals(default)) &&
            //                    StaticData.Length > checkindex && !StaticData[checkindex].Equals(default))
            //                {

            //                    StaticData[index] = StaticData[checkindex];

            //                    break;
            //                }

            //            }
            //        }
            //    }
            //}
        }
示例#9
0
        private int PatchStatics(TileMatrix matrix, string path, string pathidx, string pathlookup)
        {
            UOFileMul file   = new UOFileMul(path, pathidx, 0);
            UOFileMul lookup = new UOFileMul(pathlookup);

            int count = Math.Min((int)file.IdxFile.Length / 4, (int)lookup.Length / 12);

            file.Seek(0);
            file.IdxFile.Seek(0);
            lookup.Seek(0);

            HuedTileList[][] lists = new HuedTileList[8][];

            for (int x = 0; x < 8; x++)
            {
                lists[x] = new HuedTileList[8];
                for (int y = 0; y < 8; y++)
                {
                    lists[x][y] = new HuedTileList();
                }
            }

            for (int i = 0; i < count; i++)
            {
                int blockID = file.IdxFile.ReadInt();
                int blockX  = blockID / matrix.BlockHeight;
                int blockY  = blockID % matrix.BlockHeight;

                int offset = lookup.ReadInt();
                int length = lookup.ReadInt();

                lookup.Skip(4);

                if (offset < 0 || length < 0)
                {
                    if (StaticBlocks[blockX] == null)
                    {
                        StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                    }
                    StaticBlocks[blockX][blockY] = TileMatrix.EmptyStaticBlock;
                    continue;
                }

                file.Seek(offset);

                int tileCount = length / 7;
                if (_tileBuffer.Length < tileCount)
                {
                    _tileBuffer = new StaticTile[tileCount];
                }

                StaticTile[] statiles = _tileBuffer;

                for (int j = 0; j < tileCount; j++)
                {
                    statiles[j].ID  = file.ReadUShort();
                    statiles[j].X   = file.ReadByte();
                    statiles[j].Y   = file.ReadByte();
                    statiles[j].Z   = file.ReadSByte();
                    statiles[j].Hue = file.ReadUShort();

                    lists[statiles[j].X & 0x7][statiles[j].Y & 0x7].Add(statiles[j].ID, statiles[j].Hue, statiles[j].Z);
                }

                HuedTile[][][] tiles = new HuedTile[8][][];

                for (int x = 0; x < 8; x++)
                {
                    tiles[x] = new HuedTile[8][];
                    for (int y = 0; y < 8; y++)
                    {
                        tiles[x][y] = lists[x][y].ToArray();
                    }
                }

                if (StaticBlocks[blockX] == null)
                {
                    StaticBlocks[blockX] = new HuedTile[matrix.BlockHeight][][][];
                }
                StaticBlocks[blockX][blockY] = tiles;
            }

            return(count);
        }