コード例 #1
0
        private void ReadBodyconv()
        {
            FileInfo file = new FileInfo(Path.Combine(FileManager.UoFolderPath, "Bodyconv.def"));

            if (!file.Exists)
            {
                return;
            }

            using (DefReader defReader = new DefReader(file.FullName))
            {
                while (defReader.Next())
                {
                    int index = defReader.ReadInt();
                    if (index >= Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT)
                    {
                        continue;
                    }

                    int[] anim =
                    {
                        defReader.ReadInt(), -1, -1, -1
                    };

                    if (defReader.PartsCount >= 3)
                    {
                        anim[1] = defReader.ReadInt();

                        if (defReader.PartsCount >= 4)
                        {
                            anim[2] = defReader.ReadInt();

                            if (defReader.PartsCount >= 5)
                            {
                                anim[3] = defReader.ReadInt();
                            }
                        }
                    }

                    int    startAnimID              = -1;
                    int    animFile                 = 0;
                    ushort realAnimID               = 0;
                    sbyte  mountedHeightOffset      = 0;
                    ANIMATION_GROUPS_TYPE groupType = ANIMATION_GROUPS_TYPE.UNKNOWN;


                    if (anim[0] != -1)
                    {
                        animFile   = 1;
                        realAnimID = (ushort)anim[0];

                        if (index == 0x00C0 || index == 793)
                        {
                            mountedHeightOffset = -9;
                        }

                        if (realAnimID == 68)
                        {
                            realAnimID = 122;
                        }

                        if (realAnimID < 200)
                        {
                            startAnimID = realAnimID * 110;
                            groupType   = ANIMATION_GROUPS_TYPE.MONSTER;
                        }
                        else
                        {
                            if (realAnimID < 400)
                            {
                                startAnimID = realAnimID * 65 + 9000;
                                groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                            }
                            else
                            {
                                startAnimID = (realAnimID - 200) * 175;
                                groupType   = ANIMATION_GROUPS_TYPE.HUMAN;
                            }
                        }
                    }
                    else if (anim[1] != -1)
                    {
                        animFile   = 2;
                        realAnimID = (ushort)anim[1];

                        if (realAnimID < 300)
                        {
                            if (FileManager.ClientVersion < ClientVersions.CV_70130)
                            {
                                startAnimID = realAnimID * 110; // 33000 + ((realAnimID - 300) * 110);
                                groupType   = ANIMATION_GROUPS_TYPE.MONSTER;
                            }
                            else
                            {
                                startAnimID = realAnimID * 65 + 9000;
                                groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                            }
                        }
                        else
                        {
                            if (realAnimID < 400)
                            {
                                if (FileManager.ClientVersion < ClientVersions.CV_70130)
                                {
                                    startAnimID = realAnimID * 65 /*+ 9000*/;
                                    groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                                }
                                else
                                {
                                    startAnimID = 33000 + ((realAnimID - 300) * 110);
                                    groupType   = ANIMATION_GROUPS_TYPE.MONSTER;
                                }
                            }
                            else
                            {
                                startAnimID = 35000 + ((realAnimID - 400) * 175);
                                groupType   = ANIMATION_GROUPS_TYPE.HUMAN;
                            }
                        }
                    }
                    else if (anim[2] != -1)
                    {
                        animFile   = 3;
                        realAnimID = (ushort)anim[2];

                        if (realAnimID < 200)
                        {
                            startAnimID = realAnimID * 110;
                            groupType   = ANIMATION_GROUPS_TYPE.MONSTER;
                        }
                        else
                        {
                            if (realAnimID < 400)
                            {
                                startAnimID = realAnimID * 65 + 9000;
                                groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                            }
                            else
                            {
                                startAnimID = (realAnimID - 200) * 175;
                                groupType   = ANIMATION_GROUPS_TYPE.HUMAN;
                            }
                        }
                    }
                    else if (anim[3] != -1)
                    {
                        animFile            = 4;
                        realAnimID          = (ushort)anim[3];
                        mountedHeightOffset = -9;

                        if (index == 0x0115 || index == 0x00C0)
                        {
                            mountedHeightOffset = 0;
                        }

                        if (realAnimID != 34)
                        {
                            if (realAnimID < 200)
                            {
                                startAnimID = realAnimID * 110;
                                groupType   = ANIMATION_GROUPS_TYPE.MONSTER;
                            }
                            else
                            {
                                if (realAnimID < 400)
                                {
                                    startAnimID = realAnimID * 65 + 9000;
                                    groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                                }
                                else
                                {
                                    startAnimID = (realAnimID - 200) * 175;
                                    groupType   = ANIMATION_GROUPS_TYPE.HUMAN;
                                }
                            }
                        }
                        else
                        {
                            startAnimID = 0x2BCA;
                            groupType   = ANIMATION_GROUPS_TYPE.ANIMAL;
                        }
                    }


                    if (startAnimID != -1 && animFile != 0)
                    {
                        if (!_bodiesConv.TryGetValue(index, out var list) || list == null)
                        {
                            list = new List <BodyConvInfo>();
                            _bodiesConv.Add(index, list);
                        }

                        list.Add(new BodyConvInfo((ushort)index, (ushort)realAnimID, (byte)animFile, false, groupType, startAnimID));
                    }
                }
            }
        }
