diff options
| author | Simon Tatham <anakin@pobox.com> | 2013-03-30 16:59:19 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2013-03-30 16:59:19 +0000 |
| commit | e6026d9d8e7864c4d0f1eeba53c33d430ac36dfd (patch) | |
| tree | 333bf095a29c1b7031823e439c1004035d521490 | |
| parent | 1fdafb6abf2d3ea0d37e79b5dfd9daf8eed28f22 (diff) | |
| download | puzzles-e6026d9d8e7864c4d0f1eeba53c33d430ac36dfd.zip puzzles-e6026d9d8e7864c4d0f1eeba53c33d430ac36dfd.tar.gz puzzles-e6026d9d8e7864c4d0f1eeba53c33d430ac36dfd.tar.bz2 puzzles-e6026d9d8e7864c4d0f1eeba53c33d430ac36dfd.tar.xz | |
Add a midend function to return the current random seed, parallel to
the existing one that returns the game id. No front end has so far
needed this, but one is about to.
[originally from svn r9778]
| -rw-r--r-- | devel.but | 11 | ||||
| -rw-r--r-- | midend.c | 15 | ||||
| -rw-r--r-- | puzzles.h | 1 |
3 files changed, 27 insertions, 0 deletions
@@ -3091,6 +3091,17 @@ Returns a descriptive game ID (i.e. one in the form \cq{params:description}) describing the game currently active in the mid-end. The returned string is dynamically allocated. +\H{midend-get-random-seed} \cw{midend_get_random_seed()} + +\c char *midend_get_random_seed(midend *me) + +Returns a random game ID (i.e. one in the form \cq{params#seedstring}) +describing the game currently active in the mid-end, if there is one. +If the game was created by entering a description, no random seed will +currently exist and this function will return \cw{NULL}. + +The returned string, if it is non-\cw{NULL}, is dynamically allocated. + \H{midend-can-format-as-text-now} \cw{midend_can_format_as_text_now()} \c int midend_can_format_as_text_now(midend *me); @@ -1304,6 +1304,21 @@ char *midend_get_game_id(midend *me) return ret; } +char *midend_get_random_seed(midend *me) +{ + char *parstr, *ret; + + if (!me->seedstr) + return NULL; + + parstr = me->ourgame->encode_params(me->curparams, TRUE); + assert(parstr); + ret = snewn(strlen(parstr) + strlen(me->seedstr) + 2, char); + sprintf(ret, "%s#%s", parstr, me->seedstr); + sfree(parstr); + return ret; +} + char *midend_set_config(midend *me, int which, config_item *cfg) { char *error; @@ -251,6 +251,7 @@ config_item *midend_get_config(midend *me, int which, char **wintitle); char *midend_set_config(midend *me, int which, config_item *cfg); char *midend_game_id(midend *me, char *id); char *midend_get_game_id(midend *me); +char *midend_get_random_seed(midend *me); int midend_can_format_as_text_now(midend *me); char *midend_text_format(midend *me); char *midend_solve(midend *me); |