AP_Beacon: fix comparison order to prevent using wrong beacon_instance first

This commit is contained in:
Pierre Kancir 2021-08-11 00:35:43 +02:00 committed by Randy Mackay
parent a3c658ea01
commit ae59533af1
1 changed files with 1 additions and 1 deletions

View File

@ -214,7 +214,7 @@ bool AP_Beacon::beacon_healthy(uint8_t beacon_instance) const
// return distance to beacon in meters
float AP_Beacon::beacon_distance(uint8_t beacon_instance) const
{
if (!beacon_state[beacon_instance].healthy || beacon_instance >= num_beacons) {
if ( beacon_instance >= num_beacons || !beacon_state[beacon_instance].healthy) {
return 0.0f;
}
return beacon_state[beacon_instance].distance;