From f82ab41a254f893f332900e5f22d6bc8cf5f08a2 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Fri, 29 May 2020 21:04:48 -0700 Subject: [PATCH] Add /sync command to alleviate door related sadness Run /sync if your doors disappear. This will resync your local client with the server state. For more information, please see the associated changelog entry. --- CHANGELOG.md | 6 ++++++ TShockAPI/Bouncer.cs | 6 ++++-- TShockAPI/Commands.cs | 11 +++++++++++ TShockAPI/DB/GroupManager.cs | 3 ++- TShockAPI/Permissions.cs | 3 +++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d409b244..fd59e1e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Added HandleFoodPlatterTryPlacing event, which is called whenever a player places a food in a plate. Add antihack to bouncer, to prevent removing food from plates if the region is protected; To prevent placement if they are not in range; To prevent placement if the item is not placed from player hand. (@Patrikkk) * Fixed an offset error in NetTile that impacted `SendTileSquare`. It was being read as a `byte` and not a `ushort`. (@QuiCM) * Removed packet monitoring from debug logs. To achieve the same results, install @QuiCM's packet monitor plugin (it does better things). (@hakusaro) +* Updated packet monitoring in send tile square handler for Bouncer debugging. (@hakusaro) +* Added `/sync`, activated with `tshock.synclocalarea`. This is a default guest permission. When the command is issued, the server will resync area around the player in the event of a desync issue. (@hakusaro) + * If your doors disappear, this command will allow a player to resync without having to disconnect from the server. + * The default group that gets this permission is `Guest` for the time being. + * To add this command to your guest group, give them `tshock.synclocalarea`, with `/group addperm guest tshock.synclocalarea`. + * This command may be removed at any time in the future (and will likely be removed when send tile square handling is fixed). ## TShock 4.4.0 (Pre-release 8) * Update for OTAPI 2.0.0.36 and Terraria 1.4.0.4. (@hakusaro, @Patrikkk, @DeathCradle) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index abd5fe05..c3a62dae 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -558,6 +558,8 @@ namespace TShockAPI return; } + bool changed = false; + bool failed = false; try { var tiles = new NetTile[size, size]; @@ -569,7 +571,6 @@ namespace TShockAPI } } - bool changed = false; for (int x = 0; x < size; x++) { int realx = tileX + x; @@ -709,9 +710,10 @@ namespace TShockAPI catch { args.Player.SendTileSquare(tileX, tileY, size); + failed = true; } - TShock.Log.ConsoleDebug("Bouncer / SendTileSquare reimplemented from spaghetti from {0}", args.Player.Name); + TShock.Log.ConsoleDebug("Bouncer / SendTileSquare from {0} {1} {2}", args.Player.Name, changed, failed); args.Handled = true; } diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 8d131588..fd3f5e9e 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -589,6 +589,10 @@ namespace TShockAPI { HelpText = "Creates a reference tables for Terraria data types and the TShock permission system in the server folder." }); + add(new Command(Permissions.synclocalarea, SyncLocalArea, "sync") + { + HelpText = "Sends all tiles from the server to the player to resync the client with the actual world state." + }); #endregion add(new Command(Aliases, "aliases") @@ -5302,6 +5306,13 @@ namespace TShockAPI return; } + private static void SyncLocalArea(CommandArgs args) + { + args.Player.SendTileSquare((int) args.Player.TileX, (int) args.Player.TileY, 32); + args.Player.SendWarningMessage("Sync'd!"); + return; + } + #endregion General Commands #region Cheat Commands diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index 6405b5bc..c9a3b760 100644 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -64,7 +64,8 @@ namespace TShockAPI.DB Permissions.canlogin, Permissions.canpartychat, Permissions.cantalkinthird, - Permissions.canchat)); + Permissions.canchat, + Permissions.synclocalarea)); AddDefaultGroup("default", "guest", string.Join(",", diff --git a/TShockAPI/Permissions.cs b/TShockAPI/Permissions.cs index 322b1199..baf21a73 100644 --- a/TShockAPI/Permissions.cs +++ b/TShockAPI/Permissions.cs @@ -465,6 +465,9 @@ namespace TShockAPI [Description("Player can see advanced information about any user account.")] public static readonly string advaccountinfo = "tshock.accountinfo.details"; + + [Description("Player can resync themselves with server state.")] + public static readonly string synclocalarea = "tshock.synclocalarea"; #endregion /// /// Lists all commands associated with a given permission