From c376e695184ec53f3d0a7e0966aad1bfa2eee013 Mon Sep 17 00:00:00 2001 From: Perry Fraser Date: Fri, 1 Aug 2025 17:48:40 -0400 Subject: [PATCH] Fix tabletop grids rarely spawning on top of another (#39327) * fix: fix off-by-one for tabletop map positions Ulam spirals start at 1, not 0. * fix: make the ulam spiral a ulam spiral --- Content.Server/Tabletop/TabletopSystem.Map.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Tabletop/TabletopSystem.Map.cs b/Content.Server/Tabletop/TabletopSystem.Map.cs index 5e116d81ef..89563ec6bf 100644 --- a/Content.Server/Tabletop/TabletopSystem.Map.cs +++ b/Content.Server/Tabletop/TabletopSystem.Map.cs @@ -37,7 +37,7 @@ namespace Content.Server.Tabletop /// private Vector2 GetNextTabletopPosition() { - return UlamSpiral(_tabletops++) * TabletopSeparation; + return UlamSpiral(++_tabletops) * TabletopSeparation; } /// @@ -62,11 +62,11 @@ namespace Content.Server.Tabletop /// /// Algorithm for mapping scalars to 2D positions in the same pattern as an Ulam Spiral. /// - /// Scalar to map to a 2D position. + /// Scalar to map to a 2D position. Must be greater than or equal to 1. /// The mapped 2D position for the scalar. private Vector2i UlamSpiral(int n) { - var k = (int)MathF.Ceiling(MathF.Sqrt(n) - 1) / 2; + var k = (int)MathF.Ceiling((MathF.Sqrt(n) - 1) / 2); var t = 2 * k + 1; var m = (int)MathF.Pow(t, 2); t--;