aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-09-12 12:38:58 +0000
committerSimon Tatham <anakin@pobox.com>2005-09-12 12:38:58 +0000
commitf07576f49e9b08c9a9b2482b07e14a3e846224eb (patch)
treee6ca594752839f645fd8e5a2bd5d132584892215 /midend.c
parentf71630073f1abbcb16f65807846cdeb608163a70 (diff)
downloadpuzzles-f07576f49e9b08c9a9b2482b07e14a3e846224eb.zip
puzzles-f07576f49e9b08c9a9b2482b07e14a3e846224eb.tar.gz
puzzles-f07576f49e9b08c9a9b2482b07e14a3e846224eb.tar.bz2
puzzles-f07576f49e9b08c9a9b2482b07e14a3e846224eb.tar.xz
I found a slightly odd-looking line of code in this file a few days
ago, and nearly changed it to the obvious thing. After some thought, though, I've decided the `bug' is better off unfixed, and added a comment explaining why. [originally from svn r6293]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/midend.c b/midend.c
index cc360b5..833cbef 100644
--- a/midend.c
+++ b/midend.c
@@ -356,8 +356,24 @@ void midend_new_game(midend *me)
}
ensure(me);
+
+ /*
+ * It might seem a bit odd that we're using me->params to
+ * create the initial game state, rather than me->curparams
+ * which is better tailored to this specific game and which we
+ * always know.
+ *
+ * It's supposed to be an invariant in the midend that
+ * me->params and me->curparams differ in no aspect that is
+ * important after generation (i.e. after new_desc()). By
+ * deliberately passing the _less_ specific of these two
+ * parameter sets, we provoke play-time misbehaviour in the
+ * case where a game has failed to encode a play-time parameter
+ * in the non-full version of encode_params().
+ */
me->states[me->nstates].state =
me->ourgame->new_game(me, me->params, me->desc);
+
me->states[me->nstates].movestr = NULL;
me->states[me->nstates].movetype = NEWGAME;
me->nstates++;