Merge pull request #1323 from NyxStudios/kips-e-zero

Fix KnownIps == 0 causing .Last() to fail (Fixes #1319 again).
This commit is contained in:
Rodrigo 2016-10-24 18:45:34 +01:00 committed by GitHub
commit bccf2924ef
2 changed files with 15 additions and 8 deletions

View file

@ -17,7 +17,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* `/v2/server/rawcmd` (@WhiteXZ).
* Fixed `/user group` always giving an unhelpful error messaging telling you to check the console, even if we knew exactly why it failed (@nicatronTg).
* Removed _all obsolete methods in TShock marked obsolete prior to this version (all of them)_ (@nicatronTg).
* Fixed issue where registration + login would fail with no pre-existing users (@DogooFalchion).
* Fixed issue where registration + login would fail because KnownIps had 0 items and .Last() doesn't work on collections with 0 items (@DogooFalchion, @nicatronTg, @Simon311).
* Added `/uploadssc [player]` which allows someone to upload SSC data for [player] and store it on the server. Adds `tshock.ssc.upload` and `tshock.ssc.upload.others` permission nodes to match (@DogooFalchion).
* Added hardened stone to the whitelist of tiles editable by players (@DogooFalchion).
* Added conversion system to send convert old MOTD format into smart text, while preserving initial line starting values to keep byte optimization for background colors Thanks to (@WhiteXZ, @Simon311, and especially @DogooFalchion) for the hard work on this issue.

View file

@ -409,16 +409,23 @@ namespace TShockAPI
KnownIps = JsonConvert.DeserializeObject<List<String>>(args.Player.User.KnownIps);
}
bool last = KnownIps.Last() == args.Player.IP;
if (!last)
if (KnownIps.Count == 0)
{
if (KnownIps.Count == 100)
{
KnownIps.RemoveAt(0);
}
KnownIps.Add(args.Player.IP);
}
else
{
bool last = KnownIps.Last() == args.Player.IP;
if (!last)
{
if (KnownIps.Count == 100)
{
KnownIps.RemoveAt(0);
}
KnownIps.Add(args.Player.IP);
}
}
args.Player.User.KnownIps = JsonConvert.SerializeObject(KnownIps, Formatting.Indented);
Users.UpdateLogin(args.Player.User);