Revert "Remove Utils.ActivePlayers"

This reverts commit b613fdcda6.
This commit is contained in:
Lucas Nicodemus 2017-12-31 01:28:21 -07:00
parent cb2ed84038
commit a5cad284a8
6 changed files with 19 additions and 11 deletions

View file

@ -149,6 +149,15 @@ namespace TShockAPI
}
}
/// <summary>
/// Gets the number of active players on the server.
/// </summary>
/// <returns>The number of active players on the server.</returns>
public int ActivePlayers()
{
return Main.player.Where(p => null != p && p.active).Count();
}
//Random should not be generated in a method
Random r = new Random();
@ -1108,7 +1117,7 @@ namespace TShockAPI
}
else
{
invasionSize = 100 + (TShock.Config.InvasionMultiplier * TShock.Players.Length);
invasionSize = 100 + (TShock.Config.InvasionMultiplier * ActivePlayers());
}
// Order matters
@ -1142,12 +1151,12 @@ namespace TShockAPI
}
/// <summary>Updates the console title with some pertinent information.</summary>
/// <param name="empty">If the server is empty; determines if we should use TShock.Players.Length for player count or 0.</param>
/// <param name="empty">If the server is empty; determines if we should use Utils.ActivePlayers() for player count or 0.</param>
internal void SetConsoleTitle(bool empty)
{
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
!string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "",
empty ? 0 : TShock.Players.Length,
empty ? 0 : ActivePlayers(),
TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
}