]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix nearest beacon messages reporting the opposite direction (#28869)
authorTayrtahn <tayrtahn@gmail.com>
Tue, 11 Jun 2024 22:18:30 +0000 (18:18 -0400)
committerGitHub <noreply@github.com>
Tue, 11 Jun 2024 22:18:30 +0000 (18:18 -0400)
* Fix nearest beacon messages reporting the opposite direction

* Lets document that method, shall we?

Content.Server/Pinpointer/NavMapSystem.cs

index 424b6427de4bd8c1c1417fd810240c064e3bfbc5..da9ab20a39abc7315beb6ddebf69859cc1cdca7f 100644 (file)
@@ -431,6 +431,10 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
         return beacon != null;
     }
 
+    /// <summary>
+    /// Returns a string describing the rough distance and direction
+    /// to the position of <paramref name="ent"/> from the nearest beacon.
+    /// </summary>
     [PublicAPI]
     public string GetNearestBeaconString(Entity<TransformComponent?> ent)
     {
@@ -440,6 +444,11 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
         return GetNearestBeaconString(_transformSystem.GetMapCoordinates(ent, ent.Comp));
     }
 
+    /// <summary>
+    /// Returns a string describing the rough distance and direction
+    /// to <paramref name="coordinates"/> from the nearest beacon.
+    /// </summary>
+
     public string GetNearestBeaconString(MapCoordinates coordinates)
     {
         if (!TryGetNearestBeacon(coordinates, out var beacon, out var pos))
@@ -451,10 +460,11 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
 
         // get the angle between the two positions, adjusted for the grid rotation so that
         // we properly preserve north in relation to the grid.
-        var dir = (pos.Value.Position - coordinates.Position).ToWorldAngle();
+        var offset = coordinates.Position - pos.Value.Position;
+        var dir = offset.ToWorldAngle();
         var adjustedDir = (dir - gridOffset).GetDir();
 
-        var length = (pos.Value.Position - coordinates.Position).Length();
+        var length = offset.Length();
         if (length < CloseDistance)
         {
             return Loc.GetString("nav-beacon-pos-format",