Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7

This commit is contained in:
nhkeni
2022-03-16 17:22:43 -04:00
8 changed files with 85 additions and 56 deletions

View File

@@ -1347,6 +1347,8 @@ extern boolean litstate_rnd(int);
/* ### mkmaze.c ### */
extern boolean set_levltyp(xchar, xchar, schar);
extern boolean set_levltyp_lit(xchar, xchar, schar, schar);
extern void create_maze(int, int, boolean);
extern void wallification(int, int, int, int);
extern void fix_wall_spines(int, int, int, int);

View File

@@ -233,6 +233,13 @@ struct rm {
Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
};
/* light states for terrain replacements, for set_levltyp_lit */
#define SET_LIT_RANDOM -1
#define SET_LIT_NOCHANGE -2
#define CAN_OVERWRITE_TERRAIN(ttyp) \
(iflags.debug_overwrite_stairs || !((ttyp) == LADDER || (ttyp) == STAIRS))
/*
* Add wall angle viewing by defining "modes" for each wall type. Each
* mode describes which parts of a wall are finished (seen as as wall)

View File

@@ -63,11 +63,6 @@ enum lvlinit_types {
#define SEL_GRADIENT_RADIAL 0
#define SEL_GRADIENT_SQUARE 1
/* light states for terrain replacements, specifically for SET_TYPLIT
* (not used for init_level) */
#define SET_LIT_RANDOM -1
#define SET_LIT_NOCHANGE -2
#define SP_COORD_IS_RANDOM 0x01000000L
/* Humidity flags for get_location() and friends, used with
* SP_COORD_PACK_RANDOM() */
@@ -198,24 +193,4 @@ struct mapfragment {
char *data;
};
#define CAN_OVERWRITE_TERRAIN(ttyp) \
(iflags.debug_overwrite_stairs || !((ttyp) == LADDER || (ttyp) == STAIRS))
#define SET_TYPLIT(x, y, ttyp, llit) \
do { \
if ((x) >= 1 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
if ((ttyp) < MAX_TYPE \
&& CAN_OVERWRITE_TERRAIN(levl[(x)][(y)].typ)) \
levl[(x)][(y)].typ = (ttyp); \
if ((ttyp) == LAVAPOOL) \
levl[(x)][(y)].lit = 1; \
else if ((schar)(llit) != SET_LIT_NOCHANGE) { \
if ((schar)(llit) == SET_LIT_RANDOM) \
levl[(x)][(y)].lit = rn2(2); \
else \
levl[(x)][(y)].lit = (llit); \
} \
} \
} while (0)
#endif /* SP_LEV_H */

View File

@@ -1446,7 +1446,8 @@ make_grave(int x, int y, const char *str)
if ((levl[x][y].typ != ROOM && levl[x][y].typ != GRAVE) || t_at(x, y))
return;
/* Make the grave */
levl[x][y].typ = GRAVE;
if (!set_levltyp(x, y, GRAVE))
return;
/* Engrave the headstone */
del_engr_at(x, y);
if (!str)

View File

