From 3b748f1156c12dec293185cc19504db045e21abf Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 19 May 2020 23:42:59 -0700 Subject: [PATCH 1/7] Potentially fix player desync issue It was discovered that LastNetPosition is being checked to see if it's zero in Bouncer. Then, Bouncer rejects the update. The default is zero and potentially this can be zero in other ways. The original code in master (checked at 9f4892f in GetDataHandlers) had an additional write on LastNetPosition to update it, but this write was not moved over to Bouncer. Thus, there is a high probability that players are "desync'd" after LastNetPosition gets stuck at zero and never updates. --- TShockAPI/Bouncer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 1c64448e..a0a5dee9 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -122,9 +122,9 @@ namespace TShockAPI if (args.Player.LastNetPosition == Vector2.Zero) { - TShock.Log.ConsoleDebug("Bouncer / OnPlayerUpdate rejected from (last network position) {0}", args.Player.Name); - args.Handled = true; - return; + TShock.Log.ConsoleInfo("Bouncer / OnPlayerUpdate *would have rejected* from (last network position zero) {0}", args.Player.Name); + // args.Handled = true; + // return; } if (!pos.Equals(args.Player.LastNetPosition)) @@ -184,6 +184,7 @@ namespace TShockAPI } } + args.Player.LastNetPosition = pos; return; } From 8d96e2114a5ad1d31c8ed719263b18c669454aa1 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 19 May 2020 23:52:18 -0700 Subject: [PATCH 2/7] Update changelog again --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1b41e05..612bfb4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large. -## Upcoming changes +## TShock 4.4.0 (Pre-release 4) * Debug logging now provides ConsoleDebug and ILog has been updated to support the concept of debug logs. Debug logs are now controlled by `config.json` instead of by preprocessor debug flag. (@hakusaro) * Removed `/confuse` command and Terraria player data resync from @Zidonuke. (@hakusaro) +* Attempted to fix the player desync issue by changing `LastNetPosition` logic and disabling a check in Bouncer that would normally reject player update packets from players. (@QuiCM, @hakusaro) ## TShock 4.4.0 (Pre-release 3) * Fixed `/worldmode` command to correctly target world mode. (@Ristellise) From 7314a34986b5e2aec45fcaac98cb1e7f7d264a06 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 May 2020 00:00:09 -0700 Subject: [PATCH 3/7] Properly don't log if not logging enabled --- TShockAPI/SqlLog.cs | 7 +++++-- TShockAPI/TextLog.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/TShockAPI/SqlLog.cs b/TShockAPI/SqlLog.cs index a0fd4493..599a9de8 100644 --- a/TShockAPI/SqlLog.cs +++ b/TShockAPI/SqlLog.cs @@ -211,8 +211,11 @@ namespace TShockAPI /// The message to be written. public void ConsoleDebug(string message) { - Console.WriteLine("Debug: " + message); - Write(message, TraceLevel.Verbose); + if (TShock.Config.DebugLogs) + { + Console.WriteLine("Debug: " + message); + Write(message, TraceLevel.Verbose); + } } /// diff --git a/TShockAPI/TextLog.cs b/TShockAPI/TextLog.cs index 349ceb01..33dcb936 100644 --- a/TShockAPI/TextLog.cs +++ b/TShockAPI/TextLog.cs @@ -178,8 +178,11 @@ namespace TShockAPI /// The message to be written. public void ConsoleDebug(string message) { - Console.WriteLine("Debug: " + message); - Write(message, TraceLevel.Verbose); + if (TShock.Config.DebugLogs) + { + Console.WriteLine("Debug: " + message); + Write(message, TraceLevel.Verbose); + } } /// From dea5e0f8f8e4780368759299f82ab5b4332e6a41 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 20 May 2020 00:25:13 -0700 Subject: [PATCH 4/7] Remove reference to obsolete forums in setup Thanks to @Retrograde-i486 for pointing this out! Fixes #1793. --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5d2c2912..d32e1155 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -5012,7 +5012,7 @@ namespace TShockAPI args.Player.SendSuccessMessage("Your new account has been verified, and the {0}setup system has been turned off.", Specifier); args.Player.SendSuccessMessage("You can always use the {0}user command to manage players.", Specifier); args.Player.SendSuccessMessage("The setup system will remain disabled as long as a superadmin exists (even if you delete setup.lock)."); - args.Player.SendSuccessMessage("Share your server, talk with other admins, and more on our forums -- https://tshock.co/"); + args.Player.SendSuccessMessage("Share your server, talk with other admins, and more on GitHub! -- https://tshock.co/"); args.Player.SendSuccessMessage("Thank you for using TShock for Terraria!"); FileTools.CreateFile(Path.Combine(TShock.SavePath, "setup.lock")); File.Delete(Path.Combine(TShock.SavePath, "setup-code.txt")); From 20d1072f989a5f82fff320ef139998e095a22d0e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 20 May 2020 07:35:50 +0000 Subject: [PATCH 5/7] docs: update README.md [skip ci] --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 257df430..abdb437d 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Nathan Easton

💻
Shinon

⚠️ 💻 📖 + +
Retrograde-i486

💻 + From 8db2ce76195043bb83fdeb629b0bbdc8378d2e55 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 20 May 2020 07:35:51 +0000 Subject: [PATCH 6/7] docs: update README_cn.md [skip ci] --- README_cn.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README_cn.md b/README_cn.md index 7ede26da..caed48cb 100644 --- a/README_cn.md +++ b/README_cn.md @@ -80,6 +80,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Nathan Easton

💻
Shinon

⚠️ 💻 📖 + +
Retrograde-i486

💻 + From d45d8ceebe7894055b205d82d74ba21ff4073ead Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 20 May 2020 07:35:52 +0000 Subject: [PATCH 7/7] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index f141644b..8066f717 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -77,6 +77,15 @@ "code", "doc" ] + }, + { + "login": "Retrograde-i486", + "name": "Retrograde-i486", + "avatar_url": "https://avatars1.githubusercontent.com/u/65242258?v=4", + "profile": "https://github.com/Retrograde-i486", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7,