]> granicus.if.org Git - nethack/commitdiff
Dehardcode minefill
authorPasi Kallinen <paxed@alt.org>
Sat, 1 Feb 2020 16:29:55 +0000 (18:29 +0200)
committerPasi Kallinen <paxed@alt.org>
Sat, 1 Feb 2020 16:31:39 +0000 (18:31 +0200)
Instead of hardcoding the minefill levels in the core,
allow defining fill levels for a dungeon branch in the dungeon.lua

dat/dungeon.lua
include/dungeon.h
src/dungeon.c
src/mklev.c

index 014d3dab32fc0626420a680d07383493aecaa6e2..be504fbd200326a97d8a7f67a1f8f78c5184cbf4 100644 (file)
@@ -167,6 +167,7 @@ dungeon = {
       range = 2,
       alignment = "lawful",
       flags = { "mazelike" },
+      lvlfill = "minefill",
       levels = {
          {
             name = "minetn",
index c254940011631056b884a850f6119d262d81430a..7a5677761e4a44c62f3410276e42ac7dbec4c640 100644 (file)
@@ -56,6 +56,7 @@ typedef struct dest_area { /* non-stairway level change identifier */
 typedef struct dungeon {   /* basic dungeon identifier */
     char dname[24];        /* name of the dungeon (eg. "Hell") */
     char proto[15];        /* name of prototype file (eg. "tower") */
+    char fill_lvl[15];     /* name of "fill" level protype file */
     char boneid;           /* character to id dungeon in bones files */
     d_flags flags;         /* dungeon flags */
     xchar entry_lev;       /* entry level */
index f07f375f1a977d8bfdbf703847bba89f188d67bd..9505047322d865048eb0c8d04f39815e82399977 100644 (file)
@@ -832,7 +832,7 @@ init_dungeons()
     lua_pushnil(L); /* first key */
     i = 0;
     while (lua_next(L, tidx) != 0) {
-        char *dgn_name, *dgn_bonetag, *dgn_protoname;
+        char *dgn_name, *dgn_bonetag, *dgn_protoname, *dgn_fill;
         int dgn_base, dgn_range, dgn_align, dgn_entry, dgn_chance, dgn_flags;
 
         if (!lua_istable(L, -1))
@@ -847,6 +847,7 @@ init_dungeons()
         dgn_entry = get_table_int_opt(L, "entry", 0);
         dgn_chance = get_table_int_opt(L, "chance", 100);
         dgn_flags = get_dgn_flags(L);
+        dgn_fill = get_table_str_opt(L, "lvlfill", emptystr);
 
         debugpline4("DUNGEON[%i]: %s, base=(%i,%i)", i, dgn_name, dgn_base, dgn_range);
 
@@ -984,6 +985,7 @@ init_dungeons()
         pd.tmpdungeon[i].chance = dgn_chance;
         pd.tmpdungeon[i].entry_lev = dgn_entry;
 
+        Strcpy(g.dungeons[i].fill_lvl, dgn_fill); /* FIXME: fill_lvl len */
         Strcpy(g.dungeons[i].dname, dgn_name); /* FIXME: dname length */
         Strcpy(g.dungeons[i].proto, dgn_protoname); /* FIXME: proto length */
         g.dungeons[i].boneid = *dgn_bonetag ? *dgn_bonetag : 0;
index 41e2ae95db306ef743dd8d8a95e69ccd3052e140..965a4dca6dbc31973173c02d70ed2bfc6d5de186 100644 (file)
@@ -685,8 +685,8 @@ makelevel()
         } else if (g.dungeons[u.uz.dnum].proto[0]) {
             makemaz("");
             return;
-        } else if (In_mines(&u.uz)) {
-            makemaz("minefill");
+        } else if (g.dungeons[u.uz.dnum].fill_lvl[0]) {
+            makemaz(g.dungeons[u.uz.dnum].fill_lvl);
             return;
         } else if (In_quest(&u.uz)) {
             char fillname[9];