From 4c394e385a17a023130077477b9881f00e621dbd Mon Sep 17 00:00:00 2001 From: cohrs Date: Sat, 2 Feb 2002 02:58:07 +0000 Subject: [PATCH] SPLEVTYPE debug mode environment variable SPLEVTYPE can have a value like "minetn-3,minend-2,soko2-2" and allows someone in debug mode to select specific instances of random levels to use in a test game. Invalid values found in SPLEVTYPE are silently ignored. --- src/mkmaze.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mkmaze.c b/src/mkmaze.c index 82bc2787c..1d54da23e 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -511,6 +511,30 @@ register const char *s; } else Strcpy(protofile, ""); +#ifdef WIZARD + /* SPLEVTYPE format is "level-choice,level-choice"... */ + if (wizard && *protofile && sp && sp->rndlevs) { + char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */ + if (ep) { + /* rindex always succeeds due to code in prior block */ + int len = (rindex(protofile, '-') - protofile) + 1; + + while (*ep) { + if (!strncmp(ep, protofile, len)) { + int pick = atoi(ep + len); + /* use choice only if valid */ + if (pick > 0 && pick <= (int) sp->rndlevs) + Sprintf(protofile + len, "%d", pick); + break; + } else { + ep = index(ep, ','); + if (ep) ++ep; + } + } + } + } +#endif + if(*protofile) { Strcat(protofile, LEV_EXT); if(load_special(protofile)) {