Merge branch 'NetHack-3.7'

This commit is contained in:
nhmall
2019-11-15 22:13:00 -05:00
10 changed files with 249 additions and 113 deletions

1
.gitignore vendored
View File

@@ -37,6 +37,7 @@ Release/
binary/ binary/
build/ build/
ipch/ ipch/
lib/
Nethack.sln Nethack.sln
Nethack.sdf Nethack.sdf
Nethack.opensdf Nethack.opensdf

3
include/decl.h Normal file → Executable file
View File

@@ -339,6 +339,9 @@ E const struct c_common_strings c_common_strings;
/* material strings */ /* material strings */
E const char *materialnm[]; E const char *materialnm[];
/* empty string that is non-const for parameter use */
E char emptystr[];
/* Monster name articles */ /* Monster name articles */
#define ARTICLE_NONE 0 #define ARTICLE_NONE 0
#define ARTICLE_THE 1 #define ARTICLE_THE 1

6
include/system.h Normal file → Executable file
View File

@@ -573,4 +573,10 @@ E int FDECL(atoi, (const char *));
#include "lualib.h" #include "lualib.h"
#include "lauxlib.h" #include "lauxlib.h"
#if defined(WIN32)
#define LUA_INTCAST(i) ((int) i)
#else
#define LUA_INTCAST(i) (i)
#endif
#endif /* SYSTEM_H */ #endif /* SYSTEM_H */

2
src/decl.c Normal file → Executable file
View File

@@ -108,6 +108,8 @@ const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
"platinum", "mithril", "plastic", "glass", "platinum", "mithril", "plastic", "glass",
"gemstone", "stone" }; "gemstone", "stone" };
char emptystr[] = {0}; /* non-const */
/* Global windowing data, defined here for multi-window-system support */ /* Global windowing data, defined here for multi-window-system support */
NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN; NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;
#ifdef WIN32 #ifdef WIN32

42
src/dungeon.c Normal file → Executable file
View File

@@ -35,7 +35,9 @@ struct lchoice {
char menuletter; char menuletter;
}; };
#if 0
static void FDECL(Fread, (genericptr_t, int, int, dlb *)); static void FDECL(Fread, (genericptr_t, int, int, dlb *));
#endif
static xchar FDECL(dname_to_dnum, (const char *)); static xchar FDECL(dname_to_dnum, (const char *));
static int FDECL(find_branch, (const char *, struct proto_dungeon *)); static int FDECL(find_branch, (const char *, struct proto_dungeon *));
static xchar FDECL(parent_dnum, (const char *, struct proto_dungeon *)); static xchar FDECL(parent_dnum, (const char *, struct proto_dungeon *));
@@ -293,6 +295,7 @@ NHFILE *nhfp;
} }
} }
#if 0
static void static void
Fread(ptr, size, nitems, stream) Fread(ptr, size, nitems, stream)
genericptr_t ptr; genericptr_t ptr;
@@ -308,6 +311,7 @@ dlb *stream;
nh_terminate(EXIT_FAILURE); nh_terminate(EXIT_FAILURE);
} }
} }
#endif
static xchar static xchar
dname_to_dnum(s) dname_to_dnum(s)
@@ -776,7 +780,7 @@ lua_State *L;
if (lua_type(L, -1) == LUA_TTABLE) { if (lua_type(L, -1) == LUA_TTABLE) {
int f, nflags; int f, nflags;
lua_len(L, -1); lua_len(L, -1);
nflags = lua_tointeger(L, -1); nflags = LUA_INTCAST(lua_tointeger(L, -1));
lua_pop(L, 1); lua_pop(L, 1);
for (f = 0; f < nflags; f++) { for (f = 0; f < nflags; f++) {
lua_pushinteger(L, f+1); lua_pushinteger(L, f+1);
@@ -807,7 +811,9 @@ init_dungeons()
register s_level *x; register s_level *x;
struct proto_dungeon pd; struct proto_dungeon pd;
struct level_map *lev_map; struct level_map *lev_map;
int tidx;
nhUse(cb);
(void) memset(&pd, 0, sizeof(struct proto_dungeon)); (void) memset(&pd, 0, sizeof(struct proto_dungeon));
pd.n_levs = pd.n_brs = 0; pd.n_levs = pd.n_brs = 0;
@@ -850,7 +856,7 @@ init_dungeons()
panic("dungeon is not a lua table"); panic("dungeon is not a lua table");
lua_len(L, -1); lua_len(L, -1);
g.n_dgns = lua_tointeger(L, -1); g.n_dgns = LUA_INTCAST(lua_tointeger(L, -1));
lua_pop(L, 1); lua_pop(L, 1);
pd.start = 0; pd.start = 0;
@@ -865,23 +871,26 @@ init_dungeons()
if (g.n_dgns >= MAXDUNGEON) if (g.n_dgns >= MAXDUNGEON)
panic("init_dungeons: too many dungeons"); panic("init_dungeons: too many dungeons");
int tidx = lua_gettop(L); tidx = lua_gettop(L);
lua_pushnil(L); /* first key */ lua_pushnil(L); /* first key */
i = 0; i = 0;
while (lua_next(L, tidx) != 0) { while (lua_next(L, tidx) != 0) {
char *dgn_name, *dgn_bonetag, *dgn_protoname;
int dgn_base, dgn_range, dgn_align, dgn_entry, dgn_chance, dgn_flags;
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
panic("dungeon[%i] is not a lua table", i); panic("dungeon[%i] is not a lua table", i);
char *dgn_name = get_table_str(L, "name"); dgn_name = get_table_str(L, "name");
char *dgn_bonetag = get_table_str_opt(L, "bonetag", ""); /* TODO: single char or "none" */ dgn_bonetag = get_table_str_opt(L, "bonetag", emptystr); /* TODO: single char or "none" */
char *dgn_protoname = get_table_str_opt(L, "protofile", ""); dgn_protoname = get_table_str_opt(L, "protofile", emptystr);
int dgn_base = get_table_int(L, "base"); dgn_base = get_table_int(L, "base");
int dgn_range = get_table_int_opt(L, "range", 0); dgn_range = get_table_int_opt(L, "range", 0);
int dgn_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)]; dgn_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)];
int dgn_entry = get_table_int_opt(L, "entry", 0); dgn_entry = get_table_int_opt(L, "entry", 0);
int dgn_chance = get_table_int_opt(L, "chance", 100); dgn_chance = get_table_int_opt(L, "chance", 100);
int dgn_flags = get_dgn_flags(L); dgn_flags = get_dgn_flags(L);
debugpline4("DUNGEON[%i]: %s, base=(%i,%i)", i, dgn_name, dgn_base, dgn_range); debugpline4("DUNGEON[%i]: %s, base=(%i,%i)", i, dgn_name, dgn_base, dgn_range);
@@ -897,7 +906,7 @@ init_dungeons()
if (lua_type(L, -1) == LUA_TTABLE) { if (lua_type(L, -1) == LUA_TTABLE) {
int f, nlevels; int f, nlevels;
lua_len(L, -1); lua_len(L, -1);
nlevels = lua_tointeger(L, -1); nlevels = LUA_INTCAST(lua_tointeger(L, -1));
pd.tmpdungeon[i].levels = nlevels; pd.tmpdungeon[i].levels = nlevels;
lua_pop(L, 1); lua_pop(L, 1);
for (f = 0; f < nlevels; f++) { for (f = 0; f < nlevels; f++) {
@@ -906,7 +915,7 @@ init_dungeons()
if (lua_type(L, -1) == LUA_TTABLE) { if (lua_type(L, -1) == LUA_TTABLE) {
int bi; int bi;
char *lvl_name = get_table_str(L, "name"); char *lvl_name = get_table_str(L, "name");
char *lvl_bonetag = get_table_str_opt(L, "bonetag", ""); char *lvl_bonetag = get_table_str_opt(L, "bonetag", emptystr);
int lvl_base = get_table_int(L, "base"); int lvl_base = get_table_int(L, "base");
int lvl_range = get_table_int_opt(L, "range", 0); int lvl_range = get_table_int_opt(L, "range", 0);
int lvl_nlevels = get_table_int_opt(L, "nlevels", 0); int lvl_nlevels = get_table_int_opt(L, "nlevels", 0);
@@ -915,6 +924,9 @@ init_dungeons()
int lvl_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)]; int lvl_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)];
int lvl_flags = get_dgn_flags(L); int lvl_flags = get_dgn_flags(L);
struct tmplevel *tmpl = &pd.tmplevel[pd.n_levs + f]; struct tmplevel *tmpl = &pd.tmplevel[pd.n_levs + f];
nhUse(lvl_bonetag);
nhUse(lvl_align);
debugpline4("LEVEL[%i]:%s,(%i,%i)", f, lvl_name, lvl_base, lvl_range); debugpline4("LEVEL[%i]:%s,(%i,%i)", f, lvl_name, lvl_base, lvl_range);
tmpl->name = lvl_name; tmpl->name = lvl_name;
tmpl->chainlvl = lvl_chain; tmpl->chainlvl = lvl_chain;
@@ -953,7 +965,7 @@ init_dungeons()
if (lua_type(L, -1) == LUA_TTABLE) { if (lua_type(L, -1) == LUA_TTABLE) {
int f, nbranches; int f, nbranches;
lua_len(L, -1); lua_len(L, -1);
nbranches = lua_tointeger(L, -1); nbranches = LUA_INTCAST(lua_tointeger(L, -1));
pd.tmpdungeon[i].branches = nbranches; pd.tmpdungeon[i].branches = nbranches;
lua_pop(L, 1); lua_pop(L, 1);
for (f = 0; f < nbranches; f++) { for (f = 0; f < nbranches; f++) {

36
src/nhlsel.c Normal file → Executable file
View File

@@ -23,17 +23,27 @@ static int FDECL(l_selection_filter_mapchar, (lua_State *));
static int FDECL(l_selection_flood, (lua_State *)); static int FDECL(l_selection_flood, (lua_State *));
static int FDECL(l_selection_circle, (lua_State *)); static int FDECL(l_selection_circle, (lua_State *));
static int FDECL(l_selection_ellipse, (lua_State *)); static int FDECL(l_selection_ellipse, (lua_State *));
static int FDECL(l_selection_gradient, (lua_State *));
static int FDECL(l_selection_iterate, (lua_State *));
static int FDECL(l_selection_gc, (lua_State *)); static int FDECL(l_selection_gc, (lua_State *));
static int FDECL(l_selection_not, (lua_State *)); static int FDECL(l_selection_not, (lua_State *));
static int FDECL(l_selection_and, (lua_State *)); static int FDECL(l_selection_and, (lua_State *));
static int FDECL(l_selection_or, (lua_State *)); static int FDECL(l_selection_or, (lua_State *));
static int FDECL(l_selection_xor, (lua_State *)); static int FDECL(l_selection_xor, (lua_State *));
static int FDECL(l_selection_not, (lua_State *)); static int FDECL(l_selection_not, (lua_State *));
#if 0
/* the following do not appear to currently be
used and because they are static, the OSX
compiler is complaining about them. I've
if ifdef'd out the prototype here and the
function body below.
*/
static int FDECL(l_selection_gradient, (lua_State *));
static int FDECL(l_selection_iterate, (lua_State *));
static int FDECL(l_selection_add, (lua_State *)); static int FDECL(l_selection_add, (lua_State *));
static int FDECL(l_selection_sub, (lua_State *)); static int FDECL(l_selection_sub, (lua_State *));
static int FDECL(l_selection_ipairs, (lua_State *)); static int FDECL(l_selection_ipairs, (lua_State *));
/* this prototype was missing but function body was below */
static struct selectionvar *FDECL(l_selection_to, (lua_State *, int));
#endif
struct selectionvar * struct selectionvar *
l_selection_check(L, index) l_selection_check(L, index)
@@ -588,6 +598,17 @@ lua_State *L;
filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */ filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
} else { } else {
nhl_error(L, "wrong parameters"); nhl_error(L, "wrong parameters");
/*
* FIXME: OSX compiler is issuing a complaint
* about r being passed to selection_do_ellipse()
* below without ever having been initialized
* to something when this else clause is encountered.
* I could have added an initializer to r at the
* top, but I didn't know what it should be initialized
* to in order for selection_do_ellipse() to not
* misbehave. The parameters passed in previous versions
* were related to xaxis and yaxis.
*/
} }
get_location_coord(&x, &y, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x,y)); get_location_coord(&x, &y, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x,y));
@@ -639,6 +660,17 @@ lua_State *L;
filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */ filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */
} else { } else {
nhl_error(L, "wrong parameters"); nhl_error(L, "wrong parameters");
/*
* FIXME: OSX compiler is issuing a complaint
* about r1 and r2 being passed to selection_do_ellipse()
* below without ever having been initialized
* to something when this else clause is encountered.
* I could have added an initializer to r1,r2 at the
* top, but I didn't know what they should be initialized
* to in order for selection_do_ellipse() to not
* misbehave. The parameters passed in previous versions
* were related to xaxis and yaxis.
*/
} }
get_location_coord(&x, &y, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x,y)); get_location_coord(&x, &y, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x,y));

24
src/nhlua.c Normal file → Executable file
View File

@@ -16,7 +16,9 @@
/* lua_CFunction prototypes */ /* lua_CFunction prototypes */
static int FDECL(nhl_test, (lua_State *)); static int FDECL(nhl_test, (lua_State *));
static int FDECL(nhl_getmap, (lua_State *)); static int FDECL(nhl_getmap, (lua_State *));
#if 0
static int FDECL(nhl_setmap, (lua_State *)); static int FDECL(nhl_setmap, (lua_State *));
#endif
static int FDECL(nhl_pline, (lua_State *)); static int FDECL(nhl_pline, (lua_State *));
static int FDECL(nhl_verbalize, (lua_State *)); static int FDECL(nhl_verbalize, (lua_State *));
static int FDECL(nhl_menu, (lua_State *)); static int FDECL(nhl_menu, (lua_State *));
@@ -87,7 +89,7 @@ schar defval;
char *ter; char *ter;
xchar typ; xchar typ;
ter = get_table_str_opt(L, name, ""); ter = get_table_str_opt(L, name, emptystr);
if (name && *ter) { if (name && *ter) {
typ = check_mapchr(ter); typ = check_mapchr(ter);
if (typ == INVALID_TYPE) if (typ == INVALID_TYPE)
@@ -213,8 +215,8 @@ lua_State *L;
int argc = lua_gettop(L); int argc = lua_gettop(L);
if (argc == 2) { if (argc == 2) {
int x = lua_tointeger(L, 1); int x = LUA_INTCAST(lua_tointeger(L, 1));
int y = lua_tointeger(L, 2); int y = LUA_INTCAST(lua_tointeger(L, 2));
if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) { if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) {
char buf[BUFSZ]; char buf[BUFSZ];
@@ -572,7 +574,9 @@ const char *name;
if (ltyp == LUA_TSTRING) { if (ltyp == LUA_TSTRING) {
const char *const boolstr[] = { "true", "false", "yes", "no", NULL }; const char *const boolstr[] = { "true", "false", "yes", "no", NULL };
const int boolstr2i[] = { TRUE, FALSE, TRUE, FALSE, -1 }; const int boolstr2i[] = { TRUE, FALSE, TRUE, FALSE, -1 };
ret = luaL_checkoption(L, -1, NULL, boolstr); ret = luaL_checkoption(L, -1, NULL, boolstr);
nhUse(boolstr2i[0]);
} else if (ltyp == LUA_TBOOLEAN) { } else if (ltyp == LUA_TBOOLEAN) {
ret = lua_toboolean(L, -1); ret = lua_toboolean(L, -1);
} else if (ltyp == LUA_TNUMBER) { } else if (ltyp == LUA_TNUMBER) {
@@ -625,14 +629,17 @@ static int
nhl_test(L) nhl_test(L)
lua_State *L; lua_State *L;
{ {
int x, y;
char *name, Player[] = "Player";
/* discard any extra arguments passed in */ /* discard any extra arguments passed in */
lua_settop(L, 1); lua_settop(L, 1);
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
int x = get_table_int(L, "x"); x = get_table_int(L, "x");
int y = get_table_int(L, "y"); y = get_table_int(L, "y");
char *name = get_table_str_opt(L, "name", "Player"); name = get_table_str_opt(L, "name", Player);
pline("TEST:{ x=%i, y=%i, name=\"%s\" }", x,y, name); pline("TEST:{ x=%i, y=%i, name=\"%s\" }", x,y, name);
@@ -645,8 +652,9 @@ static const struct luaL_Reg nhl_functions[] = {
{"test", nhl_test}, {"test", nhl_test},
{"getmap", nhl_getmap}, {"getmap", nhl_getmap},
/*{"setmap", nhl_setmap},*/ #if 0
{"setmap", nhl_setmap},
#endif
{"pline", nhl_pline}, {"pline", nhl_pline},
{"verbalize", nhl_verbalize}, {"verbalize", nhl_verbalize},
{"menu", nhl_menu}, {"menu", nhl_menu},

75
src/sp_lev.c Normal file → Executable file
View File

@@ -64,17 +64,13 @@ static void FDECL(wallify_map, (int, int, int, int));
static void FDECL(maze1xy, (coord *, int)); static void FDECL(maze1xy, (coord *, int));
static void NDECL(fill_empty_maze); static void NDECL(fill_empty_maze);
static void FDECL(splev_initlev, (lev_init *)); static void FDECL(splev_initlev, (lev_init *));
#if 0
/* macosx complains that these are unused */
static long FDECL(sp_code_jmpaddr, (long, long)); static long FDECL(sp_code_jmpaddr, (long, long));
static void NDECL(spo_end_moninvent);
static void NDECL(spo_pop_container);
static void FDECL(spo_room, (struct sp_coder *)); static void FDECL(spo_room, (struct sp_coder *));
static void FDECL(spo_endroom, (struct sp_coder *));
static void FDECL(spo_trap, (struct sp_coder *)); static void FDECL(spo_trap, (struct sp_coder *));
static void FDECL(spo_gold, (struct sp_coder *)); static void FDECL(spo_gold, (struct sp_coder *));
static void FDECL(spo_corridor, (struct sp_coder *)); static void FDECL(spo_corridor, (struct sp_coder *));
static void FDECL(sel_set_ter, (int, int, genericptr_t));
static void FDECL(sel_set_feature, (int, int, genericptr_t));
static void FDECL(sel_set_door, (int, int, genericptr_t));
static void FDECL(spo_feature, (struct sp_coder *)); static void FDECL(spo_feature, (struct sp_coder *));
static void FDECL(spo_terrain, (struct sp_coder *)); static void FDECL(spo_terrain, (struct sp_coder *));
static void FDECL(spo_replace_terrain, (struct sp_coder *)); static void FDECL(spo_replace_terrain, (struct sp_coder *));
@@ -84,8 +80,15 @@ static void FDECL(spo_drawbridge, (struct sp_coder *));
static void FDECL(spo_mazewalk, (struct sp_coder *)); static void FDECL(spo_mazewalk, (struct sp_coder *));
static void FDECL(spo_wall_property, (struct sp_coder *)); static void FDECL(spo_wall_property, (struct sp_coder *));
static void FDECL(spo_room_door, (struct sp_coder *)); static void FDECL(spo_room_door, (struct sp_coder *));
static void FDECL(sel_set_wallify, (int, int, genericptr_t));
static void FDECL(spo_wallify, (struct sp_coder *)); static void FDECL(spo_wallify, (struct sp_coder *));
static void FDECL(sel_set_wallify, (int, int, genericptr_t));
#endif
static void NDECL(spo_end_moninvent);
static void NDECL(spo_pop_container);
static void FDECL(spo_endroom, (struct sp_coder *));
static void FDECL(sel_set_ter, (int, int, genericptr_t));
static void FDECL(sel_set_door, (int, int, genericptr_t));
static void FDECL(sel_set_feature, (int, int, genericptr_t));
static int FDECL(get_coord, (lua_State *, int, int *, int *)); static int FDECL(get_coord, (lua_State *, int, int *, int *));
static int FDECL(get_table_region, (lua_State *, const char *, int *, int *, int *, int *, BOOLEAN_P)); static int FDECL(get_table_region, (lua_State *, const char *, int *, int *, int *, int *, BOOLEAN_P));
@@ -2247,13 +2250,14 @@ lev_init *linit;
} }
} }
#if 0
static long static long
sp_code_jmpaddr(curpos, jmpaddr) sp_code_jmpaddr(curpos, jmpaddr)
long curpos, jmpaddr; long curpos, jmpaddr;
{ {
return (curpos + jmpaddr); return (curpos + jmpaddr);
} }
#endif
/*ARGUSED*/ /*ARGUSED*/
@@ -2282,6 +2286,7 @@ lua_State *L;
{ {
char *levmsg; char *levmsg;
int old_n, n; int old_n, n;
const char *msg;
int argc = lua_gettop(L); int argc = lua_gettop(L);
@@ -2292,7 +2297,7 @@ lua_State *L;
create_des_coder(); create_des_coder();
const char *msg = luaL_checkstring(L, 1); msg = luaL_checkstring(L, 1);
old_n = g.lev_message ? (strlen(g.lev_message) + 1) : 0; old_n = g.lev_message ? (strlen(g.lev_message) + 1) : 0;
n = strlen(msg); n = strlen(msg);
@@ -2315,10 +2320,10 @@ int
get_table_align(L) get_table_align(L)
lua_State *L; lua_State *L;
{ {
const char *const aligns[] = { "noalign", "law", "neutral", "chaos", "coaligned", "noncoaligned", "random", NULL }; const char *const gtaligns[] = { "noalign", "law", "neutral", "chaos", "coaligned", "noncoaligned", "random", NULL };
const int aligns2i[] = { AM_NONE, AM_LAWFUL, AM_NEUTRAL, AM_CHAOTIC, AM_SPLEV_CO, AM_SPLEV_NONCO, AM_SPLEV_RANDOM, 0 }; const int aligns2i[] = { AM_NONE, AM_LAWFUL, AM_NEUTRAL, AM_CHAOTIC, AM_SPLEV_CO, AM_SPLEV_NONCO, AM_SPLEV_RANDOM, 0 };
int a = aligns2i[get_table_option(L, "align", "random", aligns)]; int a = aligns2i[get_table_option(L, "align", "random", gtaligns)];
return a; return a;
} }
@@ -2347,6 +2352,7 @@ const char *s;
for (i = LOW_PM; i < NUMMONS; i++) for (i = LOW_PM; i < NUMMONS; i++)
if (!strcmpi(mons[i].mname, s)) if (!strcmpi(mons[i].mname, s))
return i; return i;
nhUse(L);
return NON_PM; return NON_PM;
} }
@@ -2501,7 +2507,7 @@ lua_State *L;
tmpmons.coord = SP_COORD_PACK(mx, my); tmpmons.coord = SP_COORD_PACK(mx, my);
if (tmpmons.id != NON_PM && tmpmons.class == -1) if (tmpmons.id != NON_PM && tmpmons.class == -1)
tmpmons.class = def_monsyms[mons[tmpmons.id].mlet].sym; tmpmons.class = def_monsyms[(int) mons[tmpmons.id].mlet].sym;
create_monster(&tmpmons, g.coder->croom); create_monster(&tmpmons, g.coder->croom);
@@ -2528,6 +2534,7 @@ const char *name;
int rndval; int rndval;
{ {
int ret; int ret;
char buf[BUFSZ];
lua_getfield(L, 1, name); lua_getfield(L, 1, name);
if (lua_type(L, -1) == LUA_TNIL) { if (lua_type(L, -1) == LUA_TNIL) {
@@ -2541,7 +2548,6 @@ int rndval;
lua_pop(L, 1); lua_pop(L, 1);
return rndval; return rndval;
} }
char buf[BUFSZ];
Sprintf(buf, "Expected integer or \"random\" for \"%s\", got %s", name, tmp); Sprintf(buf, "Expected integer or \"random\" for \"%s\", got %s", name, tmp);
nhl_error(L, buf); nhl_error(L, buf);
lua_pop(L, 1); lua_pop(L, 1);
@@ -2626,7 +2632,9 @@ int
lspo_object(L) lspo_object(L)
lua_State *L; lua_State *L;
{ {
#if 0
int nparams = 0; int nparams = 0;
#endif
long quancnt; long quancnt;
object tmpobj; object tmpobj;
int ox = -1, oy = -1; int ox = -1, oy = -1;
@@ -2727,8 +2735,9 @@ lua_State *L;
tmpobj.id = -1; tmpobj.id = -1;
if (tmpobj.id == STATUE || tmpobj.id == EGG || tmpobj.id == CORPSE || tmpobj.id == TIN) { if (tmpobj.id == STATUE || tmpobj.id == EGG || tmpobj.id == CORPSE || tmpobj.id == TIN) {
int flags = 0; int lflags = 0;
const char *montype = get_table_str_opt(L, "montype", NULL); const char *montype = get_table_str_opt(L, "montype", NULL);
if (montype) { if (montype) {
struct permonst *pm = NULL; struct permonst *pm = NULL;
if (strlen(montype) == 1 && def_char_to_monclass(*montype) != MAXMCLASSES) { if (strlen(montype) == 1 && def_char_to_monclass(*montype) != MAXMCLASSES) {
@@ -2747,10 +2756,10 @@ lua_State *L;
nhl_error(L, "Unknown montype"); nhl_error(L, "Unknown montype");
} }
if (tmpobj.id == STATUE) { if (tmpobj.id == STATUE) {
flags |= (get_table_boolean_opt(L, "historic", 0) ? STATUE_HISTORIC : 0x00); lflags |= (get_table_boolean_opt(L, "historic", 0) ? STATUE_HISTORIC : 0x00);
flags |= (get_table_boolean_opt(L, "male", 0) ? STATUE_MALE : 0x00); lflags |= (get_table_boolean_opt(L, "male", 0) ? STATUE_MALE : 0x00);
flags |= (get_table_boolean_opt(L, "female", 0) ? STATUE_FEMALE : 0x00); lflags |= (get_table_boolean_opt(L, "female", 0) ? STATUE_FEMALE : 0x00);
tmpobj.spe = flags; tmpobj.spe = lflags;
} else if (tmpobj.id == EGG) { } else if (tmpobj.id == EGG) {
tmpobj.spe = get_table_boolean_opt(L, "laid_by_you", 0) ? 1 : 0; tmpobj.spe = get_table_boolean_opt(L, "laid_by_you", 0) ? 1 : 0;
} }
@@ -2877,7 +2886,7 @@ int
lspo_engraving(L) lspo_engraving(L)
lua_State *L; lua_State *L;
{ {
int etyp; int etyp = DUST;
char *txt = (char *) 0; char *txt = (char *) 0;
long ecoord; long ecoord;
const char *const engrtypes[] = { "dust", "engrave", "burn", "mark", "blood", NULL }; const char *const engrtypes[] = { "dust", "engrave", "burn", "mark", "blood", NULL };
@@ -2885,6 +2894,8 @@ lua_State *L;
xchar x, y; xchar x, y;
int argc = lua_gettop(L); int argc = lua_gettop(L);
x = y = 0; /* FIXME: quiet a warning for else clause below.
should it actually be -1? */
create_des_coder(); create_des_coder();
if (argc == 1) { if (argc == 1) {
@@ -2903,6 +2914,8 @@ lua_State *L;
txt = dupstr(luaL_checkstring(L, 3)); txt = dupstr(luaL_checkstring(L, 3));
} else { } else {
nhl_error(L, "Wrong parameters"); nhl_error(L, "Wrong parameters");
/* FIXME: this clause left etyp uninitialized so initialization
to DUST was added above to quiet a macosx warning */
} }
if (x == -1 && y == -1) if (x == -1 && y == -1)
@@ -2975,7 +2988,7 @@ lua_State *L;
const char *name; const char *name;
int defval; int defval;
{ {
char *roomstr = get_table_str_opt(L, name, ""); char *roomstr = get_table_str_opt(L, name, emptystr);
if (roomstr && *roomstr) { if (roomstr && *roomstr) {
int i; int i;
for (i = 0; room_types[i].name; i++) for (i = 0; room_types[i].name; i++)
@@ -3055,7 +3068,7 @@ lua_State *L;
static void static void
spo_endroom(coder) spo_endroom(coder)
struct sp_coder *coder; struct sp_coder *coder UNUSED;
{ {
if (g.coder->n_subroom > 1) { if (g.coder->n_subroom > 1) {
g.coder->n_subroom--; g.coder->n_subroom--;
@@ -3095,15 +3108,15 @@ lua_State *L;
const int stairdirs2i[] = { 0, 1 }; const int stairdirs2i[] = { 0, 1 };
long scoord; long scoord;
int ax = -1,ay = -1; int ax = -1, ay = -1;
int up; int up;
int ltype = lua_type(L, 1); int ltype = lua_type(L, 1);
create_des_coder(); create_des_coder();
if (argc == 1 && ltype == LUA_TSTRING) if (argc == 1 && ltype == LUA_TSTRING) {
up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)]; up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)];
else if (argc == 3 && ltype == LUA_TSTRING) { } else if (argc == 3 && ltype == LUA_TSTRING) {
up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)]; up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)];
ax = luaL_checkinteger(L, 2); ax = luaL_checkinteger(L, 2);
ay = luaL_checkinteger(L, 3); ay = luaL_checkinteger(L, 3);
@@ -3154,15 +3167,15 @@ lua_State *L;
const int stairdirs2i[] = { 0, 1 }; const int stairdirs2i[] = { 0, 1 };
long scoord; long scoord;
int ax, ay; int ax = -1, ay = -1; /* FIXME: initializers added, macosx warning */
int up; int up;
int ltype = lua_type(L, 1); int ltype = lua_type(L, 1);
create_des_coder(); create_des_coder();
if (argc == 1 && ltype == LUA_TSTRING) if (argc == 1 && ltype == LUA_TSTRING) {
up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)]; up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)];
else if (argc == 3 && ltype == LUA_TSTRING) { } else if (argc == 3 && ltype == LUA_TSTRING) {
up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)]; up = stairdirs2i[luaL_checkoption(L, 1, "down", stairdirs)];
ax = luaL_checkinteger(L, 2); ax = luaL_checkinteger(L, 2);
ay = luaL_checkinteger(L, 3); ay = luaL_checkinteger(L, 3);
@@ -3325,7 +3338,7 @@ lua_State *L;
const char *name; const char *name;
int defval; int defval;
{ {
char *trapstr = get_table_str_opt(L, name, ""); char *trapstr = get_table_str_opt(L, name, emptystr);
if (trapstr && *trapstr) { if (trapstr && *trapstr) {
int i; int i;
for (i = 0; trap_types[i].name; i++) for (i = 0; trap_types[i].name; i++)
@@ -3474,7 +3487,7 @@ lua_State *L;
/* random_corridors(); */ /* random_corridors(); */
int int
lspo_random_corridors(L) lspo_random_corridors(L)
lua_State *L; lua_State *L UNUSED;
{ {
corridor tc; corridor tc;
@@ -5119,6 +5132,7 @@ lua_State *L;
return 0; return 0;
} }
#if 0
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
sel_set_wallify(x, y, arg) sel_set_wallify(x, y, arg)
@@ -5127,6 +5141,7 @@ genericptr_t arg UNUSED;
{ {
wallify_map(x, y, x, y); wallify_map(x, y, x, y);
} }
#endif
/* TODO: wallify(selection) */ /* TODO: wallify(selection) */
/* wallify({ x1=NN,y1=NN, x2=NN,y2=NN }); */ /* wallify({ x1=NN,y1=NN, x2=NN,y2=NN }); */
@@ -5161,7 +5176,7 @@ lua_State *L;
/* reset_level is only needed for testing purposes */ /* reset_level is only needed for testing purposes */
int int
lspo_reset_level(L) lspo_reset_level(L)
lua_State *L; lua_State *L UNUSED; /* macosx complaint needed UNUSED */
{ {
boolean wtower = In_W_tower(u.ux, u.uy, &u.uz); boolean wtower = In_W_tower(u.ux, u.uy, &u.uz);

View File

@@ -74,6 +74,9 @@ VARDAT = $(VARDATD) $(VARDATND)
#CHOWN = chown #CHOWN = chown
#CHGRP = chgrp #CHGRP = chgrp
# Lua version
LUA_VERSION = 5.3.5
# #
# end of configuration # end of configuration
# #
@@ -232,7 +235,15 @@ dofiles-nodlb:
-( cd $(INSTDIR) ; $(CHOWN) $(GAMEUID) $(DAT) ; \ -( cd $(INSTDIR) ; $(CHOWN) $(GAMEUID) $(DAT) ; \
$(CHGRP) $(GAMEGRP) $(DAT) ; \ $(CHGRP) $(GAMEGRP) $(DAT) ; \
chmod $(FILEPERM) $(DAT) ) chmod $(FILEPERM) $(DAT) )
#
# This is not part of the dependency build hierarchy.
# It requires an explicit "make fetch-Lua".
fetch-lua: fetch-Lua
fetch-Lua:
( mkdir -p lib ; cd lib ; \
curl -R -O http://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz ; \
tar zxf lua-$(LUA_VERSION).tar.gz ; rm -f lua-$(LUA_VERSION).tar.gz )
update: $(GAME) recover $(VARDAT) spec_levs update: $(GAME) recover $(VARDAT) spec_levs
# (don't yank the old version out from under people who're playing it) # (don't yank the old version out from under people who're playing it)
-mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old -mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old

View File

@@ -1,17 +1,18 @@
# NetHack 3.6 Makefile.msc $NHDT-Date: 1572748386 2019/11/03 02:33:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.167 $ */ # NetHack 3.7 Makefile.msc
# Copyright (c) NetHack PC Development Team 1993-2019 # Copyright (c) NetHack PC Development Team 1993-2019
# #
#============================================================================== #==============================================================================
# Build Tools Environment # Build Tools Environment
# #
# NetHack 3.7 Makefile for MS Visual Studio Visual C++ compiler # NetHack 3.7 Work-in-progress Makefile for
# # MS Visual Studio Visual C++ compiler
#
# Visual Studio Compilers Tested: # Visual Studio Compilers Tested:
# - Microsoft Visual Studio 2017 Community Edition # - Microsoft Visual Studio 2017 Community Edition
# - Microsoft Visual Studio 2019 Community Edition # - Microsoft Visual Studio 2019 Community Edition
# #
#============================================================================== #==============================================================================
# This is used for building two versions of NetHack: # This is used for building two distinct executables of NetHack:
# #
# A tty port utilizing the Win32 Console I/O subsystem, Console # A tty port utilizing the Win32 Console I/O subsystem, Console
# NetHack.exe # NetHack.exe
@@ -19,59 +20,77 @@
# A Win32 native port built on the Windows API, Graphical NetHack or # A Win32 native port built on the Windows API, Graphical NetHack or
# NetHackW.exe # NetHackW.exe
# #
# In addition to your C compiler, # BEFORE YOU START, in addition to your C compiler and linker,
# #
# if you want to change you will need a # o You will need a complete Lua source tree parallel to your
# files with suffix workalike for # NetHack source tree. Lua is not an optional requirement,
# .y yacc (such as bison) # it is required in order to process the level and dungeon
# .l lex (such as flex) # description files during the game. You can obtain the
# Lua source from here:
# https://www.lua.org/download.html
# #
# If you have any questions read the sys/winnt/Install.nt file included # o If you want to include the curses Window port in the non-GUI
# with the distribution. # NetHack.exe build, you will need a complete PDCurses source
#======================================================================================== # tree parallel to your NetHack source tree. You can obtain the
# PDCurses source from here:
# https://sourceforge.net/projects/pdcurses/files/pdcurses/
# or via git from here:
# git clone https://github.com/wmcbrine/PDCurses.git ../pdcurses
#
# o If you want your build of NetHack to include support for
# compressing your save files, or to be able to exchange and use
# compressed save files that originated on another platform such
# as Linux or a handheld phone or tablet, then you will need
# a copy of the zlib source tree parallel to your NetHack source
# tree. You can obtain the zlib source from here:
# https://www.zlib.net/zlib1211.zip
#
# If you want to find out more information about Lua, PDCurses, or zlib,
# here are the home page links for each at the time of this writing:
#
# Lua: https://www.lua.org/
# PDCurses: https://pdcurses.org/
# zlib: https://www.zlib.net/
#
# If you have any questions about building NetHack for the Windows platform
# please read sys/winnt/Install.nt file included in the distribution.
#
#==============================================================================
# DECISIONS SECTION # DECISIONS SECTION
# #
# Build Options Decisions # Build Options Decisions
# #
# There are currently 4 decisions that you can choose to make. # There are currently 5 decisions that you can choose to make.
# none of the 4 decisions are absolutely required because defaults are in place: # none of the 5 decisions are absolutely required because defaults
# 1. Where do you want your build to end up? # are in place:
# 2. Do you want debug information in the executable?
# 3. Do you want to explicitly override auto-detection of a 32-bit or 64-bit target?
# 4. Do you want to include the optional curses port?
# #
# Mandatory LUA source Location # 1. Where do you want your build results to end up?
# 2. Do you want to include the optional curses port?
# 3. Do you want to include compressed savefile support to
# transfer compressed savefiles between platforms?
# 4. Do you want debug information in the executable?
# 5. Do you want to explicitly override auto-detection of
# a 32-bit or 64-bit target?
# #
# LUA source code or is required to build NetHack-3.7. # Mandatory Lua source Location (not optional)
# LUATOP must point to the location of the LUA sources.
# #
#----------------------------------------------------------------------------------------- # Lua source code or is required to build NetHack-3.7.
#========================================================================================= # LUATOP below must point to the correct location of the LUA sources.
# By default it is assumed to be parallel to your NetHack source tree in
#--------------------------------------------------------------- # the same parent directory/folder.
#
#------------------------------------------------------------------------------
#==============================================================================
#
#------------------------------------------------------------------------------
# 1. Where do you want the game to be built (which folder)? # 1. Where do you want the game to be built (which folder)?
GAMEDIR = ..\binary # Default game build directory
#---------------------------------------------------------------
# 2. Do you want debug information available to the executable?
DEBUGINFO = Y
#---------------------------------------------------------------
# 3. This Makefile will attempt to auto-detect your selected target architecture
# based on Visual Studio command prompt configuration settins etc.
# However, if you want to manually override generation of a
# 32-bit or 64-bit build target, you can uncomment the apppropriate
# TARGET_CPU line below.
# #
#TARGET_CPU=x64 GAMEDIR = ..\binary # Default game build directory
#TARGET_CPU=x86 #
#------------------------------------------------------------------------------
#---------------------------------------------------------------
# OPTIONAL - Curses window port support # OPTIONAL - Curses window port support
# #
# 4. Uncomment these and set them appropriately if you want to # 2. Uncomment these and set them appropriately if you want to
# include curses port support alongside TTY support in your # include curses port support alongside TTY support in your
# NetHack.exe binary. # NetHack.exe binary.
# #
@@ -79,10 +98,40 @@ DEBUGINFO = Y
# PDCurses header (.h) files and PDCURSES_C to the location # PDCurses header (.h) files and PDCURSES_C to the location
# of your PDCurses C files. # of your PDCurses C files.
# #
ADD_CURSES=Y #ADD_CURSES=Y
PDCURSES_TOP=..\..\pdcurses #PDCURSES_TOP=..\..\pdcurses
#
#------------------------------------------------------------------------------
# OPTIONAL - zlib support (to allow compressed savefile exchange across platforms
#
# 3. Location of zlib sources
#
#
#ADD_ZLIB=Y
#ZLIBTOP=..\..\zlib
#
#------------------------------------------------------------------------------
# 4. Do you want debug information available to the executable?
#
DEBUGINFO = Y
#
#------------------------------------------------------------------------------
# 5. This Makefile will attempt to auto-detect your selected target architecture
# based on Visual Studio command prompt configuration settins etc.
# However, if you want to manually override generation of a
# 32-bit or 64-bit build target, you can uncomment the apppropriate
# TARGET_CPU line below.
#
#TARGET_CPU=x64
#TARGET_CPU=x86
#
#
#==============================================================================
#==============================================================================
# This marks the end of the BUILD DECISIONS section.
#==============================================================================
#==============================================================================
# #
#---------------------------------------------------------------
# Location of LUA # Location of LUA
# #
# Original source needs to be obtained from: # Original source needs to be obtained from:
@@ -91,23 +140,20 @@ PDCURSES_TOP=..\..\pdcurses
# This build assumes that the LUA sources are located # This build assumes that the LUA sources are located
# at the specified location. If they are actually elsewhere # at the specified location. If they are actually elsewhere
# you'll need to specify the correct spot below in order to # you'll need to specify the correct spot below in order to
# successfully build NetHack-3.7. # successfully build NetHack-3.7. You cannot build a functional
# version of NetHack-3.7 Work-in-progress without including Lua.
# #
LUATOP=..\..\lua-5.3.5 LUATOP=..\..\lua-5.3.5
# #
#============================================================================== #==============================================================================
# This marks the end of the BUILD DECISIONS section. #======================== End of Modification Section =========================
#============================================================================== #==============================================================================
# #
#=============================================== # #################################################
#======= End of Modification Section =========== # # #
#=============================================== # # Nothing below here should have to be changed. #
# # # #
################################################ # #################################################
# #
# Nothing below here should have to be changed.#
# #
################################################
# #
#============================================================================== #==============================================================================
# #