]> granicus.if.org Git - nethack/commitdiff
SPLEVTYPE debug mode environment variable
authorcohrs <cohrs>
Sat, 2 Feb 2002 02:58:07 +0000 (02:58 +0000)
committercohrs <cohrs>
Sat, 2 Feb 2002 02:58:07 +0000 (02:58 +0000)
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

index 82bc2787cbf0624f97914e05d8fa277a51693253..1d54da23e31b061d77c52a8f25bb974e1b67a265 100644 (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)) {