New rule: interpret_move() is passed a pointer to the game_drawstate

basically just so that it can divide mouse coordinates by the tile
size, but is definitely not expected to _write_ to it, and it hadn't
previously occurred to me that anyone might try. Therefore,
interpret_move() now gets a pointer to a _const_ game_drawstate
instead of a writable one.

All existing puzzles cope fine with this API change (as long as the
new const qualifier is also added to a couple of subfunctions to which
interpret_move delegates work), except for the just-committed Undead,
which somehow had ds->ascii and ui->ascii the wrong way round but is
otherwise unproblematic.

[originally from svn r9657]
This commit is contained in:
Simon Tatham
2012-09-09 18:40:12 +00:00
parent 55748a60cb
commit 3b250baa02
38 changed files with 59 additions and 49 deletions

View File

@ -856,7 +856,7 @@ producing new \c{game_state}s.
\S{backend-interpret-move} \cw{interpret_move()}
\c char *(*interpret_move)(game_state *state, game_ui *ui,
\c game_drawstate *ds,
\c const game_drawstate *ds,
\c int x, int y, int button);
This function receives user input and processes it. Its input
@ -868,6 +868,11 @@ indicating an arrow or function key or a mouse event; when
coordinates of the mouse pointer relative to the top left of the
puzzle's drawing area.
(The pointer to the \c{game_drawstate} is marked \c{const}, because
\c{interpret_move} should not write to it. The normal use of that
pointer will be to read the game's tile size parameter in order to
divide mouse coordinates by it.)
\cw{interpret_move()} may return in three different ways:
\b Returning \cw{NULL} indicates that no action whatsoever occurred