From f942a6c98a1186c81e5948f7af0ff9494703d355 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 24 Dec 2017 20:09:12 -0700 Subject: [PATCH 1/2] Revert "Change Utils.SearchProjectile to return -1 in error" This reverts commit e19fd22fe0a5600af0c47c07eade94aff119f343. --- TShockAPI/Utils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 82791065..99480b58 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -925,7 +925,7 @@ namespace TShockAPI /// /// identity /// owner - /// projectile ID or -1 if not found + /// projectile ID public int SearchProjectile(short identity, int owner) { for (int i = 0; i < Main.maxProjectiles; i++) @@ -933,7 +933,7 @@ namespace TShockAPI if (Main.projectile[i].identity == identity && Main.projectile[i].owner == owner) return i; } - return -1; + return 1000; } /// From f2da3f6c839a194941399ff8e5586a21a5e715d4 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 24 Dec 2017 20:13:53 -0700 Subject: [PATCH 2/2] Remove index check on Bouncer NewProjectiles Note: even in the previous iteration of the code the search function returned -1 if it couldn't find it in the system, which would have made removal of projectiles by ident and owner impossible because they weren't found anyway. Either way, this is related to fixing #1584. --- TShockAPI/Bouncer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 40e2c355..022421ab 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -978,7 +978,7 @@ namespace TShockAPI short type = args.Type; int index = args.Index; - if (index > Main.maxProjectiles || index < 0) + if (index > Main.maxProjectiles) { args.Player.RemoveProjectile(ident, owner); args.Handled = true;