diff options
| author | Simon Tatham <anakin@pobox.com> | 2013-04-07 10:24:35 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2013-04-07 10:24:35 +0000 |
| commit | c55e95485483f8a5b66ab4af3a372495d88389ee (patch) | |
| tree | f10b87ec70d99130039b0e241598f565322b6796 /midend.c | |
| parent | ea25b606cbadaf573b71b132c0d2d5081c8516ab (diff) | |
| download | puzzles-c55e95485483f8a5b66ab4af3a372495d88389ee.zip puzzles-c55e95485483f8a5b66ab4af3a372495d88389ee.tar.gz puzzles-c55e95485483f8a5b66ab4af3a372495d88389ee.tar.bz2 puzzles-c55e95485483f8a5b66ab4af3a372495d88389ee.tar.xz | |
Add a new midend function to reset the tile size to the puzzle's
default (but still counting the <puzzle>_TILESIZE user preference
environment variables, where available).
[originally from svn r9820]
Diffstat (limited to 'midend.c')
| -rw-r--r-- | midend.c | 43 |
1 files changed, 24 insertions, 19 deletions
@@ -94,6 +94,29 @@ struct midend { } \ } while (0) +void midend_reset_tilesize(midend *me) +{ + me->preferred_tilesize = me->ourgame->preferred_tilesize; + { + /* + * Allow an environment-based override for the default tile + * size by defining a variable along the lines of + * `NET_TILESIZE=15'. + */ + + char buf[80], *e; + int j, k, ts; + + sprintf(buf, "%s_TILESIZE", me->ourgame->name); + for (j = k = 0; buf[j]; j++) + if (!isspace((unsigned char)buf[j])) + buf[k++] = toupper((unsigned char)buf[j]); + buf[k] = '\0'; + if ((e = getenv(buf)) != NULL && sscanf(e, "%d", &ts) == 1 && ts > 0) + me->preferred_tilesize = ts; + } +} + midend *midend_new(frontend *fe, const game *ourgame, const drawing_api *drapi, void *drhandle) { @@ -153,25 +176,7 @@ midend *midend_new(frontend *fe, const game *ourgame, else me->drawing = NULL; - me->preferred_tilesize = ourgame->preferred_tilesize; - { - /* - * Allow an environment-based override for the default tile - * size by defining a variable along the lines of - * `NET_TILESIZE=15'. - */ - - char buf[80], *e; - int j, k, ts; - - sprintf(buf, "%s_TILESIZE", me->ourgame->name); - for (j = k = 0; buf[j]; j++) - if (!isspace((unsigned char)buf[j])) - buf[k++] = toupper((unsigned char)buf[j]); - buf[k] = '\0'; - if ((e = getenv(buf)) != NULL && sscanf(e, "%d", &ts) == 1 && ts > 0) - me->preferred_tilesize = ts; - } + midend_reset_tilesize(me); sfree(randseed); |