Beispiel #1
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);
            }));
        }
Beispiel #2
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);
                }
            }
Beispiel #3
0
        public override bool CheckMouseSelection()
        {
            if (!(SelectedObject.Object == this || IsHousePreview || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (State != 0)
                {
                    if ((State & (CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_IGNORE_IN_RENDER | CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_PREVIEW)) != 0)
                    {
                        return(false);
                    }
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(Graphic + 0x4000);

                Point position = RealScreenPosition;
                position.X -= index.Width;
                position.Y -= index.Height;

                return(ArtLoader.Instance.PixelCheck
                       (
                           Graphic,
                           SelectedObject.TranslatedMousePositionByViewport.X - position.X,
                           SelectedObject.TranslatedMousePositionByViewport.Y - position.Y
                       ));
            }
Beispiel #4
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);
            }));
        }
Beispiel #5
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);
            }));
        }
Beispiel #6
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];
            }
                   ));
        }
        public override bool CheckMouseSelection()
        {
            if (!(SelectedObject.Object == this || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                ushort graphic = Graphic;

                bool isTree = StaticFilters.IsTree(graphic, out _);

                if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
                {
                    graphic = Constants.TREE_REPLACE_GRAPHIC;
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                Point position = RealScreenPosition;
                position.X -= index.Width;
                position.Y -= index.Height;

                return(ArtLoader.Instance.PixelCheck
                       (
                           graphic,
                           SelectedObject.TranslatedMousePositionByViewport.X - position.X,
                           SelectedObject.TranslatedMousePositionByViewport.Y - position.Y
                       ));
            }
Beispiel #8
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);
                }
            }
Beispiel #9
0
        protected static void DrawStatic(UltimaBatcher2D batcher, ushort graphic, int x, int y, ref Vector3 hue)
        {
            ArtTexture texture = ArtLoader.Instance.GetTexture(graphic);

            if (texture != null)
            {
                texture.Ticks = Time.Ticks;
                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                batcher.DrawSprite(texture, x - index.Width, y - index.Height, false, ref hue);
            }
Beispiel #10
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());
            }
        }
Beispiel #11
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));
            }
        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]
            }
        }
Beispiel #13
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));
            }
Beispiel #14
0
            public ULMapLoader(uint maps)
            {
                feedCancel      = new CancellationTokenSource();
                NumMaps         = maps;
                int[,] old      = MapsDefaultSize;
                MapsDefaultSize = new int[NumMaps, 2];
                MapBlocksSize   = new int[NumMaps, 2];
                BlockData       = new IndexMap[NumMaps][];
                Entries         = new UOFileIndex[NumMaps][];

                for (int i = 0; i < NumMaps; i++)
                {
                    for (int x = 0; x < 2; x++)
                    {
                        MapsDefaultSize[i, x] = i < old.Length ? old[i, x] : old[0, x];
                    }
                }

                _writer  = new AsyncWriterTasked(this, feedCancel);
                _twriter = Task.Run(_writer.Loop);// new Thread(_writer.Loop) {Name = "UL_File_Writer", IsBackground = true};
            }
