示例#1
0
        protected override void OnTick()
        {
            base.OnTick();

            if (Callback != null && (IgnoreWorldIO || (!World.Loading && !World.Saving)))
            {
                if (Condition != null)
                {
                    if (VitaNexCore.TryCatchGet(Condition, VitaNexCore.ToConsole))
                    {
                        VitaNexCore.TryCatch(Callback, VitaNexCore.ToConsole);
                    }
                }
                else
                {
                    VitaNexCore.TryCatch(Callback, VitaNexCore.ToConsole);
                }
            }

            if (Interval <= TimeSpan.Zero)
            {
                Running = false;
            }
            else
            {
                var p = ResolvePriority();

                if (Priority != p)
                {
                    Priority = p;
                }
            }
        }
示例#2
0
        public ClilocInfo Lookup(FileInfo file, bool forceUpdate = false)
        {
            if (Info != null && !forceUpdate)
            {
                return(Info);
            }

            VitaNexCore.TryCatch(() => file.Deserialize(reader => Lookup(reader)), Clilocs.CSOptions.ToConsole);
            return(Info);
        }
        public bool RewriteID(bool multi, ref byte[] buffer, int offset)
        {
            if (buffer == null || offset >= buffer.Length)
            {
                return(false);
            }

            var b       = buffer;
            var success = false;

            VitaNexCore.TryCatch(
                () =>
            {
                var v  = b.Length == 23 ? 0 : b.Length == 24 ? 1 : b.Length == 26 ? 2 : -1;
                var id = LowItemID;

                switch (v)
                {
                case 0:                                 //Old
                    {
                        id &= 0x3FFF;

                        if (multi)
                        {
                            id |= 0x4000;
                        }

                        BitConverter.GetBytes((short)id).CopyTo(b, offset);
                        success = true;
                    }
                    break;

                case 1:                                 //SA
                    {
                        id &= multi ? 0x3FFF : 0x7FFF;
                        BitConverter.GetBytes((short)id).CopyTo(b, offset);
                        success = true;
                    }
                    break;

                case 2:                                 //HS
                    {
                        id &= multi ? 0x3FFF : 0xFFFF;
                        BitConverter.GetBytes((ushort)id).CopyTo(b, offset);
                        success = true;
                    }
                    break;
                }
            },
                ArtworkSupport.CSOptions.ToConsole);

            return(success);
        }
示例#4
0
文件: Table.cs 项目: uotools/JustUO
        public void Load(FileInfo file)
        {
            if (Loaded)
            {
                return;
            }

            VitaNexCore.TryCatch(
                () =>
            {
                ClilocLNG lng;

                if (!Enum.TryParse(file.Extension.TrimStart('.'), true, out lng))
                {
                    throw new FileLoadException("Could not detect language for: " + file.FullName);
                }

                Language  = lng;
                InputFile = file;

                InputFile.Deserialize(
                    reader =>
                {
                    long size = reader.Seek(0, SeekOrigin.End);
                    reader.Seek(0, SeekOrigin.Begin);

                    reader.ReadInt();
                    reader.ReadShort();

                    while (reader.Seek(0, SeekOrigin.Current) < size)
                    {
                        int index = reader.ReadInt();
                        reader.ReadByte();
                        int length  = reader.ReadShort();
                        long offset = reader.Seek(0, SeekOrigin.Current);
                        reader.Seek(length, SeekOrigin.Current);

                        if (_Table.ContainsKey(index))
                        {
                            _Table[index] = new ClilocData(Language, index, offset, length);
                        }
                        else
                        {
                            _Table.Add(index, new ClilocData(Language, index, offset, length));
                        }
                    }
                });

                Loaded = true;
            },
                Clilocs.CSOptions.ToConsole);
        }
        public bool RewriteID(bool multi, Packet p, int offset)
        {
            if (p == null || offset >= p.UnderlyingStream.Length)
            {
                return(false);
            }

            var success = false;

            VitaNexCore.TryCatch(
                () =>
            {
                var v  = p is WorldItem ? 0 : p is WorldItemSA ? 1 : p is WorldItemHS ? 2 : -1;
                var id = LowItemID;

                switch (v)
                {
                case 0:                                 //Old
                    {
                        id &= 0x3FFF;

                        if (multi)
                        {
                            id |= 0x4000;
                        }

                        success = p.Rewrite(offset, (short)id);
                    }
                    break;

                case 1:                                 //SA
                    {
                        id     &= multi ? 0x3FFF : 0x7FFF;
                        success = p.Rewrite(offset, (short)id);
                    }
                    break;

                case 2:                                 //HS
                    {
                        id     &= multi ? 0x3FFF : 0xFFFF;
                        success = p.Rewrite(offset, (ushort)id);
                    }
                    break;

                default:
                    return;
                }
            },
                ArtworkSupport.CSOptions.ToConsole);

            return(success);
        }
示例#6
0
文件: Table.cs 项目: uotools/JustUO
 public void LookupAll()
 {
     VitaNexCore.TryCatch(
         () => InputFile.Deserialize(
             reader =>
     {
         foreach (ClilocData d in _Table.Values)
         {
             d.Lookup(reader as BinaryFileReader);
         }
     }),
         Clilocs.CSOptions.ToConsole);
 }
