예제 #1
0
        public void RewriteID(NetState state, bool multi, ref byte[] buffer, int offset)
        {
            if (state == null || buffer == null || offset >= buffer.Length || state.Version >= Version)
            {
                return;
            }

            var b = buffer;

            buffer = VitaNexCore.TryCatchGet(
                () =>
            {
                int v  = b.Length == 23 ? 0 : b.Length == 24 ? 1 : b.Length == 26 ? 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(b);
                }

                BitConverter.GetBytes((short)id).CopyTo(b, offset);

                return(b);
            },
                ArtworkSupport.CSOptions.ToConsole);
        }
예제 #2
0
        public static ClilocInfo Lookup(this ClilocLNG lng, Type t)
        {
            if (lng == ClilocLNG.NULL)
            {
                lng = DefaultLanguage;
            }

            int index;

            if (_TypeCache.TryGetValue(t, out index))
            {
                return(Lookup(lng, index));
            }

            return(VitaNexCore.TryCatchGet(
                       () =>
            {
                if (t == null)
                {
                    return null;
                }

                if (!_LabelNumberProp.IsSupported(t, typeof(int)))
                {
                    return null;
                }

                var o = t.CreateInstanceSafe <object>();

                if (o == null)
                {
                    return null;
                }

                index = (int)_LabelNumberProp.GetValue(o, -1);                         // LabelNumber_get()

                var m = t.GetMethod("Delete");

                if (m != null)
                {
                    m.Invoke(o, new object[0]);                             // Delete_call()
                }

                _TypeCache.Add(t, index);

                return Lookup(lng, index);
            }));
        }
예제 #3
0
        public static ClilocInfo Lookup(this ClilocLNG lng, Type t)
        {
            if (lng == ClilocLNG.NULL)
            {
                lng = DefaultLanguage;
            }

            return(VitaNexCore.TryCatchGet(
                       () =>
            {
                if (t == null)
                {
                    return null;
                }

                PropertyInfo p = t.GetProperty("LabelNumber");

                if (p == null || !p.CanRead)
                {
                    return null;
                }

                object o = t.CreateInstanceSafe <object>();

                if (o == null)
                {
                    return null;
                }

                var index = (int)p.GetValue(o, null);                         // LabelNumber_get()

                MethodInfo m = t.GetMethod("Delete");

                if (m != null)
                {
                    m.Invoke(o, new object[0]);                             // Delete_call()
                }

                return Lookup(lng, index);
            }));
        }
예제 #4
0
파일: PollTimer.cs 프로젝트: uotools/JustUO
        protected override void OnTick()
        {
            base.OnTick();

            if (Callback != null && (IgnoreWorld || (!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;
            }
        }