Beispiel #15
0
        protected static void DrawStatic(UltimaBatcher2D batcher, ushort graphic, int x, int y, Vector3 hue, float depth)
        {
            var texture = ArtLoader.Instance.GetStaticTexture(graphic, out var bounds);

            if (texture != null)
            {
                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                x -= index.Width;
                y -= index.Height;

                batcher.Draw
                (
                    texture,
                    new Vector2(x, y),
                    bounds,
                    hue,
                    0f,
                    Vector2.Zero,
                    1f,
                    SpriteEffects.None,
                    depth + 0.5f
                );
            }
Beispiel #16
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            ResetHueVector();

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, 0);

            //Engine.DebugInfo.StaticsRendered++;

            //if ((StaticFilters.IsTree(Graphic) || ItemData.IsFoliage || StaticFilters.IsRock(Graphic)))
            //{
            //    batcher.DrawSpriteShadow(Texture, posX - Bounds.X, posY - Bounds.Y /*- 10*/, false);
            //}

            if (StaticFilters.IsTree(graphic, out _))
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }


            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent);

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!(SelectedObject.Object == this ||
                  FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, ref Vector3 hueVec)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            hueVec = Vector3.Zero;

            ushort hue = Hue;

            if (State != 0)
            {
                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_IGNORE_IN_RENDER) != 0)
                {
                    return(false);
                }

                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_INCORRECT_PLACE) != 0)
                {
                    hue = 0x002B;
                }

                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_TRANSPARENT) != 0)
                {
                    AlphaHue = 192;
                }
            }


            ushort graphic = Graphic;
            bool   partial = ItemData.IsPartialHue;

            Profile currentProfile = ProfileManager.CurrentProfile;

            if (currentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (currentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && currentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref hueVec, hue, partial, 0);

            //Engine.DebugInfo.MultiRendered++;

            if (IsHousePreview)
            {
                hueVec.Z = 0.5f;
            }

            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);

            if (AlphaHue != 255)
            {
                hueVec.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated
            (
                batcher,
                graphic,
                posX,
                posY,
                ref hueVec,
                ref DrawTransparent,
                false
            );

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!(SelectedObject.Object == this || IsHousePreview || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (State != 0)
                {
                    if ((State & (CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_IGNORE_IN_RENDER | CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_PREVIEW)) != 0)
                    {
                        return(true);
                    }
                }

                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (ArtLoader.Instance.PixelCheck
                    (
                        graphic,
                        SelectedObject.TranslatedMousePositionByViewport.X - posX,
                        SelectedObject.TranslatedMousePositionByViewport.Y - posY
                    ))
                {
                    SelectedObject.Object = this;
                }
            }
Beispiel #18
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, ref Vector3 hueVec)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            hueVec = Vector3.Zero;

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref hueVec, hue, partial, 0);

            bool isTree = StaticFilters.IsTree(graphic, out _);

            if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
            {
                graphic = Constants.TREE_REPLACE_GRAPHIC;
            }

            if (AlphaHue != 255)
            {
                hueVec.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated
            (
                batcher,
                graphic,
                posX,
                posY,
                ref hueVec,
                ref DrawTransparent,
                ProfileManager.CurrentProfile.ShadowsEnabled && ProfileManager.CurrentProfile.ShadowsStatics && (isTree || ItemData.IsFoliage || StaticFilters.IsRock(graphic))
            );

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!(SelectedObject.Object == this || FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (ArtLoader.Instance.PixelCheck
                    (
                        graphic,
                        SelectedObject.TranslatedMousePositionByViewport.X - posX,
                        SelectedObject.TranslatedMousePositionByViewport.Y - posY
                    ))
                {
                    SelectedObject.Object = this;
                }
            }
Beispiel #19
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];
Beispiel #20
0
        public override unsafe Task Load()
        {
            return(Task.Run(() =>
            {
                bool foundOneMap = false;

                for (int i = 0; i < Constants.MAPS_COUNT; i++)
                {
                    string path = UOFileManager.GetUOFilePath($"map{i}LegacyMUL.uop");

                    if (Client.IsUOPInstallation && File.Exists(path))
                    {
                        _filesMap[i] = new UOFileUop(path, $"build/map{i}legacymul/{{0:D8}}.dat");
                        Entries[i] = new UOFileIndex[((UOFileUop)_filesMap[i]).TotalEntriesCount];
                        ((UOFileUop)_filesMap[i]).FillEntries(ref Entries[i], false);
                        foundOneMap = true;
                    }
                    else
                    {
                        path = UOFileManager.GetUOFilePath($"map{i}.mul");

                        if (File.Exists(path))
                        {
                            _filesMap[i] = new UOFileMul(path);

                            foundOneMap = true;
                        }

                        path = UOFileManager.GetUOFilePath($"mapdifl{i}.mul");

                        if (File.Exists(path))
                        {
                            _mapDifl[i] = new UOFileMul(path);
                            _mapDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"mapdif{i}.mul"));
                            _staDifl[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifl{i}.mul"));
                            _staDifi[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifi{i}.mul"));
                            _staDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadif{i}.mul"));
                        }
                    }

                    path = UOFileManager.GetUOFilePath($"statics{i}.mul");
                    if (File.Exists(path))
                    {
                        _filesStatics[i] = new UOFileMul(path);
                    }
                    path = UOFileManager.GetUOFilePath($"staidx{i}.mul");
                    if (File.Exists(path))
                    {
                        _filesIdxStatics[i] = new UOFileMul(path);
                    }
                }

                if (!foundOneMap)
                {
                    throw new FileNotFoundException("No maps found.");
                }

                int mapblocksize = sizeof(MapBlock);

                if (_filesMap[0].Length / mapblocksize == 393216 || Client.Version < ClientVersion.CV_4011D)
                {
                    MapsDefaultSize[0, 0] = MapsDefaultSize[1, 0] = 6144;
                }

                // This is an hack to patch correctly all maps when you have to fake map1
                if (_filesMap[1] == null || _filesMap[1].StartAddress == IntPtr.Zero)
                {
                    _filesMap[1] = _filesMap[0];
                    _filesStatics[1] = _filesStatics[0];
                    _filesIdxStatics[1] = _filesIdxStatics[0];
                }

                //for (int i = 0; i < MAPS_COUNT; i++)
                Parallel.For(0, Constants.MAPS_COUNT, i =>
                {
                    MapBlocksSize[i, 0] = MapsDefaultSize[i, 0] >> 3;
                    MapBlocksSize[i, 1] = MapsDefaultSize[i, 1] >> 3;
                    LoadMap(i);
                });

                Entries = null;
            }));
        }
