Example #1
0
        public UOFontRenderer(GraphicsDevice device)
        {
            const int ATLAS_SIZE = 1024;

            _atlas = new TextureAtlas(device, ATLAS_SIZE, ATLAS_SIZE, SurfaceFormat.Color);

            const string ASCII_UO_FILE   = "fonts.mul";
            const string UNICODE_UO_FILE = "unifont{0}.mul";

            string path = UOFileManager.GetUOFilePath(ASCII_UO_FILE);

            if (File.Exists(path))
            {
                _asciiFontFile = new UOFile(path, true);

                _asciiFontCount = GetFontCount(_asciiFontFile, ASCII_CHARS_COUNT);
            }

            for (int i = 0; i < 20; ++i)
            {
                path = UOFileManager.GetUOFilePath(string.Format(UNICODE_UO_FILE, (i == 0 ? string.Empty : i.ToString())));

                if (File.Exists(path))
                {
                    _unicodeFontFiles[i] = new UOFile(path, true);
                }
            }
        }
Example #2
0
        public static 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, 0x4000, 10);

            /*string pathdef = Path.Combine(FileManager.UoFolderPath, "texterr.def");
             * if (File.Exists(pathdef))
             * {
             *  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.Replace('\t', ' ').Split(' ');
             *          if (defs.Length != 3)
             *              continue;
             *
             *          int checkindex = int.Parse(defs[1].Replace("{", string.Empty).Replace("}", string.Empty));
             *
             *
             *      }
             *  }
             * }*/
        }
Example #3
0
        private static AnimationFrame[] LoadAnimation(UOFile file)
        {
            ushort[] palette = new ushort[0x100];
            for (int i = 0; i < palette.Length; i++)
            {
                palette[i] = (ushort)(file.ReadUShort() ^ 0x8000);
            }

            int start      = file.Position;
            int frameCount = file.ReadInt();

            int[] lookups = new int[frameCount];
            for (int i = 0; i < lookups.Length; i++)
            {
                lookups[i] = start + file.ReadInt();
            }

            AnimationFrame[] frames = new AnimationFrame[frameCount];
            for (int i = 0; i < frames.Length; i++)
            {
                file.Seek(lookups[i]);
                frames[i] = new AnimationFrame(palette, file);
            }
            return(frames);
        }
Example #4
0
        public static void Load()
        {
            if (_keywords.Count > 0)
            {
                return;
            }

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

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

            _file = new UOFileMul(path);

            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;
                }

                _keywords.Add(new KeywordEntry()
                {
                    Code = id,
                    Text = Encoding.UTF8.GetString(_file.ReadArray(length))
                });
            }
        }
Example #5
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string filePath = UOFileManager.GetUOFilePath("artLegacyMUL.uop");

                if (Client.IsUOPInstallation && File.Exists(filePath))
                {
                    _file = new UOFileUop(filePath, "build/artlegacymul/{0:D8}.tga");
                    Entries = new UOFileIndex[Math.Max(((UOFileUop)_file).TotalEntriesCount, Constants.MAX_STATIC_DATA_INDEX_COUNT)];
                }
                else
                {
                    filePath = UOFileManager.GetUOFilePath("art.mul");
                    string idxPath = UOFileManager.GetUOFilePath("artidx.mul");

                    if (File.Exists(filePath) && File.Exists(idxPath))
                    {
                        _file = new UOFileMul(filePath, idxPath, Constants.MAX_STATIC_DATA_INDEX_COUNT);
                    }
                }

                _file.FillEntries(ref Entries);
                _spriteInfos = new SpriteInfo[Entries.Length];
            }
                   ));
        }
Example #6
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string filepath = UOFileManager.GetUOFilePath("artLegacyMUL.uop");

                if (File.Exists(filepath))
                {
                    _file = new UOFileUop(filepath, "build/artlegacymul/{0:D8}.tga");
                    Entries = new UOFileIndex[Constants.MAX_STATIC_DATA_INDEX_COUNT];
                }
                else
                {
                    filepath = UOFileManager.GetUOFilePath("art.mul");
                    string idxpath = UOFileManager.GetUOFilePath("artidx.mul");

                    if (File.Exists(filepath) && File.Exists(idxpath))
                    {
                        _file = new UOFileMul(filepath, idxpath, Constants.MAX_STATIC_DATA_INDEX_COUNT);
                    }
                }

                _file.FillEntries(ref Entries);
            }));
        }
