Skip to content

Commit

Permalink
Fix: Core: PathingAPI: When GET MapRoute called be sure to dont overw…
Browse files Browse the repository at this point in the history
…rite the Path.locations with World coordinates!
  • Loading branch information
Xian55 committed Jan 19, 2025
1 parent 94a2159 commit 517dcc6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions PathingAPI/Controllers/PPatherController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using SharedLib.Data;

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Numerics;
using System.Text.Json;
Expand Down Expand Up @@ -70,12 +71,16 @@ public JsonResult MapRoute(int uimap1, float x1, float y1, int uimap2, float x2,

service.Save();

ArrayPool<Vector3> pool = ArrayPool<Vector3>.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<Vector3>(array, 0, path.locations.Count), options);
}

/// <summary>
Expand Down

0 comments on commit 517dcc6

Please sign in to comment.