chiark / gitweb /
Fix bounds checking for Flip cursor control.
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 4 Jul 2005 11:21:50 +0000 (11:21 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 4 Jul 2005 11:21:50 +0000 (11:21 +0000)
[originally from svn r6050]

flip.c

diff --git a/flip.c b/flip.c
index f1fcaf6c1d138fbd1aca2bf9ed0d9fb206fbe6e5..503681e887e015c84adebe35a37d36e8fd9a4300 100644 (file)
--- a/flip.c
+++ b/flip.c
@@ -928,8 +928,8 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
         default: assert(!"shouldn't get here");
         }
         ui->cx += dx; ui->cy += dy;
-        ui->cx = min(max(ui->cx, 0), state->w);
-        ui->cy = min(max(ui->cy, 0), state->h);
+        ui->cx = min(max(ui->cx, 0), state->w - 1);
+        ui->cy = min(max(ui->cy, 0), state->h - 1);
         ui->cdraw = 1;
         nullret = "";
     }