コード例 #2
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string path = Path.Combine(FileManager.UoFolderPath, "tiledata.mul");

                FileSystemHelper.EnsureFileExists(path);

                UOFileMul tiledata = new UOFileMul(path);
                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))
コード例 #3
0
ファイル: SoundsLoader.cs プロジェクト: xoozyx/ClassicUO
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string path = UOFileManager.GetUOFilePath("soundLegacyMUL.uop");

                if (File.Exists(path))
                {
                    _file = new UOFileUop(path, "build/soundlegacymul/{0:D8}.dat");
                    Entries = new UOFileIndex[Constants.MAX_SOUND_DATA_INDEX_COUNT];
                }
                else
                {
                    path = UOFileManager.GetUOFilePath("sound.mul");
                    string idxpath = UOFileManager.GetUOFilePath("soundidx.mul");

                    if (File.Exists(path) && File.Exists(idxpath))
                    {
                        _file = new UOFileMul(path, idxpath, Constants.MAX_SOUND_DATA_INDEX_COUNT);
                    }
                    else
                    {
                        throw new FileNotFoundException("no sounds found");
                    }
                }

                _file.FillEntries(ref Entries);

                string def = UOFileManager.GetUOFilePath("Sound.def");

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

                            if (index < 0 || index >= Constants.MAX_SOUND_DATA_INDEX_COUNT || index >= _file.Length || Entries[index].Length != 0)
                            {
                                continue;
                            }

                            int[] group = reader.ReadGroup();

                            if (group == null)
                            {
                                continue;
                            }

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

                                if (checkIndex < -1 || checkIndex >= Constants.MAX_SOUND_DATA_INDEX_COUNT)
                                {
                                    continue;
                                }

                                ref UOFileIndex ind = ref Entries[index];

                                if (checkIndex == -1)
                                {
                                    ind = default;
                                }
                                else
                                {
                                    ref readonly UOFileIndex outInd = ref Entries[checkIndex];
コード例 #4
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string path = UOFileManager.GetUOFilePath("texmaps.mul");
                string pathidx = UOFileManager.GetUOFilePath("texidx.mul");

                FileSystemHelper.EnsureFileExists(path);
                FileSystemHelper.EnsureFileExists(pathidx);

                _file = new UOFileMul(path, pathidx, Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT, 10);
                _file.FillEntries(ref Entries);
                string pathdef = UOFileManager.GetUOFilePath("TexTerr.def");

                if (!File.Exists(pathdef))
                {
                    return;
                }

                using (DefReader defReader = new DefReader(pathdef))
                {
                    while (defReader.Next())
                    {
                        int index = defReader.ReadInt();

                        if (index < 0 || index >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT)
                        {
                            continue;
                        }

                        int[] group = defReader.ReadGroup();

                        if (group == null)
                        {
                            continue;
                        }

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

                            if (checkindex < 0 || checkindex >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT)
                            {
                                continue;
                            }

                            Entries[index] = Entries[checkindex];
                        }
                    }
                }

                //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 >= TEXTMAP_COUNT)
                //            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 >= TEXTMAP_COUNT)
                //                continue;
                //            _file.Entries[index] = _file.Entries[checkindex];
                //        }
                //    }
                //}
            }));
        }
