mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(flights): keep ground-snap sampling after the clock steps back (#1399)
Recover aircraft ground-height sampling after backward wall-clock changes while preserving sampling budgets. Contribution by @quanticsoul4772.
This commit is contained in:
1 parent
a7da90fdfc
commit
ba292ce475
4 files changed
+82
-2
No files matched your search
@@ -307,10 +307,20 @@ export function createGroundSnap({ groundFloor }) {
|
||||
}
|
||||
const now = Date.now();
|
||||
const entry = entries.get(icao);
|
||||
if (entry && now < entry.nextRetryMs) return heldSnapM(entry, surfacePos); // backoff in force
|
||||
// Backoff in force, unless it ends further off than any backoff can:
|
||||
// a retry stamped before the clock stepped back would otherwise wait for
|
||||
// the clock to catch up.
|
||||
if (
|
||||
entry &&
|
||||
now < entry.nextRetryMs &&
|
||||
entry.nextRetryMs - now <= RETRY_MAX_MS
|
||||
)
|
||||
return heldSnapM(entry, surfacePos);
|
||||
// Per-window budget: deny WITHOUT a retry stamp so the overflow simply
|
||||
// tries again next tick instead of waiting out a backoff it didn't earn.
|
||||
if (now - windowStartMs > SAMPLE_WINDOW_MS) {
|
||||
// A clock that stepped back also opens a new window, or none would open
|
||||
// until it caught up.
|
||||
if (now < windowStartMs || now - windowStartMs > SAMPLE_WINDOW_MS) {
|
||||
windowStartMs = now;
|
||||
windowCount = 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user