mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Blackbox: correct FROMDRAW() macro for C division semantics
Integer division in C rounds towards zero, so if you want it to consistently round down you need to ensure that the arguments are positive. FROMDRAW() didn't do that, so clicks off the top and left corners of the grid got treated as being in the top row or left column (row and column 0) rather than ignored. This commit fixes the macro so that it offsets its argument upward before the division and compensates afterwards.
This commit is contained in:
@ -905,7 +905,7 @@ done:
|
||||
#define TILE_SIZE (ds->tilesize)
|
||||
|
||||
#define TODRAW(x) ((TILE_SIZE * (x)) + (TILE_SIZE / 2))
|
||||
#define FROMDRAW(x) (((x) - (TILE_SIZE / 2)) / TILE_SIZE)
|
||||
#define FROMDRAW(x) (((x) + (TILE_SIZE / 2)) / TILE_SIZE - 1)
|
||||
|
||||
#define CAN_REVEAL(state) ((state)->nguesses >= (state)->minballs && \
|
||||
(state)->nguesses <= (state)->maxballs && \
|
||||
|
Reference in New Issue
Block a user