From 8b064a7e22b9dfd8967afda7f8180a6cc89aa270 Mon Sep 17 00:00:00 2001 From: gohjoseph Date: Fri, 18 Mar 2022 00:35:02 +0800 Subject: [PATCH] Fix `NetHooks_NameCollision` to kick duplicate players. - Fixes Pryaxis/TShock#2530 --- CHANGELOG.md | 1 + TShockAPI/TShock.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9801acac..6469df36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * 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. ## Upcoming changes +* Fixed duplicate characters (twins) after repeatedly logging in as the same character due to connection not being immediately closed during `NetHooks_NameCollision`. (@gohjoseph) * You could be here! ## TShock 4.5.16 diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index ce5b59bf..9da8c51a 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -521,7 +521,7 @@ namespace TShockAPI { if (player.IP == ip) { - Netplay.Clients[player.Index].PendingTermination = true; + player.Kick("You logged in from the same IP.", true, true, "Server", true); args.Handled = true; return; } @@ -530,7 +530,7 @@ namespace TShockAPI var ips = JsonConvert.DeserializeObject>(player.Account.KnownIps); if (ips.Contains(ip)) { - Netplay.Clients[player.Index].PendingTermination = true; + player.Kick("You logged in from another location.", true, true, "Server", true); args.Handled = true; } } @@ -1279,7 +1279,7 @@ namespace TShockAPI //Reset toggle creative powers to default, preventing potential power transfer & desync on another user occupying this slot later. - foreach(var kv in CreativePowerManager.Instance._powersById) + foreach (var kv in CreativePowerManager.Instance._powersById) { var power = kv.Value;