示例#7
0
        private unsafe void SetPixel(int x, int y, BitmapData data, ParallelLoopState state)
        {
            if (IsDisposed)
            {
                VitaNexCore.TryCatch(state.Stop);
                return;
            }

            var index = (y * data.Stride) + (x * 2);
            var pixel = (byte *)data.Scan0.ToPointer();

            pixel[index + 0] = (PixelColor >> 0) & 0xFF;
            pixel[index + 1] = (PixelColor >> 8) & 0xFF;
        }
示例#8
0
        public void RewriteID(NetState state, bool multi, Packet p, int offset)
        {
            if (state == null || p == null || offset >= p.UnderlyingStream.Length || state.Version >= Version)
            {
                return;
            }

            VitaNexCore.TryCatch(
                () =>
            {
                int v  = p is WorldItem ? 0 : p is WorldItemSA ? 1 : p is WorldItemHS ? 2 : -1;
                int id = ItemID.Right;

                switch (v)
                {
                case 0:                                 //Old
                    {
                        id &= 0x3FFF;

                        if (multi)
                        {
                            id |= 0x4000;
                        }
                    }
                    break;

                case 1:                                 //SA
                    {
                        id &= multi ? 0x3FFF : 0x7FFF;
                    }
                    break;

                case 2:                                 //HS
                    {
                        id &= multi ? 0x3FFF : 0xFFFF;
                    }
                    break;

                default:
                    return;
                }

                p.Rewrite(offset, (short)id);
            },
                ArtworkSupport.CSOptions.ToConsole);
        }
示例#9
0
        private static void ExportCommand(CommandEventArgs e)
        {
            if (e.Mobile == null || e.Mobile.Deleted)
            {
                return;
            }

            e.Mobile.SendMessage(0x55, "Export requested...");

            if (e.Arguments == null || e.Arguments.Length == 0 || String.IsNullOrWhiteSpace(e.Arguments[0]))
            {
                e.Mobile.SendMessage("Usage: {0}{1} <{2}>", CommandSystem.Prefix, e.Command, String.Join(" | ", _Languages));
                return;
            }

            ClilocLNG lng;

            if (Enum.TryParse(e.Arguments[0], true, out lng) && lng != ClilocLNG.NULL)
            {
                VitaNexCore.TryCatch(
                    () =>
                {
                    var file = Export(lng);

                    if (file != null && file.Exists && file.Length > 0)
                    {
                        e.Mobile.SendMessage(0x55, "{0} clilocs have been exported to: {1}", lng, file.FullName);
                    }
                    else
                    {
                        e.Mobile.SendMessage(0x22, "Could not export clilocs for {0}", lng);
                    }
                },
                    ex =>
                {
                    e.Mobile.SendMessage(0x22, "A fatal exception occurred, check the console for details.");
                    CSOptions.ToConsole(ex);
                });
            }
            else
            {
                e.Mobile.SendMessage("Usage: {0}{1} <{2}>", CommandSystem.Prefix, e.Command, String.Join(" | ", _Languages));
            }
        }
示例#10
0
        private void Compute(Rectangle3D area, ParallelLoopState state)
        {
            if (IsDisposed)
            {
                VitaNexCore.TryCatch(state.Stop);
                return;
            }

            // Check all corners to skip large bodies of water.
            if (Filters.Contains(TileFlag.Wet))
            {
                var land1 = Facet.Tiles.GetLandTile(area.Start.X, area.Start.Y);             // TL
                var land2 = Facet.Tiles.GetLandTile(area.End.X, area.Start.Y);               // TR
                var land3 = Facet.Tiles.GetLandTile(area.Start.X, area.End.Y);               // BL
                var land4 = Facet.Tiles.GetLandTile(area.End.X, area.End.Y);                 // BR

                if ((land1.Ignored || TileData.LandTable[land1.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land2.Ignored || TileData.LandTable[land2.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land3.Ignored || TileData.LandTable[land3.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land4.Ignored || TileData.LandTable[land4.ID].Flags.HasFlag(TileFlag.Wet)))
                {
                    return;
                }
            }

            int x, y, z, h;

            LandTile land;
            TileFlag flags;
            bool     valid;

            for (x = area.Start.X; !IsDisposed && x < area.End.X; x++)
            {
                for (y = area.Start.Y; !IsDisposed && y < area.End.Y; y++)
                {
                    h = GetHashCode(x, y);

                    if (_Points.ContainsKey(h))
                    {
                        continue;
                    }

                    land = Facet.Tiles.GetLandTile(x, y);

                    if (land.Ignored)
                    {
                        continue;
                    }

                    z = land.Z;

                    if (!CanSpawn(x, y, z))
                    {
                        continue;
                    }

                    if (Filters.Length > 0)
                    {
                        flags = TileData.LandTable[land.ID].Flags;

                        if (Filters.Any(f => flags.HasFlag(f)))
                        {
                            continue;
                        }

                        valid = true;

                        foreach (var tile in Facet.Tiles.GetStaticTiles(x, y))
                        {
                            flags = TileData.ItemTable[tile.ID].Flags;

                            if (Filters.Any(f => flags.HasFlag(f)))
                            {
                                valid = false;
                                break;
                            }
                        }

                        if (!valid)
                        {
                            continue;
                        }
                    }

                    if (Validator != null)
                    {
                        lock (Validator)
                        {
                            if (!Validator(Facet, x, y, z))
                            {
                                continue;
                            }
                        }
                    }

                    if (IsDisposed)
                    {
                        break;
                    }

                    lock (_Points)
                    {
                        _Points[h] = new Point3D(x, y, z);
                    }
                }
            }
        }