shithub: puzzles

Download patch

ref: 7e9228f15472ed1d9a691ac9b41ae52436e10cdf
parent: 785de41a92dcd45a71c322bafa8af737bb1eb7aa
author: Ben Harris <bjh21@bjh21.me.uk>
date: Wed Aug 9 10:32:31 EDT 2023

Use move_cursor() for cursor movement in Same Game

No significant behavioural change.

--- a/samegame.c
+++ b/samegame.c
@@ -1285,13 +1285,9 @@
         ui->displaysel = false;
 	tx = FROMCOORD(x); ty= FROMCOORD(y);
     } else if (IS_CURSOR_MOVE(button)) {
-	int dx = 0, dy = 0;
-	ui->displaysel = true;
-	dx = (button == CURSOR_LEFT) ? -1 : ((button == CURSOR_RIGHT) ? +1 : 0);
-	dy = (button == CURSOR_DOWN) ? +1 : ((button == CURSOR_UP)    ? -1 : 0);
-	ui->xsel = (ui->xsel + state->params.w + dx) % state->params.w;
-	ui->ysel = (ui->ysel + state->params.h + dy) % state->params.h;
-	return ret;
+        return move_cursor(button, &ui->xsel, &ui->ysel,
+                           state->params.w, state->params.h,
+                           true, &ui->displaysel);
     } else if (IS_CURSOR_SELECT(button)) {
 	ui->displaysel = true;
 	tx = ui->xsel;