示例#1
0
    public ConnectedPlayer AddOrUpdate(ConnectedPlayer player)
    {
        if (player.Equals(ConnectedPlayer.Invalid))
        {
            Logger.Log("Refused to add invalid connected player to this server's player list", Category.Connections);
            return(player);
        }

        Logger.Log($"Player {player.Username}'s client ID is: {player.ClientId}.");

        var loggedOffClient = GetLoggedOffClient(player.ClientId);

        if (loggedOffClient != null)
        {
            Logger.Log(
                $"ConnectedPlayer Username({player.Username}) already exists in this server's PlayerList as Character({loggedOffClient.Name}) " +
                $"Will update existing player instead of adding this new connected player.");

            if (loggedOffClient.GameObject == null)
            {
                Logger.LogFormat(
                    $"The existing ConnectedPlayer contains a null GameObject reference. Removing the entry");
                loggedOff.Remove(loggedOffClient);
                return(player);
            }

            // Switching over to the old player's character is handled by JoinedViewer.
        }

        loggedIn.Add(player);
        Logger.LogFormat("Added to this server's PlayerList {0}. Total:{1}; {2}", Category.Connections, player,
                         loggedIn.Count, string.Join(";", loggedIn));
        CheckRcon();
        return(player);
    }
示例#2
0
    private void TryAdd(ConnectedPlayer player)
    {
        if (player.Equals(ConnectedPlayer.Invalid))
        {
            Logger.Log("Refused to add invalid connected player", Category.Connections);
            return;
        }
        if (ContainsConnection(player.Connection))
        {
//			Logger.Log($"Updating {Get(player.Connection)} with {player}");
            ConnectedPlayer existingPlayer = Get(player.Connection);
            existingPlayer.GameObject = player.GameObject;
            existingPlayer.Name       = player.Name;       //Note that name won't be changed to empties/nulls
            existingPlayer.Job        = player.Job;
            existingPlayer.SteamId    = player.SteamId;
        }
        else
        {
            values.Add(player);
            Logger.Log($"Added {player}. Total:{values.Count}; {string.Join("; ",values)}", Category.Connections);
            //Adding kick timer for new players only
            StartCoroutine(KickTimer(player));
        }
        CheckRcon();
    }
示例#3
0
    public ConnectedPlayer AddOrUpdate(ConnectedPlayer player)
    {
        if (player.Equals(ConnectedPlayer.Invalid))
        {
            Logger.Log("Refused to add invalid connected player to this server's player list", Category.Connections);
            return(player);
        }
        if (ContainsConnection(player.Connection))
        {
//			Logger.Log($"Updating {Get(player.Connection)} with {player}");

            ConnectedPlayer existingPlayer = Get(player.Connection);
            Logger.LogFormat("ConnectedPlayer {0} already exists in this server's PlayerList as {1}. Will update existing player instead of adding this new connected player.", Category.Connections, player, existingPlayer);
            //TODO: Are we sure these are the only things that need to be updated?
            existingPlayer.GameObject = player.GameObject;
            existingPlayer.Name       = player.Name;       //Note that name won't be changed to empties/nulls
            existingPlayer.Job        = player.Job;
            existingPlayer.ClientId   = player.ClientId;
            CheckRcon();
            return(existingPlayer);
        }
        else
        {
            values.Add(player);
            Logger.LogFormat("Added to this server's PlayerList {0}. Total:{1}; {2}", Category.Connections, player, values.Count, string.Join(";", values));
            CheckRcon();
            return(player);
        }
    }
示例#4
0
        private IEnumerator CreateQuickPlayerPool()
        {
            QuickPoolInProgress = true;
            yield return(WaitFor.Seconds(1));

            QuickPoolInProgress = false;

            for (int i = 0; i < QuickPlayerPool.Count; i++)
            {
                ConnectedPlayer player = QuickPlayerPool.PickRandom();
                if (player == null)
                {
                    break;
                }

                QuickPlayerPool.Remove(player);
                if (player.Equals(ConnectedPlayer.Invalid))
                {
                    continue;
                }

                var kvp = GhostRoleManager.Instance.serverAvailableRoles.FirstOrDefault(role => role.Value == this);
                GhostRoleManager.Instance.ServerGhostRequestRole(player, kvp.Key);
            }

            QuickPlayerPool.Clear();
        }