@@ -620,7 +620,7 @@ makeniche(int trap_type)
else {
/* inaccessible niches occasionally have iron bars */
if (!rn2(5) && IS_WALL(levl[xx][yy].typ)) {
levl[xx][yy].typ = IRONBARS;
(void) set_levltyp(xx, yy, IRONBARS);
if (rn2(3))
(void) mkcorpstat(CORPSE, (struct monst *) 0,
mkclass(S_HUMAN, 0), xx,
@@ -1271,8 +1271,8 @@ place_branch(branch *br, /* branch to place */
: !br->end1_up;
stairway_add(x, y, goes_up, FALSE, dest);
(void) set_levltyp(x, y, STAIRS);
levl[x][y].ladder = goes_up ? LA_UP : LA_DOWN;
levl[x][y].typ = STAIRS;
}
/*
* Set made_branch to TRUE even if we didn't make a stairwell (i.e.
@@ -1635,10 +1635,7 @@ mkstairs(xchar x, xchar y,
dest.dlevel = u.uz.dlevel + (up ? -1 : 1);
stairway_add(x, y, up ? TRUE : FALSE, FALSE, &dest);
if (levl[x][y].typ == ICE)
spot_stop_timers(x, y, MELT_ICE_AWAY);
levl[x][y].typ = STAIRS;
(void) set_levltyp(x,y, STAIRS);
levl[x][y].ladder = up ? LA_UP : LA_DOWN;
}
@@ -1733,7 +1730,8 @@ mkfount(int mazeflag, struct mkroom *croom)
} while (occupied(m.x, m.y) || bydoor(m.x, m.y));
/* Put a fountain at m.x, m.y */
levl[m.x][m.y].typ = FOUNTAIN;
if (!set_levltyp(m.x, m.y, FOUNTAIN))
return;
/* Is it a "blessed" fountain? (affects drinking from fountain) */
if (!rn2(7))
levl[m.x][m.y].blessedftn = 1;
@@ -1764,7 +1762,8 @@ mksink(struct mkroom *croom)
return;
/* Put a sink at m.x, m.y */
levl[m.x][m.y].typ = SINK;
if (!set_levltyp(m.x, m.y, SINK))
return;
g.level.flags.nsinks++;
}
@@ -1782,7 +1781,8 @@ mkaltar(struct mkroom *croom)
return;
/* Put an altar at m.x, m.y */
levl[m.x][m.y].typ = ALTAR;
if (!set_levltyp(m.x, m.y, ALTAR))
return;
/* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */
al = rn2((int) A_LAWFUL + 2) - 1;

View File

@@ -67,6 +67,52 @@ is_solid(int x, int y)
return (boolean) (!isok(x, y) || IS_STWALL(levl[x][y].typ));
}
/* set map terrain type, handling lava lit, ice melt timers, etc */
boolean
set_levltyp(xchar x, xchar y, schar typ)
{
if (isok(x, y)) {
if ((typ < MAX_TYPE) && CAN_OVERWRITE_TERRAIN(levl[x][y].typ)) {
boolean was_ice = (levl[x][y].typ == ICE);
levl[x][y].typ = typ;
if (typ == LAVAPOOL)
levl[x][y].lit = 1;
if (was_ice && typ != ICE)
spot_stop_timers(x, y, MELT_ICE_AWAY);
return TRUE;
}
#ifdef EXTRA_SANITY_CHECKS
} else {
impossible("set_levltyp(%i,%i,%i) !isok", x, y, typ);
#endif /*EXTRA_SANITY_CHECKS*/
}
return FALSE;
}
/* set map terrain type and light state */
boolean
set_levltyp_lit(xchar x, xchar y, schar typ, schar lit)
{
boolean ret = set_levltyp(x, y, typ);
if (ret && isok(x, y)) {
/* LAVAPOOL handled in set_levltyp */
if ((typ != LAVAPOOL) && (lit != SET_LIT_NOCHANGE)) {
#ifdef EXTRA_SANITY_CHECKS
if (lit < SET_LIT_NOCHANGE || lit > 1)
impossible("set_levltyp_lit(%i,%i,%i,%i)", x, y, typ, lit);
#endif /*EXTRA_SANITY_CHECKS*/
if (lit == SET_LIT_RANDOM)
lit = rn2(2);
levl[x][y].lit = lit;
}
}
return ret;
}
/*
* Return 1 (not TRUE - we're doing bit vectors here) if we want to extend
* a wall spine in the (dx,dy) direction. Return 0 otherwise.

View File

@@ -329,7 +329,8 @@ lvlfill_solid(schar filling, schar lit)
for (x = 2; x <= g.x_maze_max; x++)
for (y = 0; y <= g.y_maze_max; y++) {
SET_TYPLIT(x, y, filling, lit);
if (!set_levltyp_lit(x, y, filling, lit))
continue;
/* TODO: consolidate this w lspo_map ? */
levl[x][y].flags = 0;
levl[x][y].horizontal = 0;
@@ -350,7 +351,7 @@ lvlfill_swamp(schar fg, schar bg, schar lit)
for (y = 0; y <= g.y_maze_max; y += 2) {
int c = 0;
SET_TYPLIT(x, y, fg, lit);
(void) set_levltyp_lit(x, y, fg, lit);
if (levl[x + 1][y].typ == bg)
++c;
if (levl[x][y + 1].typ == bg)
@@ -360,13 +361,13 @@ lvlfill_swamp(schar fg, schar bg, schar lit)
if (c == 3) {
switch (rn2(3)) {
case 0:
SET_TYPLIT(x + 1,y, fg, lit);
(void) set_levltyp_lit(x + 1,y, fg, lit);
break;
case 1:
SET_TYPLIT(x, y + 1, fg, lit);
(void) set_levltyp_lit(x, y + 1, fg, lit);
break;
case 2:
SET_TYPLIT(x + 1, y + 1, fg, lit);
(void) set_levltyp_lit(x + 1, y + 1, fg, lit);
break;
default:
break;
@@ -1664,7 +1665,8 @@ create_door(room_door *dd, struct mkroom *broom)
impossible("create_door: Can't find a proper place!");
return;
}
levl[x][y].typ = (dd->secret ? SDOOR : DOOR);
if (!set_levltyp(x, y, (dd->secret ? SDOOR : DOOR)))
return;
levl[x][y].doormask = dd->mask;
}
@@ -2278,7 +2280,6 @@ create_altar(altar* a, struct mkroom* croom)
xchar x = -1, y = -1;
unsigned int amask;
boolean croom_is_temple = TRUE;
int oldtyp;
if (croom) {
get_free_room_loc(&x, &y, croom, a->coord);
@@ -2293,13 +2294,11 @@ create_altar(altar* a, struct mkroom* croom)
}
/* check for existing features */
oldtyp = levl[x][y].typ;
if (!CAN_OVERWRITE_TERRAIN(oldtyp))
if (!set_levltyp(x, y, ALTAR))
return;
amask = sp_amask_to_amask(a->sp_amask);
levl[x][y].typ = ALTAR;
levl[x][y].altarmask = amask;
if (a->shrine < 0)
@@ -4801,7 +4800,9 @@ sel_set_ter(int x, int y, genericptr_t arg)
terrain terr;
terr = *(terrain *) arg;
SET_TYPLIT(x, y, terr.ter, terr.tlit);
if (!set_levltyp_lit(x, y, terr.ter, terr.tlit))
return;
/* TODO: move this below into set_levltyp? */
/* handle doors and secret doors */
if (levl[x][y].typ == SDOOR || IS_DOOR(levl[x][y].typ)) {
if (levl[x][y].typ == SDOOR)
@@ -5167,10 +5168,10 @@ lspo_replace_terrain(lua_State *L)
if (selection_getpoint(x, y,sel)) {
if (mf) {
if (mapfrag_match(mf, x, y) && (rn2(100)) < chance)
SET_TYPLIT(x, y, totyp, tolit);
(void) set_levltyp_lit(x, y, totyp, tolit);
} else {
if (levl[x][y].typ == fromtyp && rn2(100) < chance)
SET_TYPLIT(x, y, totyp, tolit);
(void) set_levltyp_lit(x, y, totyp, tolit);
}
}

View File

@@ -348,7 +348,6 @@ maketrap(int x, int y, int typ)
boolean oldplace;
struct trap *ttmp;
struct rm *lev = &levl[x][y];
boolean was_ice = (lev->typ == ICE);
if ((ttmp = t_at(x, y)) != 0) {
if (undestroyable_trap(ttmp->ttyp))
@@ -447,21 +446,19 @@ maketrap(int x, int y, int typ)
: 0L);
lev->doormask = 0; /* subsumes altarmask, icedpool... */
if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
lev->typ = ROOM;
(void) set_levltyp(x, y, ROOM);
/*
* some cases which can happen when digging
* down while phazing thru solid areas
*/
else if (lev->typ == STONE || lev->typ == SCORR)
lev->typ = CORR;
(void) set_levltyp(x, y, CORR);
else if (IS_WALL(lev->typ) || lev->typ == SDOOR)
lev->typ = g.level.flags.is_maze_lev ? ROOM
: g.level.flags.is_cavernous_lev ? CORR
: DOOR;
(void) set_levltyp(x, y, g.level.flags.is_maze_lev ? ROOM
: g.level.flags.is_cavernous_lev ? CORR
: DOOR);
unearth_objs(x, y);
if (was_ice && lev->typ != ICE)
spot_stop_timers(x, y, MELT_ICE_AWAY);
break;
}