Fix ∞ velocity exploit (@bartico6, @tlworks)

This commit is contained in:
Lucas Nicodemus 2021-01-28 00:17:55 -08:00
parent f4cc14fb8e
commit 355a7f02f5
4 changed files with 34 additions and 3 deletions

View file

@ -135,6 +135,30 @@ namespace TShockAPI
var pos = args.Position;
var vel = args.Velocity;
if (Single.IsInfinity(vel.X) || Single.IsInfinity(vel.Y))
{
TShock.Log.ConsoleInfo("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to infinity) from {0}", args.Player.Name);
args.Player.Kick("Detected DOOM set to ON position.", true, true);
args.Handled = true;
return;
}
if (Single.IsNaN(vel.X) || Single.IsNaN(vel.Y))
{
TShock.Log.ConsoleInfo("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity to NaN) from {0}", args.Player.Name);
args.Player.Kick("Detected DOOM set to ON position.", true, true);
args.Handled = true;
return;
}
if (vel.X > 50000 || vel.Y > 50000 || vel.X < -50000 || vel.Y < -50000)
{
TShock.Log.ConsoleInfo("Bouncer / OnPlayerUpdate force kicked (attempted to set velocity +/- 50000) from {0}", args.Player.Name);
args.Player.Kick("Detected DOOM set to ON position.", true, true);
args.Handled = true;
return;
}
if (pos.X < 0 || pos.Y < 0 || pos.X >= Main.maxTilesX * 16 - 16 || pos.Y >= Main.maxTilesY * 16 - 16)
{
TShock.Log.ConsoleDebug("Bouncer / OnPlayerUpdate rejected from (position check) {0}", args.Player.Name);

View file

@ -28,7 +28,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Re-Logic, Pryaxis & TShock Contributors")]
[assembly: AssemblyProduct("TShockAPI")]
[assembly: AssemblyCopyright("Copyright © Re-Logic, Pryaxis & TShock Contributors 2011-2020")]
[assembly: AssemblyCopyright("Copyright © Re-Logic, Pryaxis & TShock Contributors 2011-2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View file

@ -57,7 +57,7 @@ namespace TShockAPI
/// <summary>VersionNum - The version number the TerrariaAPI will return back to the API. We just use the Assembly info.</summary>
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
/// <summary>VersionCodename - The version codename is displayed when the server starts. Inspired by software codenames conventions.</summary>
public static readonly string VersionCodename = "Go to sleep Patrikkk, Icy, Chris, Death, Axeel, Zaicon, hakusaro, Zack, and Yoraiz0r <3";
public static readonly string VersionCodename = "Now with less velocity, thanks to Off + Quake. Usual thanks to Chris/White <3";
/// <summary>SavePath - This is the path TShock saves its data in. This path is relative to the TerrariaServer.exe (not in ServerPlugins).</summary>
public static string SavePath = "tshock";