示例#5
0
    /// <inheritdoc cref="AddExamineMsgFromServer(GameObject, string)"/>
    public static void AddExamineMsgFromServer(ConnectedPlayer recipient, string msg)
    {
        if (recipient == null || recipient.Equals(ConnectedPlayer.Invalid))
        {
            Logger.LogError($"Can't send message \"{msg}\" to invalid player!", Category.Chat);
            return;
        }

        AddExamineMsgFromServer(recipient.GameObject, msg);
    }
示例#6
0
    public void Remove(NetworkConnection connection)
    {
        ConnectedPlayer connectedPlayer = Get(connection);

        if (connectedPlayer.Equals(ConnectedPlayer.Invalid))
        {
            Debug.LogError($"Cannot remove by {connection}, not found");
        }
        else
        {
            TryRemove(connectedPlayer);
        }
    }
示例#7
0
    public void Remove(NetworkConnection connection)
    {
        ConnectedPlayer connectedPlayer = Get(connection);

        CheckForLoggedOffAdmin(connectedPlayer.UserId, connectedPlayer.Username);
        if (connectedPlayer.Equals(ConnectedPlayer.Invalid))
        {
            Logger.LogError($"Cannot remove by {connection}, not found", Category.Connections);
        }
        else
        {
            TryRemove(connectedPlayer);
        }
    }
示例#8
0
    private void TryAdd(ConnectedPlayer player)
    {
        if (player.Equals(InvalidConnectedPlayer))
        {
            Debug.Log("Refused to add invalid connected player");
            return;
        }
        if (ContainsConnection(player.Connection))
        {
//			Debug.Log($"Updating {Get(player.Connection)} with {player}");
            ConnectedPlayer existingPlayer = Get(player.Connection);
            existingPlayer.GameObject = player.GameObject;
            existingPlayer.Name       = player.Name;       //Note that name won't be changed to empties/nulls
            existingPlayer.Job        = player.Job;
        }
        else
        {
            values.Add(player);

            Debug.Log($"Added {player}. Total:{values.Count}; {string.Join("; ",values)}");
        }
    }
示例#9
0
    public ConnectedPlayer AddOrUpdate(ConnectedPlayer player)
    {
        if (player.Equals(ConnectedPlayer.Invalid))
        {
            Logger.Log("Refused to add invalid connected player to this server's player list", Category.Connections);
            return(player);
        }

        Logger.Log($"Player: {player.Username} client id is: {player.ClientId}");
        var loggedOffClient = GetLoggedOffClient(player.ClientId);

        if (loggedOffClient != null)
        {
            Logger.Log(
                $"ConnectedPlayer {player} already exists in this server's PlayerList as {loggedOff}. " +
                $"Will update existing player instead of adding this new connected player.");

            if (loggedOffClient.GameObject == null)
            {
                Logger.LogFormat(
                    $"The existing ConnectedPlayer contains a null GameObject reference. Removing the entry");
                loggedOff.Remove(loggedOffClient);
                return(player);
            }

            player.GameObject = loggedOffClient.GameObject;
            player.Name       = loggedOffClient.Name;       //Note that name won't be changed to empties/nulls
            player.Job        = loggedOffClient.Job;
            player.ClientId   = loggedOffClient.ClientId;
        }

        loggedIn.Add(player);
        Logger.LogFormat("Added to this server's PlayerList {0}. Total:{1}; {2}", Category.Connections, player,
                         loggedIn.Count, string.Join(";", loggedIn));
        CheckRcon();
        return(player);
    }
示例#10
0
 /// <summary>
 /// Called on client join to server, to update their info.
 /// </summary>
 /// <param name="connPlayer"></param>
 /// <returns></returns>
 public List <JobBanEntry> ClientAskingAboutJobBans(ConnectedPlayer connPlayer)
 {
     if (connPlayer.Equals(ConnectedPlayer.Invalid))
     {
         Logger.LogError($"Attempted to check job-ban for invalid player.", Category.Jobs);
         return(default);