Example #7
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                string uopPath = UOFileManager.GetUOFilePath("MultiCollection.uop");

                if (File.Exists(uopPath))
                {
                    Count = Constants.MAX_MULTI_DATA_INDEX_COUNT;
                    _file = new UOFileUop(uopPath, "build/multicollection/{0:D6}.bin");
                    Entries = new UOFileIndex[Count];
                    _reader = new DataReader();
                }
                else
                {
                    string path = UOFileManager.GetUOFilePath("multi.mul");
                    string pathidx = UOFileManager.GetUOFilePath("multi.idx");

                    if (File.Exists(path) && File.Exists(pathidx))
                    {
                        _file = new UOFileMul(path, pathidx, Constants.MAX_MULTI_DATA_INDEX_COUNT, 14);
                        Count = _itemOffset = UOFileManager.ClientVersion >= ClientVersions.CV_7090 ? UnsafeMemoryManager.SizeOf <MultiBlockNew>() : UnsafeMemoryManager.SizeOf <MultiBlock>();
                    }
                }

                _file.FillEntries(ref Entries);
            }));
        }
Example #8
0
        public override void FillEntries(ref UOFileIndex[] entries)
        {
            UOFile file = _idxFile ?? (UOFile)this;

            int count = (int)file.Length / 12;

            entries = new UOFileIndex[count];

            for (int i = 0; i < count; i++)
            {
                ref UOFileIndex e = ref entries[i];
                e.Address            = StartAddress;    // .mul mmf address
                e.FileSize           = (uint)Length;    // .mul mmf length
                e.Offset             = file.ReadUInt(); // .idx offset
                e.Length             = file.ReadInt();  // .idx length
                e.DecompressedLength = 0;               // UNUSED HERE --> .UOP

                int size = file.ReadInt();

                if (size > 0)
                {
                    e.Width  = (short)(size >> 16);
                    e.Height = (short)(size & 0xFFFF);
                }
            }
Example #9
0
        protected override void Load(bool loadentries = true)
        {
            base.Load(loadentries);

            if (loadentries)
            {
                UOFile file = _idxFile ?? (UOFile)this;

                int count = (int)file.Length / 12;
                Entries = new UOFileIndex3D[count];

                for (int i = 0; i < count; i++)
                {
                    Entries[i] = new UOFileIndex3D(file.ReadInt(), file.ReadInt(), 0, file.ReadInt());
                }

                //UOFileIndex5D[] patches = Verdata.Patches;

                //for (int i = 0; i < patches.Length; i++)
                //{
                //    UOFileIndex5D patch = patches[i];

                //    if (patch.FileID == _patch && patch.BlockID >= 0 && patch.BlockID < Entries.Length)
                //    {
                //        ref UOFileIndex3D entry = ref Entries[patch.BlockID];
                //        entry = new UOFileIndex3D(patch.Position, patch.Length | (1 << 31), 0, patch.GumpData);
                //    }
                //}
            }
        }
Example #10
0
        public void Load(UOFile file)
        {
            byte header = file.ReadByte();

            _chars[0] = new ASCIIChar();

            for (int i = 0; i < _chars.Length; i++)
            {
                ASCIIChar ch     = new ASCIIChar(file);
                int       height = ch.Height;
                if (i > 32 && i < 90 && height > header)
                {
                    Height = height;
                }
                _chars[i] = ch;
            }

            for (int i = 0; i < _chars.Length; i++)
            {
                _chars[i].OffsetY = Height - (_chars[i].Height + _chars[i].OffsetY);
            }

            Height -= 2;

            GetChar(' ').Width = GetChar('M').Width / 3;
        }
Example #11
0
        public UniChar(UOFile file)
        {
            OffsetX = file.ReadSByte();
            OffsetY = file.ReadSByte();
            Width   = file.ReadByte();
            Height  = file.ReadByte();

            if (Width > 0 && Height > 0)
            {
                _pixels = new uint[Width * Height];

                for (int y = 0; y < Height; y++)
                {
                    byte[] line = file.ReadArray(((Width - 1) / 8) + 1);
                    int    bitX = 7; int byteX = 0;

                    for (int x = 0; x < Width; x++)
                    {
                        uint color = (line[byteX] & (byte)Math.Pow(2, bitX)) != 0 ? 0xFFFFFFFF : 0;
                        _pixels[y * Width + x] = color;
                        bitX--;
                        if (bitX < 0)
                        {
                            bitX = 7;
                            byteX++;
                        }
                    }
                }
            }
        }
Example #12
0
        public override unsafe Task Load()
        {
            return(Task.Run(() =>
            {
                string uopPath = UOFileManager.GetUOFilePath("MultiCollection.uop");

                if (Client.IsUOPInstallation && System.IO.File.Exists(uopPath))
                {
                    Count = Constants.MAX_MULTI_DATA_INDEX_COUNT;
                    _file = new UOFileUop(uopPath, "build/multicollection/{0:D6}.bin");
                    Entries = new UOFileIndex[Count];
                    _reader = new DataReader();
                    IsUOP = true;
                }
                else
                {
                    string path = UOFileManager.GetUOFilePath("multi.mul");
                    string pathidx = UOFileManager.GetUOFilePath("multi.idx");

                    if (System.IO.File.Exists(path) && System.IO.File.Exists(pathidx))
                    {
                        _file = new UOFileMul(path, pathidx, Constants.MAX_MULTI_DATA_INDEX_COUNT, 14);
                        Count = _itemOffset = Client.Version >= ClientVersion.CV_7090 ? sizeof(MultiBlockNew) + 2 : sizeof(MultiBlock);
                    }
                }

                _file.FillEntries(ref Entries);
            }));
        }
Example #13
0
        //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 < 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;
                    }
                }
            }
        }
