only do velocity distance calculation for relevant clients

This commit is contained in:
Reese Norris
2025-05-25 14:27:07 -07:00
parent bc7a37e490
commit f63d89eb3e
2 changed files with 12 additions and 10 deletions

View File

@@ -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)
}
}
}
}

View File

@@ -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])