Dehardcode minefill

Instead of hardcoding the minefill levels in the core,
allow defining fill levels for a dungeon branch in the dungeon.lua
This commit is contained in:
Pasi Kallinen
2020-02-01 18:29:55 +02:00
parent c03ed894de
commit 33cd6befe0
4 changed files with 7 additions and 3 deletions

View File

@@ -167,6 +167,7 @@ dungeon = {
range = 2,
alignment = "lawful",
flags = { "mazelike" },
lvlfill = "minefill",
levels = {
{
name = "minetn",

View 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 */

View 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;

View 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];