+ return me->ourgame->wants_statusbar();
+}
+
+config_item *midend_get_config(midend_data *me, int which, char **wintitle)
+{
+ char *titlebuf, *parstr;
+ config_item *ret;
+
+ titlebuf = snewn(40 + strlen(me->ourgame->name), char);
+
+ switch (which) {
+ case CFG_SETTINGS:
+ sprintf(titlebuf, "%s configuration", me->ourgame->name);
+ *wintitle = dupstr(titlebuf);
+ return me->ourgame->configure(me->params);
+ case CFG_SEED:
+ case CFG_DESC:
+ sprintf(titlebuf, "%s %s selection", me->ourgame->name,
+ which == CFG_SEED ? "random" : "game");
+ *wintitle = dupstr(titlebuf);
+
+ ret = snewn(2, config_item);
+
+ ret[0].type = C_STRING;
+ if (which == CFG_SEED)
+ ret[0].name = "Game random seed";
+ else
+ ret[0].name = "Game ID";
+ ret[0].ival = 0;
+ /*
+ * For CFG_DESC the text going in here will be a string
+ * encoding of the restricted parameters, plus a colon,
+ * plus the game description. For CFG_SEED it will be the
+ * full parameters, plus a hash, plus the random seed data.
+ * Either of these is a valid full game ID (although only
+ * the former is likely to persist across many code
+ * changes).
+ */
+ parstr = me->ourgame->encode_params(me->curparams, which == CFG_SEED);
+ if (which == CFG_DESC) {
+ ret[0].sval = snewn(strlen(parstr) + strlen(me->desc) + 2, char);
+ sprintf(ret[0].sval, "%s:%s", parstr, me->desc);
+ } else if (me->seedstr) {
+ ret[0].sval = snewn(strlen(parstr) + strlen(me->seedstr) + 2, char);
+ sprintf(ret[0].sval, "%s#%s", parstr, me->seedstr);
+ } else {
+ /*
+ * If the current game was not randomly generated, the
+ * best we can do is to give a template for typing a
+ * new seed in.
+ */
+ ret[0].sval = snewn(strlen(parstr) + 2, char);
+ sprintf(ret[0].sval, "%s#", parstr);
+ }
+ sfree(parstr);
+
+ ret[1].type = C_END;
+ ret[1].name = ret[1].sval = NULL;
+ ret[1].ival = 0;
+
+ return ret;
+ }
+
+ assert(!"We shouldn't be here");
+ return NULL;
+}
+
+static char *midend_game_id_int(midend_data *me, char *id, int defmode)
+{
+ char *error, *par, *desc, *seed;
+
+ seed = strchr(id, '#');
+ desc = strchr(id, ':');
+
+ if (desc && (!seed || desc < seed)) {
+ /*
+ * We have a colon separating parameters from game
+ * description. So `par' now points to the parameters
+ * string, and `desc' to the description string.
+ */
+ *desc++ = '\0';
+ par = id;
+ seed = NULL;
+ } else if (seed && (!desc || seed < desc)) {
+ /*
+ * We have a hash separating parameters from random seed.
+ * So `par' now points to the parameters string, and `seed'
+ * to the seed string.
+ */
+ *seed++ = '\0';
+ par = id;
+ desc = NULL;
+ } else {
+ /*
+ * We only have one string. Depending on `defmode', we take
+ * it to be either parameters, seed or description.
+ */
+ if (defmode == DEF_SEED) {
+ seed = id;
+ par = desc = NULL;
+ } else if (defmode == DEF_DESC) {
+ desc = id;
+ par = seed = NULL;
+ } else {
+ par = id;
+ seed = desc = NULL;
+ }
+ }
+
+ if (par) {
+ game_params *tmpparams;
+ tmpparams = me->ourgame->dup_params(me->params);
+ me->ourgame->decode_params(tmpparams, par);
+ error = me->ourgame->validate_params(tmpparams);
+ if (error) {
+ me->ourgame->free_params(tmpparams);
+ return error;
+ }
+ if (me->curparams)
+ me->ourgame->free_params(me->curparams);
+ me->curparams = tmpparams;
+
+ /*
+ * Now filter only the persistent parts of this state into
+ * the long-term params structure, unless we've _only_
+ * received a params string in which case the whole lot is
+ * persistent.
+ */
+ if (seed || desc) {
+ char *tmpstr = me->ourgame->encode_params(tmpparams, FALSE);
+ me->ourgame->decode_params(me->params, tmpstr);
+ sfree(tmpstr);
+ } else {
+ me->ourgame->free_params(me->params);
+ me->params = me->ourgame->dup_params(tmpparams);
+ }
+ }
+
+ sfree(me->desc);
+ me->desc = NULL;
+ sfree(me->seedstr);
+ me->seedstr = NULL;
+
+ if (desc) {
+ error = me->ourgame->validate_desc(me->params, desc);
+ if (error)
+ return error;
+
+ me->desc = dupstr(desc);
+ me->genmode = GOT_DESC;
+ if (me->aux_info)
+ me->ourgame->free_aux_info(me->aux_info);
+ me->aux_info = NULL;
+ }
+
+ if (seed) {
+ me->seedstr = dupstr(seed);
+ me->genmode = GOT_SEED;
+ }
+
+ return NULL;