コード例 #5
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string path = UOFileManager.GetUOFilePath("gumpartLegacyMUL.uop");

                if (Client.IsUOPInstallation && File.Exists(path))
                {
                    _file = new UOFileUop(path, "build/gumpartlegacymul/{0:D8}.tga", true);
                    Entries = new UOFileIndex[Math.Max(((UOFileUop)_file).TotalEntriesCount, Constants.MAX_GUMP_DATA_INDEX_COUNT)];
                    Client.UseUOPGumps = true;
                }
                else
                {
                    path = UOFileManager.GetUOFilePath("gumpart.mul");
                    string pathidx = UOFileManager.GetUOFilePath("gumpidx.mul");

                    if (!File.Exists(path))
                    {
                        path = UOFileManager.GetUOFilePath("Gumpart.mul");
                    }

                    if (!File.Exists(pathidx))
                    {
                        pathidx = UOFileManager.GetUOFilePath("Gumpidx.mul");
                    }

                    _file = new UOFileMul(path, pathidx, Constants.MAX_GUMP_DATA_INDEX_COUNT, 12);

                    Client.UseUOPGumps = false;
                }

                _file.FillEntries(ref Entries);

                string pathdef = UOFileManager.GetUOFilePath("gump.def");

                if (!File.Exists(pathdef))
                {
                    return;
                }

                using (DefReader defReader = new DefReader(pathdef, 3))
                {
                    while (defReader.Next())
                    {
                        int ingump = defReader.ReadInt();

                        if (ingump < 0 || ingump >= Constants.MAX_GUMP_DATA_INDEX_COUNT ||
                            ingump >= Entries.Length || Entries[ingump].Length > 0)
                        {
                            continue;
                        }

                        int[] group = defReader.ReadGroup();

                        if (group == null)
                        {
                            continue;
                        }

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

                            if (checkIndex < 0 || checkIndex >= Constants.MAX_GUMP_DATA_INDEX_COUNT ||
                                checkIndex >= Entries.Length || Entries[checkIndex].Length <= 0)
                            {
                                continue;
                            }

                            Entries[ingump] = Entries[checkIndex];

                            Entries[ingump].Hue = (ushort)defReader.ReadInt();

                            break;
                        }
                    }
                }
            }
                   ));
        }
コード例 #6
0
        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "soundLegacyMUL.uop");

            if (File.Exists(path))
            {
                _file = new UOFileUop(path, ".dat", Constants.MAX_SOUND_DATA_INDEX_COUNT);
            }
            else
            {
                path = Path.Combine(FileManager.UoFolderPath, "sound.mul");
                string idxpath = Path.Combine(FileManager.UoFolderPath, "soundidx.mul");

                if (File.Exists(path) && File.Exists(idxpath))
                {
                    _file = new UOFileMul(path, idxpath, Constants.MAX_SOUND_DATA_INDEX_COUNT);
                }
                else
                {
                    throw new FileNotFoundException("no sounds found");
                }
            }

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

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

                        if (index < 0 || index >= Constants.MAX_SOUND_DATA_INDEX_COUNT || index >= _file.Length || _file.Entries[index].Length != 0)
                        {
                            continue;
                        }

                        int[] group = reader.ReadGroup();
                        if (group == null)
                        {
                            continue;
                        }

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

                            if (checkIndex < -1 || checkIndex >= Constants.MAX_SOUND_DATA_INDEX_COUNT)
                            {
                                continue;
                            }

                            ref UOFileIndex3D ind = ref _file.Entries[index];

                            if (checkIndex == -1)
                            {
                                ind = default;
                            }
                            else
                            {
                                ref UOFileIndex3D outInd = ref _file.Entries[checkIndex];

                                if (outInd.Length == 0)
                                {
                                    continue;
                                }

                                _file.Entries[index] = _file.Entries[checkIndex];
                            }
                        }
                    }
                }
コード例 #7
0
ファイル: GumpsLoader.cs プロジェクト: plugtopus/WisQuas2
        //private readonly List<uint> _usedIndex = new List<uint>();

        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "gumpartLegacyMUL.uop");

            if (File.Exists(path))
            {
                _file = new UOFileUop(path, ".tga", Constants.MAX_GUMP_DATA_INDEX_COUNT, true);
                FileManager.UseUOPGumps = true;
            }
            else
            {
                path = Path.Combine(FileManager.UoFolderPath, "Gumpart.mul");
                string pathidx = Path.Combine(FileManager.UoFolderPath, "Gumpidx.mul");
                if (File.Exists(path) && File.Exists(pathidx))
                {
                    _file = new UOFileMul(path, pathidx, Constants.MAX_GUMP_DATA_INDEX_COUNT, 12);
                }
                FileManager.UseUOPGumps = false;
            }

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

            if (!File.Exists(pathdef))
            {
                return;
            }

            using (DefReader defReader = new DefReader(pathdef, 3))
            {
                while (defReader.Next())
                {
                    int ingump = defReader.ReadInt();

                    //if (ingump >= 50000)
                    //{
                    //    if (ingump >= 60000)
                    //        ingump -= 60000;
                    //    else
                    //        ingump -= 50000;
                    //}

                    if (ingump < 0 || ingump >= Constants.MAX_GUMP_DATA_INDEX_COUNT /*|| _file.Entries[ingump].DecompressedLength != 0*/)
                    {
                        continue;
                    }

                    int outgump = defReader.ReadGroupInt();

                    //if (outgump >= 50000)
                    //{
                    //    if (outgump >= 60000)
                    //        outgump -= 60000;
                    //    else
                    //        outgump -= 50000;
                    //}

                    if (outgump < 0 || outgump >= Constants.MAX_GUMP_DATA_INDEX_COUNT /*|| _file.Entries[outgump].DecompressedLength != 0*/)
                    {
                        continue;
                    }

                    _file.Entries[ingump] = _file.Entries[outgump];
                }
            }
        }
コード例 #8
0
        //private readonly List<uint> _usedIndex = new List<uint>();

        public override Task Load()
        {
            return(Task.Run(() => {
                string path = Path.Combine(FileManager.UoFolderPath, "gumpartLegacyMUL.uop");

                if (File.Exists(path))
                {
                    _file = new UOFileUop(path, ".tga", Constants.MAX_GUMP_DATA_INDEX_COUNT, true);
                    FileManager.UseUOPGumps = true;
                }
                else
                {
                    path = Path.Combine(FileManager.UoFolderPath, "Gumpart.mul");
                    string pathidx = Path.Combine(FileManager.UoFolderPath, "Gumpidx.mul");

                    if (File.Exists(path) && File.Exists(pathidx))
                    {
                        _file = new UOFileMul(path, pathidx, Constants.MAX_GUMP_DATA_INDEX_COUNT, 12);
                    }
                    FileManager.UseUOPGumps = false;
                }

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

                if (!File.Exists(pathdef))
                {
                    return;
                }

                using (DefReader defReader = new DefReader(pathdef, 3))
                {
                    while (defReader.Next())
                    {
                        int ingump = defReader.ReadInt();

                        if (ingump < 0 || ingump >= Constants.MAX_GUMP_DATA_INDEX_COUNT ||
                            ingump >= _file.Entries.Length ||
                            _file.Entries[ingump].Length > 0)
                        {
                            continue;
                        }

                        int[] group = defReader.ReadGroup();

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

                            if (checkIndex < 0 || checkIndex >= Constants.MAX_GUMP_DATA_INDEX_COUNT || checkIndex >= _file.Entries.Length ||
                                _file.Entries[checkIndex].Length <= 0)
                            {
                                continue;
                            }

                            _file.Entries[ingump] = _file.Entries[checkIndex];

                            break;
                        }
                    }
                }
            }));
        }
