diff options
Diffstat (limited to 'include/tak.c')
| -rw-r--r-- | include/tak.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/tak.c b/include/tak.c index dc402d4..57dacf7 100644 --- a/include/tak.c +++ b/include/tak.c @@ -151,8 +151,11 @@ try_move(const int8_t location, const enum MOVE_DIRECTION direction, }; case M_LEFT: { delta = -1; - if ((location + steps * delta) / board_size - < location / board_size) + // We need the extra check for zero here because, irritatingly, + // -1 / board_size == 1 / board_size + if ((location + steps * delta < 0) || + ((location + steps * delta) / board_size + < location / board_size)) return ACT_ILLEGAL; break; }; @@ -469,7 +472,7 @@ parse_move(const uint8_t board_size, char *ptn, // =================================================================== void -generate_place(const uint8_t board_size, const uint8_t in_location, +generate_place(const uint8_t in_location, const enum STONE_VARIANT in_stone, char out_ptn[4]) { switch (in_stone) { case STONE_FLAT: { break; } @@ -486,7 +489,7 @@ generate_place(const uint8_t board_size, const uint8_t in_location, // =================================================================== void -generate_move(const uint8_t board_size, const uint8_t in_location, +generate_move(const uint8_t in_location, const enum MOVE_DIRECTION in_direction, const uint8_t in_steps, const uint8_t in_drops[5], char out_ptn[10]) { |
