Fix NetHooks_NameCollision to kick duplicate players.

- Fixes Pryaxis/TShock#2530
This commit is contained in:
gohjoseph 2022-03-18 00:35:02 +08:00
parent 227cef3bd6
commit 8b064a7e22
2 changed files with 4 additions and 3 deletions

View file

@ -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

View file

@ -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<List<string>>(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;