Example #14
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string path = UOFileManager.GetUOFilePath("Multimap.rle");

                if (File.Exists(path))
                {
                    _file = new UOFile(path, true);
                }

                for (int i = 0; i < 6; i++)
                {
                    path = UOFileManager.GetUOFilePath($"facet0{i}.mul");

                    if (File.Exists(path))
                    {
                        _facets[i] = new UOFileMul(path);
                    }
                }
            }
                   ));
        }
Example #15
0
            internal void CheckForShardMapFile(int mapID)
            {
                if (Entries == null)
                {
                    Entries = new UOFileIndex[MapLoader.MAPS_COUNT][];
                }
                string oldmap     = UOFileManager.GetUOFilePath($"map{mapID}.mul");
                string oldstaidx  = UOFileManager.GetUOFilePath($"staidx{mapID}.mul");
                string oldstatics = UOFileManager.GetUOFilePath($"statics{mapID}.mul");
                //create file names
                string mapPath     = Path.Combine(_UL.ShardName, $"map{mapID}.mul");
                string staidxPath  = Path.Combine(_UL.ShardName, $"staidx{mapID}.mul");
                string staticsPath = Path.Combine(_UL.ShardName, $"statics{mapID}.mul");

                if (!File.Exists(mapPath))
                {
                    UOFile mapfile = GetMapFile(mapID);

                    if (mapfile == null)
                    {
                        CreateNewPersistantMap(mapID, mapPath, staidxPath, staticsPath);
                    }
                    else
                    {
                        if (mapfile is UOFileUop uop)
                        {
                            Entries[mapID] = new UOFileIndex[uop.TotalEntriesCount];
                            uop.FillEntries(ref Entries[mapID]);

                            Log.Trace($"UltimaLive -> converting file:\t{mapPath} from {uop.FilePath}");

                            using (FileStream stream = File.Create(mapPath))
                            {
                                for (int x = 0; x < Entries[mapID].Length; x++)
                                {
                                    uop.Seek(Entries[mapID][x].Offset);
                                    stream.Write(uop.ReadArray(Entries[mapID][x].Length), 0, Entries[mapID][x].Length);
                                }

                                stream.Flush();
                            }
                        }
                        else
                        {
                            CopyFile(oldmap, mapPath);
                        }
                    }
                }

                if (!File.Exists(staticsPath))
                {
                    CopyFile(oldstatics, staticsPath);
                }

                if (!File.Exists(staidxPath))
                {
                    CopyFile(oldstaidx, staidxPath);
                }
            }
        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 >= Entries.Length)
                        {
                            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 >= Entries.Length)
                            {
                                continue;
                            }

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

                _spriteInfos = new SpriteInfo[Entries.Length];
            }
                   ));
        }
