Merge remote-tracking branch 'punchready/general-devel' into general-devel
This commit is contained in:
commit
83427106a5
3 changed files with 82 additions and 4 deletions
|
|
@ -41,6 +41,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Changed SendTileRect handling from a denylist to an allowlist with stricter checks. This prevents essentially all exploits involving this packet. Most notably this stops people from placing arbitrary tiles with arbitrary framing values, which are the root of most exploits. (@punchready)
|
* Changed SendTileRect handling from a denylist to an allowlist with stricter checks. This prevents essentially all exploits involving this packet. Most notably this stops people from placing arbitrary tiles with arbitrary framing values, which are the root of most exploits. (@punchready)
|
||||||
* Removed the config options `TileRectangleSizeThreshold` and `KickOnTileRectangleSizeThresholdBroken` because they are made obsolete by the new system, which will only allow valid rectangle sizes (at a maximum of only 4 by 4 tiles in 1.4.3.6). (@punchready)
|
* Removed the config options `TileRectangleSizeThreshold` and `KickOnTileRectangleSizeThresholdBroken` because they are made obsolete by the new system, which will only allow valid rectangle sizes (at a maximum of only 4 by 4 tiles in 1.4.3.6). (@punchready)
|
||||||
* Bumped Newtonsoft Json to 13.0.1. (@dependabot)
|
* Bumped Newtonsoft Json to 13.0.1. (@dependabot)
|
||||||
|
* Added a second `Utils.TryParseTime` method for parsing large, positive time spans. (@punchready)
|
||||||
|
* Fixed `/tempgroup` breaking on durations greater than roughly 24 days. (@punchready)
|
||||||
|
|
||||||
## TShock 4.5.17
|
## TShock 4.5.17
|
||||||
* Fixed duplicate characters (twins) after repeatedly logging in as the same character due to connection not being immediately closed during `NetHooks_NameCollision`. (@gohjoseph)
|
* Fixed duplicate characters (twins) after repeatedly logging in as the same character due to connection not being immediately closed during `NetHooks_NameCollision`. (@gohjoseph)
|
||||||
|
|
|
||||||
|
|
@ -1511,7 +1511,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TShock.Utils.TryParseTime(duration, out int seconds))
|
if (TShock.Utils.TryParseTime(duration, out ulong seconds))
|
||||||
{
|
{
|
||||||
expiration = DateTime.UtcNow.AddSeconds(seconds);
|
expiration = DateTime.UtcNow.AddSeconds(seconds);
|
||||||
}
|
}
|
||||||
|
|
@ -1879,7 +1879,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (args.Parameters.Count > 2)
|
if (args.Parameters.Count > 2)
|
||||||
{
|
{
|
||||||
int time;
|
ulong time;
|
||||||
if (!TShock.Utils.TryParseTime(args.Parameters[2], out time))
|
if (!TShock.Utils.TryParseTime(args.Parameters[2], out time))
|
||||||
{
|
{
|
||||||
args.Player.SendErrorMessage("Invalid time string! Proper format: _d_h_m_s, with at least one time specifier.");
|
args.Player.SendErrorMessage("Invalid time string! Proper format: _d_h_m_s, with at least one time specifier.");
|
||||||
|
|
@ -1887,7 +1887,7 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ply[0].tempGroupTimer = new System.Timers.Timer(time * 1000);
|
ply[0].tempGroupTimer = new System.Timers.Timer(time * 1000d);
|
||||||
ply[0].tempGroupTimer.Elapsed += ply[0].TempGroupTimerElapsed;
|
ply[0].tempGroupTimer.Elapsed += ply[0].TempGroupTimerElapsed;
|
||||||
ply[0].tempGroupTimer.Start();
|
ply[0].tempGroupTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -574,7 +574,7 @@ namespace TShockAPI
|
||||||
var sb = new StringBuilder(3);
|
var sb = new StringBuilder(3);
|
||||||
for (int i = 0; i < str.Length; i++)
|
for (int i = 0; i < str.Length; i++)
|
||||||
{
|
{
|
||||||
if (Char.IsDigit(str[i]) || (str[i] == '-' || str[i] == '+' || str[i] == ' '))
|
if (char.IsDigit(str[i]) || str[i] == '-' || str[i] == '+' || str[i] == ' ')
|
||||||
sb.Append(str[i]);
|
sb.Append(str[i]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -607,6 +607,82 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse a string as a positive timespan (_d_m_h_s).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The time string.</param>
|
||||||
|
/// <param name="seconds">The seconds.</param>
|
||||||
|
/// <returns>Whether the string was parsed successfully.</returns>
|
||||||
|
public bool TryParseTime(string str, out ulong seconds)
|
||||||
|
{
|
||||||
|
seconds = 0;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(str))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sb = new StringBuilder(3);
|
||||||
|
for (int i = 0; i < str.Length; i++)
|
||||||
|
{
|
||||||
|
if (char.IsDigit(str[i]) || str[i] == '-' || str[i] == '+' || str[i] == ' ')
|
||||||
|
sb.Append(str[i]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num;
|
||||||
|
if (!int.TryParse(sb.ToString().Trim(' '), out num))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
sb.Clear();
|
||||||
|
|
||||||
|
if (num == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int numSeconds;
|
||||||
|
switch (str[i])
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
|
numSeconds = num;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
numSeconds = num * 60;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
numSeconds = num * 60 * 60;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
numSeconds = num * 60 * 60 * 24;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numSeconds > 0)
|
||||||
|
{
|
||||||
|
if (ulong.MaxValue - seconds < (uint)numSeconds)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
seconds += (uint)numSeconds;
|
||||||
|
}
|
||||||
|
else if (seconds >= (uint)Math.Abs(numSeconds))
|
||||||
|
{
|
||||||
|
seconds -= (uint)Math.Abs(numSeconds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sb.Length != 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches for a projectile by identity and owner
|
/// Searches for a projectile by identity and owner
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue