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 @@
|
|||||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.297 $ $NHDT-Date: 1599255099 2020/09/04 21:31:39 $
|
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.298 $ $NHDT-Date: 1599434249 2020/09/06 23:17:29 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -326,6 +326,8 @@ the fix to make worm visibility checks work as intended forced the coordinates
|
|||||||
reverses the segments and can throw some away if there isn't room,
|
reverses the segments and can throw some away if there isn't room,
|
||||||
but throwing away the extra segment removed the worm from the map
|
but throwing away the extra segment removed the worm from the map
|
||||||
using 'O' to try to change 'symset' was a no-op; 'roguesymset' worked
|
using 'O' to try to change 'symset' was a no-op; 'roguesymset' worked
|
||||||
|
change default for lit attribute in special level des.terrain directives to
|
||||||
|
'unchanged' instead of 'unlit'
|
||||||
|
|
||||||
curses: 'msg_window' option wasn't functional for curses unless the binary
|
curses: 'msg_window' option wasn't functional for curses unless the binary
|
||||||
also included tty support
|
also included tty support
|
||||||
|
|||||||
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) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Pasi Kallinen, 2017. */
|
/*-Copyright (c) Pasi Kallinen, 2017. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* 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 */
|
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
|
* 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)
|
* 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.
|
* Macros for encapsulation of level.monsters references.
|
||||||
*/
|
*/
|
||||||
#if 0
|
#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] != (struct monst *) 0 \
|
||||||
&& !(g.level.monsters[x][y])->mburied)
|
&& !(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] != (struct monst *) 0 \
|
||||||
&& (g.level.monsters[x][y])->mburied)
|
&& (g.level.monsters[x][y])->mburied)
|
||||||
#else /* without 'mburied' */
|
#else /* without 'mburied' */
|
||||||
@@ -642,15 +626,15 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef EXTRA_SANITY_CHECKS
|
#ifdef EXTRA_SANITY_CHECKS
|
||||||
#define place_worm_seg(m, x, y) \
|
#define place_worm_seg(m, x, y) \
|
||||||
do { \
|
do { \
|
||||||
if (g.level.monsters[x][y] && g.level.monsters[x][y] != m) \
|
if (g.level.monsters[x][y] && g.level.monsters[x][y] != m) \
|
||||||
impossible("place_worm_seg over mon"); \
|
impossible("place_worm_seg over mon"); \
|
||||||
g.level.monsters[x][y] = m; \
|
g.level.monsters[x][y] = m; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define remove_monster(x, y) \
|
#define remove_monster(x, y) \
|
||||||
do { \
|
do { \
|
||||||
if (!g.level.monsters[x][y]) \
|
if (!g.level.monsters[x][y]) \
|
||||||
impossible("no monster to remove"); \
|
impossible("no monster to remove"); \
|
||||||
g.level.monsters[x][y] = (struct monst *) 0; \
|
g.level.monsters[x][y] = (struct monst *) 0; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#else
|
#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 */
|
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -62,6 +62,11 @@ enum lvlinit_types {
|
|||||||
#define SEL_GRADIENT_RADIAL 0
|
#define SEL_GRADIENT_RADIAL 0
|
||||||
#define SEL_GRADIENT_SQUARE 1
|
#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
|
#define SP_COORD_IS_RANDOM 0x01000000L
|
||||||
/* Humidity flags for get_location() and friends, used with
|
/* Humidity flags for get_location() and friends, used with
|
||||||
* SP_COORD_PACK_RANDOM() */
|
* SP_COORD_PACK_RANDOM() */
|
||||||
@@ -188,4 +193,20 @@ struct mapfragment {
|
|||||||
char *data;
|
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 */
|
#endif /* SP_LEV_H */
|
||||||
|
|||||||
39
src/sp_lev.c
39
src/sp_lev.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 sp_lev.c $NHDT-Date: 1596498212 2020/08/03 23:43:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.201 $ */
|
/* NetHack 3.7 sp_lev.c $NHDT-Date: 1599434249 2020/09/06 23:17:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.202 $ */
|
||||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define IN_SP_LEV_C
|
#define IN_SP_LEV_C
|
||||||
|
|
||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "sp_lev.h"
|
#include "sp_lev.h"
|
||||||
|
|
||||||
@@ -5089,12 +5089,15 @@ lua_State *L;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* terrain({ x=NN, y=NN, typ=MAPCHAR, lit=BOOL }); */
|
/*
|
||||||
/* terrain({ coord={X, Y}, typ=MAPCHAR, lit=BOOL }); */
|
* [lit_state: 1 On, 0 Off, -1 random, -2 leave as-is]
|
||||||
/* terrain({ selection=SELECTION, typ=MAPCHAR, lit=BOOL }); */
|
* terrain({ x=NN, y=NN, typ=MAPCHAR, lit=lit_state });
|
||||||
/* terrain( SELECTION, MAPCHAR [, BOOL ] ); */
|
* terrain({ coord={X, Y}, typ=MAPCHAR, lit=lit_state });
|
||||||
/* terrain({x,y}, MAPCHAR); */
|
* terrain({ selection=SELECTION, typ=MAPCHAR, lit=lit_state });
|
||||||
/* terrain(x,y, MAPCHAR); */
|
* terrain( SELECTION, MAPCHAR [, lit_state ] );
|
||||||
|
* terrain({x,y}, MAPCHAR);
|
||||||
|
* terrain(x,y, MAPCHAR);
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
lspo_terrain(L)
|
lspo_terrain(L)
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
@@ -5105,7 +5108,7 @@ lua_State *L;
|
|||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
create_des_coder();
|
create_des_coder();
|
||||||
tmpterrain.tlit = 0;
|
tmpterrain.tlit = SET_LIT_NOCHANGE;
|
||||||
tmpterrain.ter = INVALID_TYPE;
|
tmpterrain.ter = INVALID_TYPE;
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
@@ -5120,7 +5123,7 @@ lua_State *L;
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
tmpterrain.ter = get_table_mapchr(L, "typ");
|
tmpterrain.ter = get_table_mapchr(L, "typ");
|
||||||
tmpterrain.tlit = get_table_int_opt(L, "lit", 0);
|
tmpterrain.tlit = get_table_int_opt(L, "lit", SET_LIT_NOCHANGE);
|
||||||
} else if (argc == 2 && lua_type(L, 1) == LUA_TTABLE
|
} else if (argc == 2 && lua_type(L, 1) == LUA_TTABLE
|
||||||
&& lua_type(L, 2) == LUA_TSTRING) {
|
&& lua_type(L, 2) == LUA_TSTRING) {
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
@@ -5154,10 +5157,16 @@ lua_State *L;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replace_terrain({ x1=NN,y1=NN, x2=NN,y2=NN, fromterrain=MAPCHAR, toterrain=MAPCHAR, lit=N, chance=NN }); */
|
/*
|
||||||
/* replace_terrain({ region={x1,y1, x2,y2}, fromterrain=MAPCHAR, toterrain=MAPCHAR, lit=N, chance=NN }); */
|
* replace_terrain({ x1=NN,y1=NN, x2=NN,y2=NN, fromterrain=MAPCHAR,
|
||||||
/* replace_terrain({ selection=selection.area(2,5, 40,10), fromterrain=MAPCHAR, toterrain=MAPCHAR }); */
|
* toterrain=MAPCHAR, lit=N, chance=NN });
|
||||||
/* replace_terrain({ selection=SEL, mapfragment=[[...]], toterrain=MAPCHAR }); */
|
* replace_terrain({ region={x1,y1, x2,y2}, fromterrain=MAPCHAR,
|
||||||
|
* toterrain=MAPCHAR, lit=N, chance=NN });
|
||||||
|
* replace_terrain({ selection=selection.area(2,5, 40,10),
|
||||||
|
* fromterrain=MAPCHAR, toterrain=MAPCHAR });
|
||||||
|
* replace_terrain({ selection=SEL, mapfragment=[[...]],
|
||||||
|
* toterrain=MAPCHAR });
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
lspo_replace_terrain(L)
|
lspo_replace_terrain(L)
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
@@ -5195,7 +5204,7 @@ lua_State *L;
|
|||||||
}
|
}
|
||||||
|
|
||||||
chance = get_table_int_opt(L, "chance", 100);
|
chance = get_table_int_opt(L, "chance", 100);
|
||||||
tolit = get_table_int_opt(L, "lit", -2);
|
tolit = get_table_int_opt(L, "lit", SET_LIT_NOCHANGE);
|
||||||
x1 = get_table_int_opt(L, "x1", -1);
|
x1 = get_table_int_opt(L, "x1", -1);
|
||||||
y1 = get_table_int_opt(L, "y1", -1);
|
y1 = get_table_int_opt(L, "y1", -1);
|
||||||
x2 = get_table_int_opt(L, "x2", -1);
|
x2 = get_table_int_opt(L, "x2", -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user