From 25a7e9e83aef1dc0b2e92dc680a8468bb429ab60 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 13 Jun 2021 00:14:32 -0700 Subject: [PATCH] Fix warp send nullcheck @punchready reported that there was an issue with the /warp send command checking for position != (0,0). I tried to figure out what was going on here, and I came up dry. I think this is vestigial from some other database or file format storage. When @MarioE converted everything to the new warp system, he preserved the check. The problem is that the check seems to be based on the idea that a non-existent warp would return the default constructor (which would contain Point.Zero). Instead, a warp not found returns a null now. Therefore, the proper thing to do, as implied by @punchready, is to simply nullcheck this value instead. --- CHANGELOG.md | 1 + TShockAPI/Commands.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1530cfdf..a421bafc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Changed the default respawn timer to 10 seconds, so as to not desynchronize from the game by default. (@hakusaro) * Fixed `/home` allowing players to bypass the respawn timer. (@hakusaro, @moisterrific, @Arthri) * Added the config option `SuppressPermissionFailureNotices`. When set to `true`, the server will not send warning messages to players when they fail a build permission check from `TSPlayer.HasBuildPermission` (even if `shouldWarnPlayer` is set to true. (@hakusaro) +* Fixed `/warp send` failing a nullcheck if the warp didn't exist. The previous behavior may have always been buggy or broken. In other words, sending someone to a warp that doesn't exist should result in a nicer error. (@hakusaro, @punchready) ## TShock 4.5.4 * Fixed ridiculous typo in `GetDataHandlers` which caused TShock to read the wrong field in the packet for `usingBiomeTorches`. (@hakusaro, @Arthri) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2a83350f..5ea9d5ee 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -3137,7 +3137,7 @@ namespace TShockAPI string warpName = args.Parameters[2]; var warp = TShock.Warps.Find(warpName); var plr = foundplr[0]; - if (warp.Position != Point.Zero) + if (warp != null) { if (plr.Teleport(warp.Position.X * 16, warp.Position.Y * 16)) {