Example #17
0
            internal static void CheckForShardMapFile(int mapID)
            {
                string oldmap     = Path.Combine(FileManager.UoFolderPath, $"map{mapID}.mul");
                string oldstaidx  = Path.Combine(FileManager.UoFolderPath, $"staidx{mapID}.mul");
                string oldstatics = Path.Combine(FileManager.UoFolderPath, $"statics{mapID}.mul");
                //create file names
                string mapPath     = Path.Combine(_UL.ShardName, $"map{mapID}.mul");
                string staidxPath  = Path.Combine(_UL.ShardName, $"staidx{mapID}.mul");
                string staticsPath = Path.Combine(_UL.ShardName, $"statics{mapID}.mul");

                if (!File.Exists(mapPath))
                {
                    UOFile mapfile = GetMapFile(mapID);

                    if (mapfile == null)
                    {
                        CreateNewPersistantMap(mapID, mapPath, staidxPath, staticsPath);
                    }
                    else
                    {
                        if (mapfile is UOFileUop uop)
                        {
                            Log.Message(LogTypes.Trace, $"UltimaLive -> converting file:\t{mapPath} from {uop.FilePath}");

                            using (FileStream stream = File.Create(mapPath))
                            {
                                for (int x = 0; x < uop.Entries.Length; x++)
                                {
                                    uop.Seek(uop.Entries[x].Offset);
                                    stream.Write(uop.ReadArray(uop.Entries[x].Length), 0, uop.Entries[x].Length);
                                }

                                stream.Flush();
                            }
                        }
                        else
                        {
                            CopyFile(oldmap, mapPath);
                        }
                    }
                }

                if (!File.Exists(staticsPath))
                {
                    CopyFile(oldstatics, staticsPath);
                }

                if (!File.Exists(staidxPath))
                {
                    CopyFile(oldstaidx, staidxPath);
                }
            }
Example #18
0
        public void Load(UOFile file)
        {
            _file = file;

            _chars[0] = new UniChar();

            for (int i = 33; i < 128; i++)
            {
                GetChar((char)i);
            }

            GetChar(' ').Width = GetChar('M').Width / 3;
        }
Example #19
0
        public override void FillEntries(ref UOFileIndex[] entries)
        {
            UOFile file = _idxFile ?? (UOFile)this;

            int count = (int)file.Length / 12;

            entries = new UOFileIndex[count];

            for (int i = 0; i < count; i++)
            {
                entries[i] = new UOFileIndex(file.ReadInt(), file.ReadInt(), 0, file.ReadInt());
            }
        }
Example #20
0
        public static void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "gumpartLegacyMUL.uop");

            if (File.Exists(path))
            {
                _file = new UOFileUop(path, ".tga", 0x10000, 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, 0x10000, 12);
                }
            }

            string pathdef = Path.Combine(FileManager.UoFolderPath, "gump.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.Replace('\t', ' ').Split(' ');
                    if (defs.Length != 3)
                    {
                        continue;
                    }

                    int ingump  = int.Parse(defs[0]);
                    int outgump = int.Parse(defs[1].Replace("{", string.Empty).Replace("}", string.Empty));
                    int outhue  = int.Parse(defs[2]);

                    _file.Entries[ingump] = _file.Entries[outgump];
                }
            }
        }
