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.
This commit is contained in:
cohrs
2002-02-02 02:58:07 +00:00
parent 9c851c0c1d
commit 4c394e385a

View File

@@ -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)) {