From 42a8b315e5f7db5a35c0ffc8952c05a264e1ab82 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 16 Aug 2008 14:57:13 -0400 Subject: [PATCH] Fix deltx() for x < r->lx && r->lx < r->hx; likewise delty() Bug couldn't bite, because callers pass only coordinates within the interval. --- src/lib/subs/radmap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/subs/radmap.c b/src/lib/subs/radmap.c index 0ab3c12b..04857823 100644 --- a/src/lib/subs/radmap.c +++ b/src/lib/subs/radmap.c @@ -189,26 +189,28 @@ radmap2(int owner, pr("\n"); } +/* + * Return distance from left edge of R to X. + * Value is between 0 (inclusive) and WORLD_X (exclusive). + * X must be normalized. + */ int deltx(struct range *r, coord x) { - if (r->lx < r->hx) - return x - r->lx; - if (x >= r->lx) return x - r->lx; - return x + WORLD_X - r->lx; } +/* + * Return distance from top edge of R to Y. + * Value is between 0 (inclusive) and WORLD_Y (exclusive). + * Y must be normalized. + */ int delty(struct range *r, coord y) { - if (r->ly < r->hy) - return y - r->ly; - if (y >= r->ly) return y - r->ly; - return y + WORLD_Y - r->ly; }