Example #21
0
        public static void Load()
        {
            string filepath = Path.Combine(FileManager.UoFolderPath, "artLegacyMUL.uop");

            if (File.Exists(filepath))
            {
                _file = new UOFileUop(filepath, ".tga", 0x10000);
            }
            else
            {
                filepath = Path.Combine(FileManager.UoFolderPath, "art.mul");
                string idxpath = Path.Combine(FileManager.UoFolderPath, "artidx.mul");
                if (File.Exists(filepath) && File.Exists(idxpath))
                {
                    _file = new UOFileMul(filepath, idxpath, 0x10000);
                }
            }
        }
        public override void FillEntries(ref UOFileIndex[] entries)
        {
            UOFile file = _idxFile ?? (UOFile)this;

            int count = (int)file.Length / 12;

            entries = new UOFileIndex[count];

            for (int i = 0; i < count; i++)
            {
                entries[i] = new UOFileIndex(StartAddress,    // .mul mmf address
                                             (uint)Length,    // .mul mmf length
                                             file.ReadInt(),  // .idx offset
                                             file.ReadInt(),  // .idx length
                                             0,               // UNUSED HERE --> .UOP
                                             file.ReadInt()); // extra [gump]
            }
        }
Example #23
0
        public unsafe AnimationFrame(ushort[] palette, UOFile file)
        {
            int centerX = file.ReadShort();
            int centerY = file.ReadShort();
            int width   = file.ReadUShort();
            int height  = file.ReadUShort();

            if (width == 0 || height == 0)
            {
                return;
            }

            // sittings ?

            ushort[] data = new ushort[width * height];

            fixed(ushort *pdata = data)
            {
                ushort *dataRef = pdata;

                int header;

                while ((header = file.ReadInt()) != END_OF_FRAME)
                {
                    header ^= DOUBLE_XOR;

                    int x = ((header >> 22) & 0x3FF) + centerX - 0x200;
                    int y = ((header >> 12) & 0x3FF) + centerY + height - 0x200;

                    ushort *cur       = dataRef + y * width + x;
                    ushort *end       = cur + (header & 0xFFF);
                    int     filecount = 0;
                    byte[]  filedata  = file.ReadArray(header & 0xFFF);
                    while (cur < end)
                    {
                        *cur++ = palette[filedata[filecount++]];
                    }
                }
            }

            CenterX = centerX;
            CenterY = centerY;
            Data    = data;
        }
Example #24
0
        public override void Load()
        {
            string path = Path.Combine(FileManager.UoFolderPath, "Multimap.rle");

            if (File.Exists(path))
            {
                _file = new UOFile(path);
            }

            for (int i = 0; i < 6; i++)
            {
                path = Path.Combine(FileManager.UoFolderPath, $"facet0{i}.mul");

                if (File.Exists(path))
                {
                    _facets[i] = new UOFileMul(path, false);
                }
            }
        }
Example #25
0
        public override void Load()
        {
            string filepath = Path.Combine(FileManager.UoFolderPath, "artLegacyMUL.uop");

            if (File.Exists(filepath))
            {
                _file = new UOFileUop(filepath, ".tga", Constants.MAX_STATIC_DATA_INDEX_COUNT);
            }
            else
            {
                filepath = Path.Combine(FileManager.UoFolderPath, "art.mul");
                string idxpath = Path.Combine(FileManager.UoFolderPath, "artidx.mul");

                if (File.Exists(filepath) && File.Exists(idxpath))
                {
                    _file = new UOFileMul(filepath, idxpath, Constants.MAX_STATIC_DATA_INDEX_COUNT);
                }
            }
        }
        public static unsafe void Initialize()
        {
            if (_static_infos != null)
            {
                return;
            }

            _static_infos = new RawList <static_animation_info>();
            UOFile file = AnimDataLoader.Instance.AnimDataFile;

            if (file == null)
            {
                return;
            }

            long startAddr = file.StartAddress.ToInt64();
            uint lastaddr  = (uint)(startAddr + file.Length - sizeof(AnimDataFrame2));

            for (int i = 0; i < TileDataLoader.Instance.StaticData.Length; i++)
            {
                if (TileDataLoader.Instance.StaticData[i]
                    .IsAnimated)
                {
                    uint addr   = (uint)(i * 68 + 4 * (i / 8 + 1));
                    uint offset = (uint)(startAddr + addr);

                    if (offset <= lastaddr)
                    {
                        _static_infos.Add
                        (
                            new static_animation_info
                        {
                            index    = (ushort)i,
                            is_field = StaticFilters.IsField((ushort)i)
                        }
                        );
                    }
                }
            }
        }
