Skip to content

Commit

Permalink
No duplicates in gps calculation.
Browse files Browse the repository at this point in the history
Also update distance to latest known to partially decrease cc-tweaked#901 effect.
  • Loading branch information
Wojbie committed Feb 18, 2023
1 parent 4e909bc commit 5cce6fc
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,17 @@ function locate(_nTimeout, _bDebug)
if tFix.nDistance == 0 then
pos1, pos2 = tFix.vPosition, nil
else
table.insert(tFixes, tFix)
local duplicate = false
for _,older in pairs(tFixes) do
if older.vPosition:equals(tFix.vPosition) then
older.nDistance = tFix.nDistance
duplicate = true
break
end
end
if not duplicate then
table.insert(tFixes, tFix)
end
if #tFixes >= 3 then
if not pos1 then
pos1, pos2 = trilaterate(tFixes[1], tFixes[2], tFixes[#tFixes])
Expand Down

0 comments on commit 5cce6fc

Please sign in to comment.