Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

Commit 412e278

Browse files
authored
Merge pull request #17 from AlessioDP/jump-fix
Fix minimap jumps
2 parents e24aff1 + 17a08f9 commit 412e278

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/NewWorldMinimap/MapForm.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,32 @@ private void UpdateLoop()
174174
{
175175
Stopwatch sw = new Stopwatch();
176176

177+
Vector3 lastPos = Vector3.Zero;
178+
int jumpThreshold = int.MaxValue;
177179
int i = 0;
178180
while (true)
179181
{
180182
sw.Restart();
181183

182184
if (pd.TryGetPosition(ScreenGrabber.TakeScreenshot(currentScreen), out Vector3 pos))
183185
{
184-
Console.WriteLine($"{i}: {pos}");
186+
Vector3 difference = lastPos - pos;
187+
Console.WriteLine($"{i}: {pos} [{difference.Length()}]");
188+
if (difference.Length() > 20.0)
189+
{
190+
if (jumpThreshold < 3)
191+
{
192+
Console.WriteLine($"{i}: Failure due to jump of {difference.Length()}");
193+
jumpThreshold++;
194+
continue;
195+
}
196+
else
197+
{
198+
jumpThreshold = 0;
199+
}
200+
}
201+
202+
lastPos = pos;
185203
using Image<Rgba32> baseMap = map.GetTileForCoordinate(pos.X, pos.Y);
186204

187205
(int imageX, int imageY) = map.ToMinimapCoordinate(pos.X, pos.Y, pos.X, pos.Y);

0 commit comments

Comments
 (0)