Example #27
0
        public static void Load()
        {
            string filepath = Path.Combine(FileManager.UoFolderPath, "artLegacyMUL.uop");

            if (File.Exists(filepath))
            {
                _file = new UOFileUop(filepath, ".tga", ART_COUNT);
            }
            else
            {
                filepath = Path.Combine(FileManager.UoFolderPath, "art.mul");
                string idxpath = Path.Combine(FileManager.UoFolderPath, "artidx.mul");

                if (File.Exists(filepath) && File.Exists(idxpath))
                {
                    _file = new UOFileMul(filepath, idxpath, ART_COUNT);
                }
            }

            _artCache  = new SpriteTexture[ART_COUNT];
            _landCache = new SpriteTexture[ART_COUNT];
        }
Example #28
0
            internal unsafe void ReloadBlock(int map, int blocknum)
            {
                int    mapblocksize       = UnsafeMemoryManager.SizeOf <MapBlock>();
                int    staticidxblocksize = UnsafeMemoryManager.SizeOf <StaidxBlock>();
                int    staticblocksize    = UnsafeMemoryManager.SizeOf <StaticsBlock>();
                UOFile file = _filesMap[map];
                UOFile fileidx = _filesIdxStatics[map];
                UOFile staticfile = _filesStatics[map];
                ulong  staticidxaddress = (ulong)fileidx.StartAddress;
                ulong  endstaticidxaddress = staticidxaddress + (ulong)fileidx.Length;
                ulong  staticaddress = (ulong)staticfile.StartAddress;
                ulong  endstaticaddress = staticaddress + (ulong)staticfile.Length;
                ulong  mapddress = (ulong)file.StartAddress;
                ulong  endmapaddress = mapddress + (ulong)file.Length;
                ulong  uopoffset = 0;
                int    fileNumber = -1;
                bool   isuop = file is UOFileUop;
                ulong  realmapaddress = 0, realstaticaddress = 0;
                uint   realstaticcount = 0;
                int    block           = blocknum;

                if (isuop)
                {
                    blocknum &= 4095;
                    int shifted = block >> 12;

                    if (fileNumber != shifted)
                    {
                        fileNumber = shifted;

                        if (shifted < Entries.Length)
                        {
                            uopoffset = (ulong)Entries[map][shifted].Offset;
                        }
                    }
                }

                ulong address = mapddress + uopoffset + (ulong)(blocknum * mapblocksize);

                if (address < endmapaddress)
                {
                    realmapaddress = address;
                }
                ulong        stidxaddress = staticidxaddress + (ulong)(block * staticidxblocksize);
                StaidxBlock *bb           = (StaidxBlock *)stidxaddress;

                if (stidxaddress < endstaticidxaddress && bb->Size > 0 && bb->Position != 0xFFFFFFFF)
                {
                    ulong address1 = staticaddress + bb->Position;

                    if (address1 < endstaticaddress)
                    {
                        realstaticaddress = address1;
                        realstaticcount   = (uint)(bb->Size / staticblocksize);

                        if (realstaticcount > 1024)
                        {
                            realstaticcount = 1024;
                        }
                    }
                }

                ref var data = ref BlockData[map][block];
Example #29
0
        //private readonly List<uint> _usedIndex = new List<uint>();


        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();

                        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];
                //        }
                //    }
                //}
            }));
        }
Example #30
0
        public override Task Load()
        {
            return(Task.Run
                   (
                       () =>
            {
                string path = UOFileManager.GetUOFilePath("soundLegacyMUL.uop");

                if (Client.IsUOPInstallation && File.Exists(path))
                {
                    _file = new UOFileUop(path, "build/soundlegacymul/{0:D8}.dat");
                    Entries = new UOFileIndex[Math.Max(((UOFileUop)_file).TotalEntriesCount, 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];