aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-07-10 10:06:04 +0000
committerSimon Tatham <anakin@pobox.com>2005-07-10 10:06:04 +0000
commit145301d0dc5b75a89620ffe88bc8a890699eef59 (patch)
tree5c9dcee0d3157b1b64760a7909e199c51b35db56 /midend.c
parentac36314b021854a642593be87a99cad9b04333a5 (diff)
downloadpuzzles-145301d0dc5b75a89620ffe88bc8a890699eef59.zip
puzzles-145301d0dc5b75a89620ffe88bc8a890699eef59.tar.gz
puzzles-145301d0dc5b75a89620ffe88bc8a890699eef59.tar.bz2
puzzles-145301d0dc5b75a89620ffe88bc8a890699eef59.tar.xz
Change of policy on game_changed_state(). Originally, it was called
by the midend every time the game state changed _other_ than as a result of make_move(), on the basis that when the game state changed due to make_move() the game backend had probably noticed anyway. However, when make_move() split up, this became more fiddly: if the game_ui had to be updated based on some property of the final game state, then execute_move() couldn't do it because it didn't have a pointer to the game_ui, but it was fiddly to do it in interpret_move() because that didn't directly have a copy of the finished game state to examine. Same Game (the only game to be affected) had to deal with this by actually having interpret_move() _call_ execute_move() to construct a temporary new game state, update the UI, and then throw it away. So now, game_changed_state() is called _every_ time the current game state changes, which means that if anything needs doing to the game_ui as a result of examining the new game state, it can be done there and save a lot of effort. [originally from svn r6087]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/midend.c b/midend.c
index 691c643..b5ce237 100644
--- a/midend.c
+++ b/midend.c
@@ -491,6 +491,10 @@ static int midend_really_process_key(midend_data *me, int x, int y, int button)
me->states[me->nstates].movetype = MOVE;
me->statepos = ++me->nstates;
me->dir = +1;
+ if (me->ui)
+ me->ourgame->changed_state(me->ui,
+ me->states[me->statepos-2].state,
+ me->states[me->statepos-1].state);
} else {
goto done;
}