mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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]
This commit is contained in:
43
midend.c
43
midend.c
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user