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); }
static CallbackResult OnWalkRequestSucceed(byte[] data, CallbackResult prevResult) { if (walkQueue.Count > 0) { latencyList.Add((int)(NativeTimer.timeGetTime() - walkQueue.Dequeue())); UpdateLatency(); } return(CallbackResult.Normal); }
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); }
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); } }
static CallbackResult OnClientPing(byte[] data, CallbackResult lastResult) { pingQueue.Enqueue(NativeTimer.timeGetTime()); System.Diagnostics.Debug.WriteLine("Ping sent by client", "Information"); return(CallbackResult.Normal); }
static CallbackResult OnWalkRequest(byte[] data, CallbackResult prevResult) { walkQueue.Enqueue(NativeTimer.timeGetTime()); return(CallbackResult.Normal); }