Wrap usages of TShock.Players[] with checks for out of bounds.
This commit is contained in:
parent
cd13cc97aa
commit
229d2bf990
2 changed files with 12 additions and 3 deletions
|
|
@ -2492,6 +2492,9 @@ namespace TShockAPI
|
|||
return false;
|
||||
}
|
||||
|
||||
if (id >= Main.maxPlayers)
|
||||
return true;
|
||||
|
||||
if (OnKillMe(id, direction, dmg, pvp))
|
||||
return true;
|
||||
|
||||
|
|
@ -2871,6 +2874,12 @@ namespace TShockAPI
|
|||
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id >= Main.maxPlayers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!TShock.Players[id].TPlayer.hostile)
|
||||
{
|
||||
args.Player.SendData(PacketTypes.PlayerBuff, "", id);
|
||||
|
|
@ -2977,7 +2986,7 @@ namespace TShockAPI
|
|||
}*/
|
||||
}
|
||||
|
||||
if (TShock.Players[id] == null)
|
||||
if (id >= Main.maxPlayers || TShock.Players[id] == null)
|
||||
return true;
|
||||
|
||||
if (dmg > TShock.Config.MaxDamage && !args.Player.Group.HasPermission(Permissions.ignoredamagecap) && id != args.Player.Index)
|
||||
|
|
@ -3330,7 +3339,7 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (Main.player[id] == null || TShock.Players[id] == null)
|
||||
if (id >= Main.maxPlayers || Main.player[id] == null || TShock.Players[id] == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ namespace TShockAPI
|
|||
return found;
|
||||
|
||||
byte plrID;
|
||||
if (byte.TryParse(plr, out plrID))
|
||||
if (byte.TryParse(plr, out plrID) && plrID < Main.maxPlayers)
|
||||
{
|
||||
TSPlayer player = TShock.Players[plrID];
|
||||
if (player != null && player.Active)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue