From 517dcc66520ba5a41cc2d0ee734b464f775b3278 Mon Sep 17 00:00:00 2001 From: Xian55 <367101+Xian55@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:34:17 +0100 Subject: [PATCH] Fix: Core: PathingAPI: When GET MapRoute called be sure to dont overwrite the Path.locations with World coordinates! --- PathingAPI/Controllers/PPatherController.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PathingAPI/Controllers/PPatherController.cs b/PathingAPI/Controllers/PPatherController.cs index d44e4726..67e45e70 100644 --- a/PathingAPI/Controllers/PPatherController.cs +++ b/PathingAPI/Controllers/PPatherController.cs @@ -10,6 +10,7 @@ using SharedLib.Data; using System; +using System.Buffers; using System.Collections.Generic; using System.Numerics; using System.Text.Json; @@ -70,12 +71,16 @@ public JsonResult MapRoute(int uimap1, float x1, float y1, int uimap2, float x2, service.Save(); + ArrayPool pool = ArrayPool.Shared; + var array = pool.Rent(path.locations.Count); + for (int i = 0; i < path.locations.Count; i++) { - path.locations[i] = service.ToLocal(path.locations[i], (int)service.SearchFrom.W, uimap1); + array[i] = service.ToLocal(path.locations[i], (int)service.SearchFrom.W, uimap1); } - return new JsonResult(path.locations, options); + pool.Return(array); + return new JsonResult(new ArraySegment(array, 0, path.locations.Count), options); } ///