コード例 #9
0
ファイル: GumpsLoader.cs プロジェクト: Juzzver/MobileUO
        public override Task Load()
        {
            return(Task.Run(() => {
                string path = UOFileManager.GetUOFilePath("gumpartLegacyMUL.uop");

                if (File.Exists(path))
                {
                    _file = new UOFileUop(path, "build/gumpartlegacymul/{0:D8}.tga", true);
                    Entries = new UOFileIndex[Constants.MAX_GUMP_DATA_INDEX_COUNT];
                    Client.UseUOPGumps = true;
                }
                else
                {
                    //Changed these filenames to be all lower-case as it was causing problems with File.Exists on iOS
                    //Checked a few shard installations, these files seem to be all lower-case anyways
                    path = UOFileManager.GetUOFilePath("gumpart.mul");
                    string pathidx = UOFileManager.GetUOFilePath("gumpidx.mul");

                    if (File.Exists(path) && File.Exists(pathidx))
                    {
                        _file = new UOFileMul(path, pathidx, Constants.MAX_GUMP_DATA_INDEX_COUNT, 12);
                    }
                    Client.UseUOPGumps = false;
                }
                _file.FillEntries(ref Entries);

                string pathdef = UOFileManager.GetUOFilePath("gump.def");

                if (!File.Exists(pathdef))
                {
                    return;
                }

                using (DefReader defReader = new DefReader(pathdef, 3))
                {
                    while (defReader.Next())
                    {
                        int ingump = defReader.ReadInt();

                        if (ingump < 0 || ingump >= Constants.MAX_GUMP_DATA_INDEX_COUNT ||
                            ingump >= Entries.Length ||
                            Entries[ingump].Length > 0)
                        {
                            continue;
                        }

                        int[] group = defReader.ReadGroup();

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

                            if (checkIndex < 0 || checkIndex >= Constants.MAX_GUMP_DATA_INDEX_COUNT || checkIndex >= Entries.Length ||
                                Entries[checkIndex].Length <= 0)
                            {
                                continue;
                            }

                            Entries[ingump] = Entries[checkIndex];

                            break;
                        }
                    }
                }
            }));
        }
コード例 #10
0
        //private readonly List<uint> _usedIndex = new List<uint>();


        public override void Load()
        {
            string path    = Path.Combine(FileManager.UoFolderPath, "texmaps.mul");
            string pathidx = Path.Combine(FileManager.UoFolderPath, "texidx.mul");

            if (!File.Exists(path) || !File.Exists(pathidx))
            {
                throw new FileNotFoundException();
            }
            _file = new UOFileMul(path, pathidx, Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT, 10);
            string pathdef = Path.Combine(FileManager.UoFolderPath, "TexTerr.def");

            if (!File.Exists(pathdef))
            {
                return;
            }

            using (DefReader defReader = new DefReader(pathdef, 2))
            {
                while (defReader.Next())
                {
                    int index = defReader.ReadInt();
                    if (index < 0 || index >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT)
                    {
                        continue;
                    }

                    int[] group = defReader.ReadGroup();

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

                        if (checkindex < 0 || checkindex >= Constants.MAX_LAND_TEXTURES_DATA_INDEX_COUNT)
                        {
                            continue;
                        }
                        _file.Entries[index] = _file.Entries[checkindex];
                    }
                }
            }

            //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 >= TEXTMAP_COUNT)
            //            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 >= TEXTMAP_COUNT)
            //                continue;
            //            _file.Entries[index] = _file.Entries[checkindex];
            //        }
            //    }
            //}
        }