From 85a46562748c802a1be4ec9c769c3e9f0c38afa8 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Fri, 26 Nov 2021 23:52:05 +0700
Subject: [PATCH 1/7] Added values for AI[].
---
TShockAPI/GetDataHandlers.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index 02ff7de4..c4366961 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -689,12 +689,17 @@ namespace TShockAPI
/// ???
///
public int Index { get; set; }
+
+ ///
+ /// The special meaning of the projectile.
+ ///
+ public float[] Ai { get; set; }
}
///
/// NewProjectile - Called when a client creates a new projectile
///
public static HandlerList NewProjectile = new HandlerList();
- private static bool OnNewProjectile(MemoryStream data, short ident, Vector2 pos, Vector2 vel, float knockback, short dmg, byte owner, short type, int index, TSPlayer player)
+ private static bool OnNewProjectile(MemoryStream data, short ident, Vector2 pos, Vector2 vel, float knockback, short dmg, byte owner, short type, int index, TSPlayer player, float[] ai)
{
if (NewProjectile == null)
return false;
@@ -711,6 +716,7 @@ namespace TShockAPI
Type = type,
Index = index,
Player = player,
+ Ai = ai
};
NewProjectile.Invoke(null, args);
return args.Handled;
@@ -2788,7 +2794,7 @@ namespace TShockAPI
var index = TShock.Utils.SearchProjectile(ident, owner);
- if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player))
+ if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player, ai))
return true;
lock (args.Player.RecentlyCreatedProjectiles)
From bf605a212735024930ef65ccfc89f3183ebf5633 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 00:00:55 +0700
Subject: [PATCH 2/7] Added "Bouncer," which prohibits the creation of large
projectiles.
---
TShockAPI/Bouncer.cs | 55 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 2cae6ca0..8d1c9d93 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -945,6 +945,7 @@ namespace TShockAPI
byte owner = args.Owner;
short type = args.Type;
int index = args.Index;
+ float[] ai = args.Ai;
if (index > Main.maxProjectiles)
{
@@ -1082,6 +1083,20 @@ namespace TShockAPI
return;
}
+ if (
+ (Projectile_MaxValuesAI.ContainsKey(type) &&
+ (ai[0] > Projectile_MaxValuesAI[type] || ai[0] < Projectile_MinValuesAI[type])) ||
+
+ (Projectile_MaxValuesAI2.ContainsKey(type) &&
+ (ai[1] > Projectile_MaxValuesAI2[type] || ai[1] < Projectile_MaxValuesAI2[type]))
+ )
+ {
+ TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified AI from {0}.", args.Player.Name);
+ args.Player.RemoveProjectile(ident, owner);
+ args.Handled = true;
+ return;
+ }
+
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
if (type == ProjectileID.CrystalShard && TShock.Config.Settings.ProjIgnoreShrapnel) // Ignore crystal shards
@@ -2496,5 +2511,45 @@ namespace TShockAPI
{ ProjectileID.GoldShortswordStab, ItemID.GoldShortsword },
{ ProjectileID.PlatinumShortswordStab, ItemID.PlatinumShortsword }
};
+
+ private Dictionary Projectile_MinValuesAI = new Dictionary {
+ { 611, -1 },
+
+ { 950, 0 }
+ };
+ private Dictionary Projectile_MaxValuesAI = new Dictionary {
+ { 611, 1 },
+
+ { 950, 0 }
+ };
+
+ private Dictionary Projectile_MinValuesAI2 = new Dictionary {
+ { 405, 0 },
+ { 410, 0 },
+
+ { 424, 0 },
+ { 425, 0 },
+ { 426, 0 },
+
+ { 612, 0 },
+ { 953, 0 },
+
+ { 756, 0 },
+ { 522, 0 }
+ };
+ private Dictionary Projectile_MaxValuesAI2 = new Dictionary {
+ { 405, 2 },
+ { 410, 2 },
+
+ { 424, 1 },
+ { 425, 1 },
+ { 426, 1 },
+
+ { 612, 2 },
+ { 953, 2 },
+
+ { 756, 1 },
+ { 522, 0 }
+ };
}
}
From f11ffd2b91dcb4e32d20aaf88bb877742a00e94a Mon Sep 17 00:00:00 2001
From: Zoom L1 <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 09:30:52 +0700
Subject: [PATCH 3/7] Fixed the maximum and minimum values.
Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com>
---
TShockAPI/Bouncer.cs | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 8d1c9d93..980f2ebf 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -2524,32 +2524,32 @@ namespace TShockAPI
};
private Dictionary Projectile_MinValuesAI2 = new Dictionary {
- { 405, 0 },
- { 410, 0 },
+ { 405, 0.8f },
+ { 410, 0.6f },
- { 424, 0 },
- { 425, 0 },
- { 426, 0 },
+ { 424, 0.5f },
+ { 425, 0.5f },
+ { 426, 0.5f },
- { 612, 0 },
- { 953, 0 },
+ { 612, 0.4f },
+ { 953, 0.85f },
- { 756, 0 },
+ { 756, 0.5f },
{ 522, 0 }
};
private Dictionary Projectile_MaxValuesAI2 = new Dictionary {
- { 405, 2 },
- { 410, 2 },
+ { 405, 1.2f },
+ { 410, 1.2f },
- { 424, 1 },
- { 425, 1 },
- { 426, 1 },
+ { 424, 0.8f },
+ { 425, 0.8f },
+ { 426, 0.8f },
- { 612, 2 },
+ { 612, 0.7f },
{ 953, 2 },
{ 756, 1 },
- { 522, 0 }
+ { 522, 40f }
};
}
}
From 246c67a622c823cfab2bedc175145896f5acc385 Mon Sep 17 00:00:00 2001
From: Zoom L1 <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 09:34:14 +0700
Subject: [PATCH 4/7] Updated the dictionaries.
---
TShockAPI/Bouncer.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 980f2ebf..1679de62 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1088,7 +1088,7 @@ namespace TShockAPI
(ai[0] > Projectile_MaxValuesAI[type] || ai[0] < Projectile_MinValuesAI[type])) ||
(Projectile_MaxValuesAI2.ContainsKey(type) &&
- (ai[1] > Projectile_MaxValuesAI2[type] || ai[1] < Projectile_MaxValuesAI2[type]))
+ (ai[1] > Projectile_MaxValuesAI2[type] || ai[1] < Projectile_MinValuesAI2[type]))
)
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified AI from {0}.", args.Player.Name);
@@ -2512,18 +2512,18 @@ namespace TShockAPI
{ ProjectileID.PlatinumShortswordStab, ItemID.PlatinumShortsword }
};
- private Dictionary Projectile_MinValuesAI = new Dictionary {
+ private Dictionary Projectile_MinValuesAI = new Dictionary {
{ 611, -1 },
{ 950, 0 }
};
- private Dictionary Projectile_MaxValuesAI = new Dictionary {
+ private Dictionary Projectile_MaxValuesAI = new Dictionary {
{ 611, 1 },
{ 950, 0 }
};
- private Dictionary Projectile_MinValuesAI2 = new Dictionary {
+ private Dictionary Projectile_MinValuesAI2 = new Dictionary {
{ 405, 0.8f },
{ 410, 0.6f },
@@ -2537,7 +2537,7 @@ namespace TShockAPI
{ 756, 0.5f },
{ 522, 0 }
};
- private Dictionary Projectile_MaxValuesAI2 = new Dictionary {
+ private Dictionary Projectile_MaxValuesAI2 = new Dictionary {
{ 405, 1.2f },
{ 410, 1.2f },
From 2f30ef20fdd427749b14edf25e8d01cbaacd7001 Mon Sep 17 00:00:00 2001
From: Zoom L1 <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 11:28:04 +0700
Subject: [PATCH 5/7] Update CHANGELOG.md
---
CHANGELOG.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0aa888dc..03bbaa6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Do not forget to sign every line you change with your name. (@hakusaro)
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change.
+## TShock 4.5.11
+* Fixed the exploit with increasing projectile size.
+
## TShock 4.5.10
* Changed the server behavior when `SIGINT` is received. When `SIGINT` is trapped, the server will attempt to shut down safely. When it is trapped a second time in a session, it will immediately exit. (`SIGINT` is typically triggered via CTRL + C.) This means that it is possible to corrupt your world if you force shutdown at the wrong time (e.g., while the world is saving), but hopefully you expect this to happen if you hit CTRL + C twice in a session and you read the warning. (@hakusaro, @Onusai)
From 606b9e43d70bc8511dda31826ae91bf27cc3f300 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 11:57:48 +0700
Subject: [PATCH 6/7] Fixed the minimum value that made the "Bouncer" not work
properly
---
TShockAPI/Bouncer.cs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 1679de62..28783ab2 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1083,12 +1083,17 @@ namespace TShockAPI
return;
}
+ /*if (
+ (Projectile_MaxValuesAI.ContainsKey(type) &&
+ (Projectile_MinValuesAI[type] > ai[0] || ai[0] < Projectile_MaxValuesAI[type])) ||
+ (Projectile_MaxValuesAI2.ContainsKey(type) &&
+ (Projectile_MinValuesAI2[type] > ai[1] || Projectile_MaxValuesAI2[type] < ai[1]))
+ )*/
if (
(Projectile_MaxValuesAI.ContainsKey(type) &&
- (ai[0] > Projectile_MaxValuesAI[type] || ai[0] < Projectile_MinValuesAI[type])) ||
-
+ (Projectile_MaxValuesAI[type] < ai[0] || Projectile_MinValuesAI[type] > ai[0])) ||
(Projectile_MaxValuesAI2.ContainsKey(type) &&
- (ai[1] > Projectile_MaxValuesAI2[type] || ai[1] < Projectile_MinValuesAI2[type]))
+ (Projectile_MaxValuesAI2[type] < ai[1] || Projectile_MinValuesAI2[type] > ai[1]))
)
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified AI from {0}.", args.Player.Name);
@@ -1097,6 +1102,8 @@ namespace TShockAPI
return;
}
+
+
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
if (type == ProjectileID.CrystalShard && TShock.Config.Settings.ProjIgnoreShrapnel) // Ignore crystal shards
@@ -2524,8 +2531,8 @@ namespace TShockAPI
};
private Dictionary Projectile_MinValuesAI2 = new Dictionary {
- { 405, 0.8f },
- { 410, 0.6f },
+ { 405, 0f },
+ { 410, 0f },
{ 424, 0.5f },
{ 425, 0.5f },
From 76b0d9e5634738ddb2f66d4198e933024f1685d0 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sat, 27 Nov 2021 11:59:49 +0700
Subject: [PATCH 7/7] Removed unnecessary code comments.
---
TShockAPI/Bouncer.cs | 6 ------
1 file changed, 6 deletions(-)
diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 28783ab2..38da95dd 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -1083,12 +1083,6 @@ namespace TShockAPI
return;
}
- /*if (
- (Projectile_MaxValuesAI.ContainsKey(type) &&
- (Projectile_MinValuesAI[type] > ai[0] || ai[0] < Projectile_MaxValuesAI[type])) ||
- (Projectile_MaxValuesAI2.ContainsKey(type) &&
- (Projectile_MinValuesAI2[type] > ai[1] || Projectile_MaxValuesAI2[type] < ai[1]))
- )*/
if (
(Projectile_MaxValuesAI.ContainsKey(type) &&
(Projectile_MaxValuesAI[type] < ai[0] || Projectile_MinValuesAI[type] > ai[0])) ||