Beispiel #21
0
        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;
                        }
                    }
                }
            }));
        }
Beispiel #22
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[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;
                        }
                    }
                }
            }));
        }
Beispiel #23
0
        public override Task Load()
        {
            return(Task.Run(() =>
            {
                bool foundOneMap = false;

                for (int i = 0; i < MAPS_COUNT; i++)
                {
                    string path = UOFileManager.GetUOFilePath($"map{i}LegacyMUL.uop");

                    if (File.Exists(path))
                    {
                        _filesMap[i] = new UOFileUop(path, $"build/map{i}legacymul/{{0:D8}}.dat");
                        Entries[i] = new UOFileIndex[((UOFileUop)_filesMap[i]).TotalEntriesCount];
                        ((UOFileUop)_filesMap[i]).FillEntries(ref Entries[i], false);
                        foundOneMap = true;
                    }
                    else
                    {
                        path = UOFileManager.GetUOFilePath($"map{i}.mul");

                        if (File.Exists(path))
                        {
                            _filesMap[i] = new UOFileMul(path);

                            foundOneMap = true;
                        }

                        path = UOFileManager.GetUOFilePath($"mapdifl{i}.mul");

                        if (File.Exists(path))
                        {
                            _mapDifl[i] = new UOFileMul(path);
                            _mapDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"mapdif{i}.mul"));
                            _staDifl[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifl{i}.mul"));
                            _staDifi[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadifi{i}.mul"));
                            _staDif[i] = new UOFileMul(UOFileManager.GetUOFilePath($"stadif{i}.mul"));
                        }
                    }

                    path = UOFileManager.GetUOFilePath($"statics{i}.mul");
                    if (File.Exists(path))
                    {
                        _filesStatics[i] = new UOFileMul(path);
                    }
                    path = UOFileManager.GetUOFilePath($"staidx{i}.mul");
                    if (File.Exists(path))
                    {
                        _filesIdxStatics[i] = new UOFileMul(path);
                    }
                }

                if (!foundOneMap)
                {
                    throw new FileNotFoundException("No maps found.");
                }

                int mapblocksize = UnsafeMemoryManager.SizeOf <MapBlock>();

                if (_filesMap[0].Length / mapblocksize == 393216 || Client.Version < ClientVersion.CV_4011D)
                {
                    MapsDefaultSize[0, 0] = MapsDefaultSize[1, 0] = 6144;
                }

                //for (int i = 0; i < MAPS_COUNT; i++)
                Parallel.For(0, MAPS_COUNT, i =>
                {
                    MapBlocksSize[i, 0] = MapsDefaultSize[i, 0] >> 3;
                    MapBlocksSize[i, 1] = MapsDefaultSize[i, 1] >> 3;
                    LoadMap(i);
                });

                Entries = null;
            }));
        }
Beispiel #24
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ushort graphic = Graphic;
            ushort hue     = Hue;
            bool   partial = ItemData.IsPartialHue;

            ResetHueVector();

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, 0);

            // ## BEGIN - END ## //
            if (ProfileManager.CurrentProfile.HighlightTileAtRange && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRange)
            {
                HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHue;
                HueVector.Y = 1;
            }
            if (ProfileManager.CurrentProfile.HighlightTileAtRangeSpell)
            {
                if (GameCursor._spellTime >= 1 && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRangeSpell)
                {
                    HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHueSpell;
                    HueVector.Y = 1;
                }
            }
            if (ProfileManager.CurrentProfile.PreviewFields)
            {
                if (UOClassicCombatCollection.StaticFieldPreview(this))
                {
                    HueVector.X = 0x0040;
                    HueVector.Y = 1;
                }
                if (SelectedObject.LastObject == this)
                {
                    HueVector.X = 0x0023;
                    HueVector.Y = 1;
                }
            }
            // ## BEGIN - END ## //
            // ## BEGIN - END ## // ORIG

            /*
             * bool isTree = StaticFilters.IsTree(graphic, out _);
             *
             * if (isTree && ProfileManager.CurrentProfile.TreeToStumps)
             * {
             *  graphic = Constants.TREE_REPLACE_GRAPHIC;
             * }
             */
            // ## BEGIN - END ## // ORIG
            graphic = UOClassicCombatCollection.ArtloaderFilters(graphic);

            bool isTree = StaticFilters.IsTree(graphic, out _);

            // ## BEGIN - END ## //

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent, ProfileManager.CurrentProfile.ShadowsEnabled && ProfileManager.CurrentProfile.ShadowsStatics && (isTree || ItemData.IsFoliage || StaticFilters.IsRock(graphic)));

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!(SelectedObject.Object == this ||
                  FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
Beispiel #25
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            //Engine.DebugInfo.ItemsRendered++;

            ResetHueVector();
            DrawTransparent = false;

            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);

            if (ItemData.IsTranslucent)
            {
                HueVector.Z = 0.5f;
            }

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            if (IsCorpse)
            {
                return(DrawCorpse(batcher, posX, posY - 3));
            }


            ushort hue     = Hue;
            ushort graphic = DisplayedGraphic;
            bool   partial = ItemData.IsPartialHue;

            if (OnGround)
            {
                if (ItemData.IsAnimated)
                {
                    if (ProfileManager.CurrentProfile.FieldsType == 2)
                    {
                        if (StaticFilters.IsFireField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0020;
                        }
                        else if (StaticFilters.IsParalyzeField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0058;
                        }
                        else if (StaticFilters.IsEnergyField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0070;
                        }
                        else if (StaticFilters.IsPoisonField(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x0044;
                        }
                        else if (StaticFilters.IsWallOfStone(Graphic))
                        {
                            graphic = Constants.FIELD_REPLACE_GRAPHIC;
                            hue     = 0x038A;
                        }
                    }
                }

                if (ItemData.IsContainer && SelectedObject.SelectedContainer == this)
                {
                    hue     = 0x0035;
                    partial = false;
                }
            }

            if (ProfileManager.CurrentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue = Constants.OUT_RANGE_COLOR;
            }
            else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
            {
                hue = Constants.DEAD_RANGE_COLOR;
            }
            else
            {
                if (!IsLocked && !IsMulti && SelectedObject.LastObject == this)
                {
                    // TODO: check why i put this.
                    //isPartial = ItemData.Weight == 0xFF;
                    hue = 0x0035;
                }
                else if (IsHidden)
                {
                    hue = 0x038E;
                }
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, HueVector.Z);

            if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable)
            {
                DrawStaticAnimated(batcher, graphic, posX - 5, posY - 5, ref HueVector, ref DrawTransparent);
            }

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                HueVector.Z = 0.5f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent);

            if (SelectedObject.Object == this || TargetManager.TargetingState == CursorTarget.MultiPlacement)
            {
                return(false);
            }

            ArtTexture texture = ArtLoader.Instance.GetTexture(graphic);

            if (texture != null)
            {
                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(texture, posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }
Beispiel #26
0
        public override bool Draw(UltimaBatcher2D batcher, int posX, int posY)
        {
            if (!AllowedToDraw || IsDestroyed)
            {
                return(false);
            }

            ResetHueVector();

            ushort hue = Hue;

            if (State != 0)
            {
                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_IGNORE_IN_RENDER) != 0)
                {
                    return(false);
                }

                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_INCORRECT_PLACE) != 0)
                {
                    hue = 0x002B;
                }

                if ((State & CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_TRANSPARENT) != 0)
                {
                    if (AlphaHue >= 192)
                    {
                        AlphaHue = 0xFF;
                    }
                    else
                    {
                        ProcessAlpha(192);
                    }
                }
            }

            ResetHueVector();

            ushort graphic = Graphic;
            bool   partial = ItemData.IsPartialHue;

            Profile currentProfile = ProfileManager.CurrentProfile;

            if (currentProfile.HighlightGameObjects && SelectedObject.LastObject == this)
            {
                hue     = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                partial = false;
            }
            else if (currentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange)
            {
                hue     = Constants.OUT_RANGE_COLOR;
                partial = false;
            }
            else if (World.Player.IsDead && currentProfile.EnableBlackWhiteEffect)
            {
                hue     = Constants.DEAD_RANGE_COLOR;
                partial = false;
            }

            ShaderHueTranslator.GetHueVector(ref HueVector, hue, partial, 0);

            //Engine.DebugInfo.MultiRendered++;

            // ## BEGIN - END ## //
            if (ProfileManager.CurrentProfile.HighlightTileAtRange && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRange)
            {
                HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHue;
                HueVector.Y = 1;
            }
            if (ProfileManager.CurrentProfile.HighlightTileAtRangeSpell)
            {
                if (GameCursor._spellTime >= 1 && Distance == ProfileManager.CurrentProfile.HighlightTileAtRangeRangeSpell)
                {
                    HueVector.X = ProfileManager.CurrentProfile.HighlightTileRangeHueSpell;
                    HueVector.Y = 1;
                }
            }
            if (ProfileManager.CurrentProfile.PreviewFields)
            {
                if (UOClassicCombatCollection.MultiFieldPreview(this))
                {
                    HueVector.X = 0x0040;
                    HueVector.Y = 1;
                }
                if (SelectedObject.LastObject == this)
                {
                    HueVector.X = 0x0023;
                    HueVector.Y = 1;
                }
            }
            // ## BEGIN - END ## //

            if (IsHousePreview)
            {
                HueVector.Z = 0.5f;
            }

            posX += (int)Offset.X;
            posY += (int)(Offset.Y + Offset.Z);

            if (AlphaHue != 255)
            {
                HueVector.Z = 1f - AlphaHue / 255f;
            }

            DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent, false);

            if (ItemData.IsLight)
            {
                Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22);
            }

            if (!(SelectedObject.Object == this || IsHousePreview ||
                  FoliageIndex != -1 && Client.Game.GetScene <GameScene>().FoliageIndex == FoliageIndex))
            {
                if (State != 0)
                {
                    if ((State & (CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_IGNORE_IN_RENDER |
                                  CUSTOM_HOUSE_MULTI_OBJECT_FLAGS.CHMOF_PREVIEW)) != 0)
                    {
                        return(true);
                    }
                }

                if (DrawTransparent)
                {
                    return(true);
                }

                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                posX -= index.Width;
                posY -= index.Height;

                if (SelectedObject.IsPointInStatic(ArtLoader.Instance.GetTexture(graphic), posX, posY))
                {
                    SelectedObject.Object = this;
                }
            }