special level's lit state when changing terrain
Part of pull request #308: when using des.terrain to set terrain, default for lit state becomes 'unchanged' rather than 'unlit'. des.replace_terrain already operates that way. Replace lit state magic numbers -1 and -2 with SET_LIT_RANDOM and SET_LIT_NOCHANGE. Also change SET_TYPLIT() to not operate on map column 0 and move it from rm.h to sp_lev.h. It never belonged there, is only used in sp_lev.c, and now because of the SET_LIT_ macros it couldn't be used anywhere else unless sp_lev.h gets included too.
This commit is contained in:
32
include/rm.h
32
include/rm.h
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 rm.h $NHDT-Date: 1596498558 2020/08/03 23:49:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.83 $ */
|
||||
/* NetHack 3.7 rm.h $NHDT-Date: 1599434249 2020/09/06 23:17:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.84 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Pasi Kallinen, 2017. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -436,22 +436,6 @@ struct rm {
|
||||
Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
|
||||
};
|
||||
|
||||
#define SET_TYPLIT(x, y, ttyp, llit) \
|
||||
{ \
|
||||
if ((x) >= 0 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
|
||||
if ((ttyp) < MAX_TYPE) \
|
||||
levl[(x)][(y)].typ = (ttyp); \
|
||||
if ((ttyp) == LAVAPOOL) \
|
||||
levl[(x)][(y)].lit = 1; \
|
||||
else if ((schar)(llit) != -2) { \
|
||||
if ((schar)(llit) == -1) \
|
||||
levl[(x)][(y)].lit = rn2(2); \
|
||||
else \
|
||||
levl[(x)][(y)].lit = (llit); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
@@ -631,10 +615,10 @@ typedef struct {
|
||||
* Macros for encapsulation of level.monsters references.
|
||||
*/
|
||||
#if 0
|
||||
#define MON_AT(x, y) \
|
||||
#define MON_AT(x, y) \
|
||||
(g.level.monsters[x][y] != (struct monst *) 0 \
|
||||
&& !(g.level.monsters[x][y])->mburied)
|
||||
#define MON_BURIED_AT(x, y) \
|
||||
#define MON_BURIED_AT(x, y) \
|
||||
(g.level.monsters[x][y] != (struct monst *) 0 \
|
||||
&& (g.level.monsters[x][y])->mburied)
|
||||
#else /* without 'mburied' */
|
||||
@@ -642,15 +626,15 @@ typedef struct {
|
||||
#endif
|
||||
#ifdef EXTRA_SANITY_CHECKS
|
||||
#define place_worm_seg(m, x, y) \
|
||||
do { \
|
||||
do { \
|
||||
if (g.level.monsters[x][y] && g.level.monsters[x][y] != m) \
|
||||
impossible("place_worm_seg over mon"); \
|
||||
g.level.monsters[x][y] = m; \
|
||||
impossible("place_worm_seg over mon"); \
|
||||
g.level.monsters[x][y] = m; \
|
||||
} while(0)
|
||||
#define remove_monster(x, y) \
|
||||
do { \
|
||||
do { \
|
||||
if (!g.level.monsters[x][y]) \
|
||||
impossible("no monster to remove"); \
|
||||
impossible("no monster to remove"); \
|
||||
g.level.monsters[x][y] = (struct monst *) 0; \
|
||||
} while(0)
|
||||
#else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 sp_lev.h $NHDT-Date: 1596498560 2020/08/03 23:49:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.38 $ */
|
||||
/* NetHack 3.7 sp_lev.h $NHDT-Date: 1599434249 2020/09/06 23:17:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.39 $ */
|
||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -62,6 +62,11 @@ 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() */
|
||||
@@ -188,4 +193,20 @@ struct mapfragment {
|
||||
char *data;
|
||||
};
|
||||
|
||||
#define SET_TYPLIT(x, y, ttyp, llit) \
|
||||
{ \
|
||||
if ((x) >= 1 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
|
||||
if ((ttyp) < MAX_TYPE) \
|
||||
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); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* SP_LEV_H */
|
||||
|
||||
Reference in New Issue
Block a user