ref: 85a29743ef113cd26448e4e4cd04c7a34ce4fdd1
parent: 64e114cce121e55f0f90cb5692c5020d917aa202
author: Simon Tatham <anakin@pobox.com>
date: Sun Jul 3 07:45:49 EDT 2005
Allow game backends to use even special keystrokes such as N and Q; they will only be processed as special by the midend if unwanted by the backend. This causes 5x5 Solo to become just about playable, because you can now click in a square and type `n'. However, typing `n' when a square is not selected will revert to the normal behaviour of starting a new game. (This isn't particularly ideal, I know, but it's better than nothing.) [originally from svn r6048]
--- a/midend.c
+++ b/midend.c
@@ -387,37 +387,38 @@
me->ourgame->dup_game(me->states[me->statepos - 1].state);
int special = FALSE, gotspecial = FALSE, ret = 1;
float anim_time;
+ game_state *s;
+ char *movestr;
+
+ movestr =
+ me->ourgame->interpret_move(me->states[me->statepos-1].state,
+ me->ui, me->drawstate, x, y, button);
- if (button == 'n' || button == 'N' || button == '\x0E') {
- midend_stop_anim(me);
- midend_new_game(me);
- midend_redraw(me);
- goto done; /* never animate */
- } else if (button == 'u' || button == 'u' ||
- button == '\x1A' || button == '\x1F') {
- midend_stop_anim(me);
- special = special(me->states[me->statepos-1].movetype);
- gotspecial = TRUE;
- if (!midend_undo(me))
+ if (!movestr) {
+ if (button == 'n' || button == 'N' || button == '\x0E') {
+ midend_stop_anim(me);
+ midend_new_game(me);
+ midend_redraw(me);
+ goto done; /* never animate */
+ } else if (button == 'u' || button == 'u' ||
+ button == '\x1A' || button == '\x1F') {
+ midend_stop_anim(me);
+ special = special(me->states[me->statepos-1].movetype);
+ gotspecial = TRUE;
+ if (!midend_undo(me))
+ goto done;
+ } else if (button == 'r' || button == 'R' ||
+ button == '\x12' || button == '\x19') {
+ midend_stop_anim(me);
+ if (!midend_redo(me))
+ goto done;
+ } else if (button == 'q' || button == 'Q' || button == '\x11') {
+ ret = 0;
goto done;
- } else if (button == 'r' || button == 'R' ||
- button == '\x12' || button == '\x19') {
- midend_stop_anim(me);
- if (!midend_redo(me))
- goto done;
- } else if (button == 'q' || button == 'Q' || button == '\x11') {
- ret = 0;
- goto done;
+ } else
+ goto done;
} else {
- game_state *s;
- char *movestr;
-
- movestr =
- me->ourgame->interpret_move(me->states[me->statepos-1].state,
- me->ui, me->drawstate, x, y, button);
- if (!movestr)
- s = NULL;
- else if (!*movestr)
+ if (!*movestr)
s = me->states[me->statepos-1].state;
else {
s = me->ourgame->execute_move(me->states[me->statepos-1].state,