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:
@@ -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