Exemple #1
0
        public bool Hit(int weight)
        {
            if (weight < 0)
            {
                throw new ArgumentException("weight");
            }

            long now = NativeTimer.timeGetTime();

            if (current > 0)
            {
                current -= (int)((now - last) / rate);
                if (current < 0)
                {
                    current = 0;
                }
            }

            if (current > burst)
            {
                return(false);
            }

            current += weight;
            last     = now;

            return(true);
        }
Exemple #2
0
 static CallbackResult OnWalkRequestSucceed(byte[] data, CallbackResult prevResult)
 {
     if (walkQueue.Count > 0)
     {
         latencyList.Add((int)(NativeTimer.timeGetTime() - walkQueue.Dequeue()));
         UpdateLatency();
     }
     return(CallbackResult.Normal);
 }
Exemple #3
0
        static CallbackResult OnServerPing(byte[] data, CallbackResult lastResult)
        {
            if (pingQueue.Count > 0)
            {
                latencyList.Add((int)(NativeTimer.timeGetTime() - pingQueue.Dequeue()));
                UpdateLatency();
            }

            return(data[1] != 0x7F ? CallbackResult.Normal : CallbackResult.Eat);
        }
Exemple #4
0
        internal static void SendPing()
        {
            if (Core.LoggedIn)
            {
                byte[] data = new byte[2];
                data[0] = 0x73;
                data[1] = 0x7F;

                pingQueue.Enqueue(NativeTimer.timeGetTime());
                Core.SendToServer(data);
            }
        }
Exemple #5
0
 static CallbackResult OnClientPing(byte[] data, CallbackResult lastResult)
 {
     pingQueue.Enqueue(NativeTimer.timeGetTime());
     System.Diagnostics.Debug.WriteLine("Ping sent by client", "Information");
     return(CallbackResult.Normal);
 }
Exemple #6
0
 static CallbackResult OnWalkRequest(byte[] data, CallbackResult prevResult)
 {
     walkQueue.Enqueue(NativeTimer.timeGetTime());
     return(CallbackResult.Normal);
 }