private void PingFilterTimer_Tick(object sender, EventArgs e) { double sumPing = 0; int n = 0; bool absPingRespected = true; foreach (Player p in Player.ActivePlayers()) { if (p.Ping != -1) { absPingRespected &= p.Ping < Settings.Default.MaxAbsPing; sumPing += p.Ping; n++; } } if (n == 0) { // Wait until at least one player has a ping pingFilterTimer.Interval = TimeSpan.FromSeconds(0.5); return; } if ((!absPingRespected || sumPing / n > Settings.Default.MaxAvgPing) && !DS3Interop.InLoadingScreen()) { var joinMethod = DS3Interop.GetJoinMethod(); DS3Interop.LeaveSession(); if (joinMethod == DS3Interop.JoinMethod.RedEyeOrb) { hadInvaded = true; } else if (joinMethod == DS3Interop.JoinMethod.RedSign) { DS3Interop.ApplyEffect(10); } else if (joinMethod == DS3Interop.JoinMethod.WhiteSign) { DS3Interop.ApplyEffect(4); } } else { reoSpamming = false; } pingFilterTimer.Stop(); }
private void OnlineHotkey(int effect) { if (DS3Interop.InLoadingScreen()) { return; } if (effect == 11 && Settings.Default.SpamRedEyeOrb) { reoSpamming ^= true; reoSpamCnt = 0; if (!reoSpamming && DS3Interop.IsSearchingInvasion()) { DS3Interop.ApplyEffect(11); } } else { DS3Interop.ApplyEffect(effect); } }
private void UpdateTimer_Tick(object sender, EventArgs e) { Player.UpdatePlayerList(); Player.UpdateInGameInfo(); playerData.Clear(); foreach (Player p in Player.ActivePlayers()) { playerData.Add(p); } // Update session info column sizes foreach (var col in dataGridSession.Columns) { col.Width = new DataGridLength(1, DataGridLengthUnitType.Pixel); col.Width = new DataGridLength(1, DataGridLengthUnitType.Auto); } dataGridSession.UpdateLayout(); // Update overlay column sizes foreach (var col in overlay.dataGrid.Columns) { col.Width = new DataGridLength(1, DataGridLengthUnitType.Pixel); col.Width = new DataGridLength(1, DataGridLengthUnitType.SizeToCells); } overlay.dataGrid.UpdateLayout(); // Queue position update after the overlay has re-rendered Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(overlay.UpdatePosition)); DS3Interop.NetStatus status = DS3Interop.GetNetworkState(); if (reoSpamming && !Settings.Default.SpamRedEyeOrb) { reoSpamming = false; reoSpamCnt = 0; } if (status == DS3Interop.NetStatus.None) { if (hadInvaded && !reoSpamming) { DS3Interop.ApplyEffect(11); } if (reoSpamming) { reoSpamCnt = (reoSpamCnt + 1) % 5; if (DS3Interop.IsSearchingInvasion() ^ (reoSpamCnt != 0)) { DS3Interop.ApplyEffect(11); } } hadInvaded = false; pingCheked = false; } if (Settings.Default.UsePingFilter) { if (status == DS3Interop.NetStatus.Host || status == DS3Interop.NetStatus.TryCreateSession || DS3Interop.InLoadingScreen()) { // Someone invaded, or the local player summoned a phantom, or ping filter was too late pingFilterTimer.Stop(); reoSpamming = false; reoSpamCnt = 0; pingCheked = false; } if (status == DS3Interop.NetStatus.Client && !pingFilterTimer.IsEnabled && !pingCheked) { // Connection has been established pingCheked = true; pingFilterTimer.Interval = TimeSpan.FromSeconds(Settings.Default.SamplingDelay); pingFilterTimer.Start(); } } else { pingFilterTimer.Stop(); } }