/// <summary> /// Handles the outgoing player connection, either by disconnect or kick. /// </summary> /// <param name="player">The player.</param> public async Task HandleOutgoingPlayerConnection(string player) { Log.Write("Detected outgoing connection for " + player, _logClassType, _logPrefix); player = player.ToLowerInvariant(); // The outgoing player was actually in the game, and not a spectator var outgoingWasActive = _sst.ServerInfo.IsActivePlayer(player); // Get the outgoing player's team before he disconnected var outgoingTeam = _sst.ServerInfo.CurrentPlayers[player].Team; // Evaluate the player's no-show/sub status for pickup module, if active if (_sst.Mod.Pickup.Active) { await _sst.Mod.Pickup.Manager.EvalOutgoingPlayer(player, outgoingWasActive, outgoingTeam); _sst.Mod.Pickup.Manager.RemoveActivePickupPlayer(player); _sst.Mod.Pickup.Manager.RemoveEligibility(player); } // Remove player from our internal list RemovePlayer(player); // If player was/is currently being spectated, clear the internal tracker if (!string.IsNullOrEmpty(_sst.ServerInfo.PlayerFollowedForAccuracy) && _sst.ServerInfo.PlayerFollowedForAccuracy.Equals(player)) { _sst.ServerInfo.PlayerFollowedForAccuracy = string.Empty; } // If IRC module is active, send the message to the IRC channel if (_sst.Mod.Irc.Active && _sst.Mod.Irc.IsConnectedToIrc) { _sst.Mod.Irc.IrcManager.SendIrcMessage(_sst.Mod.Irc.IrcManager.IrcSettings.ircChannel, string.Format("{0} has left my QL server.", player)); } // Evaluate player's early quit situation if that module is active if (!_sst.Mod.EarlyQuit.Active) { return; } if (!outgoingWasActive) { return; } // Do not increase player's early quit count if already banned. var banDb = new DbBans(); if (banDb.UserAlreadyBanned(player)) { return; } var eqh = new EarlyQuitHandler(_sst); await eqh.EvalCountdownQuitter(player); await eqh.EvalInProgressQuitter(player); }
/// <summary> /// Handles the situation when a player joins the spectators. /// </summary> /// <param name="player">The player.</param> public async Task HandlePlayerWentToSpec(string player) { // Spectator event includes the full clan tag, so need to strip player = Helpers.GetStrippedName(player); // The outgoing player was actually in the game & not a spectator. //TODO: investigate this, it might always be false for sub being moved out in pickup var outgoingWasActive = _sst.ServerInfo.IsActivePlayer(player); // Get the outgoing player's team before he disconnected var outgoingTeam = _sst.ServerInfo.CurrentPlayers[player].Team; // Evaluate the player's no-show/sub status for pickup module, if active if (_sst.Mod.Pickup.Active) { await _sst.Mod.Pickup.Manager.EvalOutgoingPlayer(player, outgoingWasActive, outgoingTeam); _sst.Mod.Pickup.Manager.RemoveActivePickupPlayer(player); _sst.Mod.Pickup.Manager.RemoveEligibility(player); } // If IRC module is active, send the message to the IRC channel if (_sst.Mod.Irc.Active && _sst.Mod.Irc.IsConnectedToIrc) { _sst.Mod.Irc.IrcManager.SendIrcMessage(_sst.Mod.Irc.IrcManager.IrcSettings.ircChannel, string.Format("{0} has joined the spectators.", player)); } // Evaluate player's early quit situation if that module is active if (!_sst.Mod.EarlyQuit.Active) { return; } if (!outgoingWasActive) { return; } var eqh = new EarlyQuitHandler(_sst); await eqh.EvalCountdownQuitter(player); await eqh.EvalInProgressQuitter(player); }