shithub: puzzles

Download patch

ref: 2b6c6dce34b9867fd18faed4ca9be6caf4e45bf5
parent: df31bc7a515a56b2322a097bda8f1aa510a7b9da
author: Ben Harris <bjh21@bjh21.me.uk>
date: Wed Aug 9 16:34:50 EDT 2023

Flood: use move_cursor() for cursor movement

--- a/flood.c
+++ b/flood.c
@@ -835,22 +835,9 @@
 	tx = FROMCOORD(x);
         ty = FROMCOORD(y);
         ui->cursor_visible = false;
-    } else if (button == CURSOR_LEFT && ui->cx > 0) {
-        ui->cx--;
-        ui->cursor_visible = true;
-        return MOVE_UI_UPDATE;
-    } else if (button == CURSOR_RIGHT && ui->cx+1 < w) {
-        ui->cx++;
-        ui->cursor_visible = true;
-        return MOVE_UI_UPDATE;
-    } else if (button == CURSOR_UP && ui->cy > 0) {
-        ui->cy--;
-        ui->cursor_visible = true;
-        return MOVE_UI_UPDATE;
-    } else if (button == CURSOR_DOWN && ui->cy+1 < h) {
-        ui->cy++;
-        ui->cursor_visible = true;
-        return MOVE_UI_UPDATE;
+    } else if (IS_CURSOR_MOVE(button)) {
+        return move_cursor(button, &ui->cx, &ui->cy, w, h, false,
+                           &ui->cursor_visible);
     } else if (button == CURSOR_SELECT) {
         tx = ui->cx;
         ty = ui->cy;