X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fkernel%2Fao_distance.c;h=481a53c11c5bbdc14b8392895d221d90d7204368;hp=ba7d59fea6c1ea44c2afc1a75e3ec090a7ac4515;hb=1085ec5d57e0ed5d132f2bbdac1a0b6a32c0ab4a;hpb=6e152dd5c0786a650aed8f0c09babdc93895bff1 diff --git a/src/kernel/ao_distance.c b/src/kernel/ao_distance.c index ba7d59fe..481a53c1 100644 --- a/src/kernel/ao_distance.c +++ b/src/kernel/ao_distance.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,6 +25,7 @@ ao_dist(int32_t a, int32_t b) int32_t d = a - b; if (d < 0) d = -d; + return (uint32_t) ((int64_t) d * 111198 / 10000000); } @@ -98,7 +100,7 @@ ao_lon_dist(int32_t lon_a, int32_t lon_b) uint32_t lon_dist; /* check if it's shorter to go the other way around */ - if (lon_a < lon_b - 1800000000) + if ((lon_a >> 1) < (lon_b >> 1) - (1800000000 >> 1)) lon_a += 3600000000; lon_dist = ao_dist(lon_a, lon_b); if (c) {