mirror of
https://github.com/renorris/openfsd
synced 2026-04-21 10:45:31 +08:00
only do velocity distance calculation for relevant clients
This commit is contained in:
@@ -165,6 +165,7 @@ func (s *Server) handlePilotPosition(client *Client, packet []byte) {
|
|||||||
client.lastUpdated.Store(time.Now())
|
client.lastUpdated.Store(time.Now())
|
||||||
|
|
||||||
// Check if we need to update the sendfast state
|
// Check if we need to update the sendfast state
|
||||||
|
if client.protoRevision == 101 {
|
||||||
if client.sendFastEnabled {
|
if client.sendFastEnabled {
|
||||||
if (client.closestVelocityClientDistance / 1852.0) > 5.0 { // 5.0 nautical miles
|
if (client.closestVelocityClientDistance / 1852.0) > 5.0 { // 5.0 nautical miles
|
||||||
client.sendFastEnabled = false
|
client.sendFastEnabled = false
|
||||||
@@ -177,6 +178,7 @@ func (s *Server) handlePilotPosition(client *Client, packet []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleFastPilotPosition handles logic for fast `^`, stopped `#ST`, and slow `#SL` pilot position updates
|
// handleFastPilotPosition handles logic for fast `^`, stopped `#ST`, and slow `#SL` pilot position updates
|
||||||
func (s *Server) handleFastPilotPosition(client *Client, packet []byte) {
|
func (s *Server) handleFastPilotPosition(client *Client, packet []byte) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func (p *postOffice) search(client *Client, callback func(recipient *Client) boo
|
|||||||
return true // Ignore self
|
return true // Ignore self
|
||||||
}
|
}
|
||||||
|
|
||||||
if foundClient.protoRevision == 101 {
|
if !client.isAtc && client.protoRevision == 101 && foundClient.protoRevision == 101 {
|
||||||
clientLatLon := client.latLon()
|
clientLatLon := client.latLon()
|
||||||
foundClientLatLon := foundClient.latLon()
|
foundClientLatLon := foundClient.latLon()
|
||||||
dist := distance(clientLatLon[0], clientLatLon[1], foundClientLatLon[0], foundClientLatLon[1])
|
dist := distance(clientLatLon[0], clientLatLon[1], foundClientLatLon[0], foundClientLatLon[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user