From f63d89eb3e372ec158355ccfc9461514a539b08c Mon Sep 17 00:00:00 2001 From: Reese Norris Date: Sun, 25 May 2025 14:27:07 -0700 Subject: [PATCH] only do velocity distance calculation for relevant clients --- fsd/handler.go | 20 +++++++++++--------- fsd/postoffice.go | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fsd/handler.go b/fsd/handler.go index cc221ca..55deb06 100644 --- a/fsd/handler.go +++ b/fsd/handler.go @@ -165,15 +165,17 @@ func (s *Server) handlePilotPosition(client *Client, packet []byte) { client.lastUpdated.Store(time.Now()) // Check if we need to update the sendfast state - if client.sendFastEnabled { - if (client.closestVelocityClientDistance / 1852.0) > 5.0 { // 5.0 nautical miles - client.sendFastEnabled = false - sendDisableSendFastPacket(client) - } - } else { - if (client.closestVelocityClientDistance / 1852.0) < 5.0 { // 5.0 nautical miles - client.sendFastEnabled = true - sendEnableSendFastPacket(client) + if client.protoRevision == 101 { + if client.sendFastEnabled { + if (client.closestVelocityClientDistance / 1852.0) > 5.0 { // 5.0 nautical miles + client.sendFastEnabled = false + sendDisableSendFastPacket(client) + } + } else { + if (client.closestVelocityClientDistance / 1852.0) < 5.0 { // 5.0 nautical miles + client.sendFastEnabled = true + sendEnableSendFastPacket(client) + } } } } diff --git a/fsd/postoffice.go b/fsd/postoffice.go index 5b4d6c7..5441355 100644 --- a/fsd/postoffice.go +++ b/fsd/postoffice.go @@ -98,7 +98,7 @@ func (p *postOffice) search(client *Client, callback func(recipient *Client) boo return true // Ignore self } - if foundClient.protoRevision == 101 { + if !client.isAtc && client.protoRevision == 101 && foundClient.protoRevision == 101 { clientLatLon := client.latLon() foundClientLatLon := foundClient.latLon() dist := distance(clientLatLon[0], clientLatLon[1], foundClientLatLon[0], foundClientLatLon[1])