Exemple #1
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));
                }
            }
        }
Exemple #2
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string path = UOFileManager.GetUOFilePath("hues.mul");

                FileSystemHelper.EnsureFileExists(path);

                UOFileMul file = new UOFileMul(path);
                int groupSize = Marshal.SizeOf <HuesGroup>();
                int entrycount = (int)file.Length / groupSize;
                HuesCount = entrycount * 8;
                HuesRange = new HuesGroup[entrycount];
                ulong addr = (ulong)file.StartAddress;

                for (int i = 0; i < entrycount; i++)
                {
                    HuesRange[i] = Marshal.PtrToStructure <HuesGroup>((IntPtr)(addr + (ulong)(i * groupSize)));
                }

                path = UOFileManager.GetUOFilePath("radarcol.mul");

                FileSystemHelper.EnsureFileExists(path);

                UOFileMul radarcol = new UOFileMul(path);
                RadarCol = radarcol.ReadArray <ushort>((int)radarcol.Length >> 1);
                file.Dispose();
                radarcol.Dispose();
            }
                   ));
        }
Exemple #3
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();
                 * }*/
            }
        }
Exemple #4
0
        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "hues.mul");

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

            UOFileMul file       = new UOFileMul(path, false);
            int       groupSize  = Marshal.SizeOf <HuesGroup>();
            int       entrycount = (int)file.Length / groupSize;

            HuesCount = entrycount * 8;
            HuesRange = new HuesGroup[entrycount];
            ulong addr = (ulong)file.StartAddress;

            for (int i = 0; i < entrycount; i++)
            {
                HuesRange[i] = Marshal.PtrToStructure <HuesGroup>((IntPtr)(addr + (ulong)(i * groupSize)));
            }

            path = Path.Combine(FileManager.UoFolderPath, "radarcol.mul");

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

            UOFileMul radarcol = new UOFileMul(path, false);

            RadarCol = radarcol.ReadArray <ushort>((int)radarcol.Length >> 1);
            file.Dispose();
            radarcol.Dispose();
        }
Exemple #5
0
        public static void Load()
        {
            if (_speeches.Count > 0)
            {
                return;
            }
            string path = Path.Combine(FileManager.UoFolderPath, "speech.mul");

            if (!File.Exists(path))
            {
                throw new FileNotFoundException();
            }
            UOFileMul file = new UOFileMul(path);
            Dictionary <int, List <Regex> > table = null;
            int lastIndex = -1;

            while (file.Position < file.Length)
            {
                ushort id     = (ushort)((file.ReadByte() << 8) | file.ReadByte());
                ushort length = (ushort)((file.ReadByte() << 8) | file.ReadByte());

                if (length > 128)
                {
                    length = 128;
                }
                string text = Encoding.UTF8.GetString(file.ReadArray <byte>(length)).Trim();

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

                if (table == null || lastIndex > id)
                {
                    if (id == 0 && text == "*withdraw*")
                    {
                        _speeches.Insert(0, table = new Dictionary <int, List <Regex> >());
                    }
                    else
                    {
                        _speeches.Add(table = new Dictionary <int, List <Regex> >());
                    }
                }

                lastIndex = id;
                table.TryGetValue(id, out List <Regex> regex);

                if (regex == null)
                {
                    table[id] = regex = new List <Regex>();
                }
                regex.Add(new Regex(text.Replace("*", @".*"), RegexOptions.IgnoreCase));

                //_keywords.Add(new KeywordEntry
                //    {Code = id, Text = Encoding.UTF8.GetString(_file.ReadArray<byte>(length)).Trim()});
            }

            file.Unload();
        }
Exemple #6
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                if (SkillsCount > 0)
                {
                    return;
                }

                string path = UOFileManager.GetUOFilePath("skills.mul");
                string pathidx = UOFileManager.GetUOFilePath("Skills.idx");

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

                _file = new UOFileMul(path, pathidx, 0, 16);
                _file.FillEntries(ref Entries);

                for (int i = 0, count = 0; i < Entries.Length; i++)
                {
                    ref UOFileIndex entry = ref GetValidRefEntry(i);

                    if (entry.Length > 0)
                    {
                        _file.SetData(entry.Address, entry.FileSize);
                        _file.Seek(entry.Offset);
                        bool hasAction = _file.ReadBool();

                        string name = Encoding.UTF8.GetString(_file.ReadArray <byte>(entry.Length - 1)).TrimEnd('\0');

                        /*
                         * if(skillUseless.Contains(name))  // giga487, UoMars
                         * {
                         *  continue;  // se carico le skill che ho messo dentro il vettore string skillUseless vado avanti.
                         * }
                         */

                        SkillEntry skill = new SkillEntry(count++, name, hasAction);
                        Skills.Add(skill);
                    }
                }

                SortedSkills.AddRange(Skills);
                SortedSkills.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.InvariantCulture));
            }
Exemple #7
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                if (SkillsCount > 0)
                {
                    return;
                }

                string path = UOFileManager.GetUOFilePath("skills.mul");
                string pathidx = UOFileManager.GetUOFilePath("Skills.idx");

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

                _file = new UOFileMul(path, pathidx, 0, 16);
                _file.FillEntries(ref Entries);

                for (int i = 0, count = 0; i < Entries.Length; i++)
                {
                    ref UOFileIndex entry = ref GetValidRefEntry(i);

                    if (entry.Length > 0)
                    {
                        _file.Seek(entry.Offset);
                        bool hasAction = _file.ReadBool();

                        string name = Encoding.UTF8.GetString
                                          (_file.ReadArray <byte>(entry.Length - 1))
                                      .TrimEnd('\0');

                        SkillEntry skill = new SkillEntry(count++, name, hasAction);

                        Skills.Add(skill);
                    }
                }

                SortedSkills.AddRange(Skills);
                SortedSkills.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.InvariantCulture));
            }
Exemple #8
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];
                }
            }
        }