parent
cb2ed84038
commit
a5cad284a8
6 changed files with 19 additions and 11 deletions
|
|
@ -68,7 +68,6 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@hakusaro).
|
* Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@hakusaro).
|
||||||
* Removed broken noclip detection and attempted prevention. TShock wasn't doing a good job at stopping noclip. It's always worse to claim that you do something that you can't/don't do, so removing this is better than keeping broken detection in. (@hakusaro)
|
* Removed broken noclip detection and attempted prevention. TShock wasn't doing a good job at stopping noclip. It's always worse to claim that you do something that you can't/don't do, so removing this is better than keeping broken detection in. (@hakusaro)
|
||||||
* Replaced `Utils.FindPlayer` with `TSPlayer.FindByNameOrID` to more appropriately be object orientated. (@hakusaro)
|
* Replaced `Utils.FindPlayer` with `TSPlayer.FindByNameOrID` to more appropriately be object orientated. (@hakusaro)
|
||||||
* Removed `Utils.ActivePlayers()` -- use `TShock.Players.Length` instead. (@hakusaro)
|
|
||||||
* Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro)
|
* Moved `Utils.Kick()` to `TSPlayer` since its first argument was a `TSPlayer` object. (@hakusaro)
|
||||||
* Removed `Utils.ForceKick()`. (@hakusaro)
|
* Removed `Utils.ForceKick()`. (@hakusaro)
|
||||||
* Removed `Utils.GetPlayerIP()`. (@hakusaro)
|
* Removed `Utils.GetPlayerIP()`. (@hakusaro)
|
||||||
|
|
|
||||||
|
|
@ -4819,7 +4819,7 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Players.Length, TShock.Config.MaxSlots);
|
args.Player.SendSuccessMessage("Online Players ({0}/{1})", TShock.Utils.ActivePlayers(), TShock.Config.MaxSlots);
|
||||||
|
|
||||||
var players = new List<string>();
|
var players = new List<string>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1892,7 +1892,7 @@ namespace TShockAPI
|
||||||
if (OnGetSection(args.Player, args.Data, args.Data.ReadInt32(), args.Data.ReadInt32()))
|
if (OnGetSection(args.Player, args.Data, args.Data.ReadInt32(), args.Data.ReadInt32()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (TShock.Players.Length + 1 > TShock.Config.MaxSlots &&
|
if (TShock.Utils.ActivePlayers() + 1 > TShock.Config.MaxSlots &&
|
||||||
!args.Player.HasPermission(Permissions.reservedslot))
|
!args.Player.HasPermission(Permissions.reservedslot))
|
||||||
{
|
{
|
||||||
args.Player.Kick(TShock.Config.ServerFullReason, true, true);
|
args.Player.Kick(TShock.Config.ServerFullReason, true, true);
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ namespace TShockAPI
|
||||||
return new JsonData()
|
return new JsonData()
|
||||||
{
|
{
|
||||||
port = Terraria.Netplay.ListenPort,
|
port = Terraria.Netplay.ListenPort,
|
||||||
currentPlayers = TShock.Players.Length,
|
currentPlayers = TShock.Utils.ActivePlayers(),
|
||||||
maxPlayers = TShock.Config.MaxSlots,
|
maxPlayers = TShock.Config.MaxSlots,
|
||||||
systemRam = GetTotalSystemRam(ServerApi.RunningMono),
|
systemRam = GetTotalSystemRam(ServerApi.RunningMono),
|
||||||
version = TShock.VersionNum.ToString(),
|
version = TShock.VersionNum.ToString(),
|
||||||
|
|
|
||||||
|
|
@ -1241,7 +1241,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
var player = new TSPlayer(args.Who);
|
var player = new TSPlayer(args.Who);
|
||||||
|
|
||||||
if (TShock.Players.Length + 1 > Config.MaxSlots + Config.ReservedSlots)
|
if (Utils.ActivePlayers() + 1 > Config.MaxSlots + Config.ReservedSlots)
|
||||||
{
|
{
|
||||||
player.Kick(Config.ServerFullNoReservedReason, true, true, null, false);
|
player.Kick(Config.ServerFullNoReservedReason, true, true, null, false);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|
@ -1400,7 +1400,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last player will leave after this hook is executed.
|
// The last player will leave after this hook is executed.
|
||||||
if (TShock.Players.Length == 1)
|
if (Utils.ActivePlayers() == 1)
|
||||||
{
|
{
|
||||||
if (Config.SaveWorldOnLastPlayerExit)
|
if (Config.SaveWorldOnLastPlayerExit)
|
||||||
SaveManager.Instance.SaveWorld();
|
SaveManager.Instance.SaveWorld();
|
||||||
|
|
@ -1621,7 +1621,7 @@ namespace TShockAPI
|
||||||
if (Config.EnableGeoIP && TShock.Geo != null)
|
if (Config.EnableGeoIP && TShock.Geo != null)
|
||||||
{
|
{
|
||||||
Log.Info("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP,
|
Log.Info("{0} ({1}) from '{2}' group from '{3}' joined. ({4}/{5})", player.Name, player.IP,
|
||||||
player.Group.Name, player.Country, TShock.Players.Length,
|
player.Group.Name, player.Country, TShock.Utils.ActivePlayers(),
|
||||||
TShock.Config.MaxSlots);
|
TShock.Config.MaxSlots);
|
||||||
if (!player.SilentJoinInProgress)
|
if (!player.SilentJoinInProgress)
|
||||||
Utils.Broadcast(string.Format("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow);
|
Utils.Broadcast(string.Format("{0} ({1}) has joined.", player.Name, player.Country), Color.Yellow);
|
||||||
|
|
@ -1629,7 +1629,7 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP,
|
Log.Info("{0} ({1}) from '{2}' group joined. ({3}/{4})", player.Name, player.IP,
|
||||||
player.Group.Name, TShock.Players.Length, TShock.Config.MaxSlots);
|
player.Group.Name, TShock.Utils.ActivePlayers(), TShock.Config.MaxSlots);
|
||||||
if (!player.SilentJoinInProgress)
|
if (!player.SilentJoinInProgress)
|
||||||
Utils.Broadcast(player.Name + " has joined.", Color.Yellow);
|
Utils.Broadcast(player.Name + " has joined.", Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 should not be generated in a method
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
|
|
||||||
|
|
@ -1108,7 +1117,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
invasionSize = 100 + (TShock.Config.InvasionMultiplier * TShock.Players.Length);
|
invasionSize = 100 + (TShock.Config.InvasionMultiplier * ActivePlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order matters
|
// Order matters
|
||||||
|
|
@ -1142,12 +1151,12 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Updates the console title with some pertinent information.</summary>
|
/// <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)
|
internal void SetConsoleTitle(bool empty)
|
||||||
{
|
{
|
||||||
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
|
Console.Title = string.Format("{0}{1}/{2} on {3} @ {4}:{5} (TShock for Terraria v{6})",
|
||||||
!string.IsNullOrWhiteSpace(TShock.Config.ServerName) ? TShock.Config.ServerName + " - " : "",
|
!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);
|
TShock.Config.MaxSlots, Main.worldName, Netplay.ServerIP.ToString(), Netplay.ListenPort, TShock.VersionNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue