From: Markus Armbruster Date: Mon, 12 May 2008 16:45:11 +0000 (+0200) Subject: Fix XNORM() and YNORM() X-Git-Tag: v4.3.15~16 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=7680acc39fd63684c6854f27e99a2a5e18712473 Fix XNORM() and YNORM() Broken in commit 5f764285 (v4.3.12) for negative multiples of WORLD_X and WORLD_Y, respectively. This could theoretically lead to buffer overruns and other unpleasantness. None have been reproduced, though. --- diff --git a/include/xy.h b/include/xy.h index 9f1f06c21..574c1b679 100644 --- a/include/xy.h +++ b/include/xy.h @@ -43,9 +43,9 @@ #define XYOFFSET(x, y) (((y) * WORLD_X + (x)) / 2) #define XNORM(x) \ - (((x) < 0) ? (WORLD_X - (-(x) % WORLD_X)) : ((x) % WORLD_X)) + (((x) < 0) ? (WORLD_X - 1 - ((-(x) - 1) % WORLD_X)) : ((x) % WORLD_X)) #define YNORM(y) \ - (((y) < 0) ? (WORLD_Y - (-(y) % WORLD_Y)) : ((y) % WORLD_Y)) + (((y) < 0) ? (WORLD_Y - 1 - ((-(y) - 1) % WORLD_Y)) : ((y) % WORLD_Y)) struct range { coord lx; /* low-range x,y */