/* material strings */
E const char *materialnm[];
+/* empty string that is non-const for parameter use */
+E char emptystr[];
+
/* Monster name articles */
#define ARTICLE_NONE 0
#define ARTICLE_THE 1
#include "lualib.h"
#include "lauxlib.h"
+#if defined(WIN32)
+#define LUA_INTCAST(i) ((int) i)
+#else
+#define LUA_INTCAST(i) (i)
+#endif
+
#endif /* SYSTEM_H */
"platinum", "mithril", "plastic", "glass",
"gemstone", "stone" };
+char emptystr[] = {0}; /* non-const */
+
/* Global windowing data, defined here for multi-window-system support */
NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;
#ifdef WIN32
char menuletter;
};
+#if 0
static void FDECL(Fread, (genericptr_t, int, int, dlb *));
+#endif
static xchar FDECL(dname_to_dnum, (const char *));
static int FDECL(find_branch, (const char *, struct proto_dungeon *));
static xchar FDECL(parent_dnum, (const char *, struct proto_dungeon *));
}
}
+#if 0
static void
Fread(ptr, size, nitems, stream)
genericptr_t ptr;
nh_terminate(EXIT_FAILURE);
}
}
+#endif
static xchar
dname_to_dnum(s)
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nflags;
lua_len(L, -1);
- nflags = lua_tointeger(L, -1);
+ nflags = LUA_INTCAST(lua_tointeger(L, -1));
lua_pop(L, 1);
for (f = 0; f < nflags; f++) {
lua_pushinteger(L, f+1);
register s_level *x;
struct proto_dungeon pd;
struct level_map *lev_map;
+ int tidx;
+ nhUse(cb);
(void) memset(&pd, 0, sizeof(struct proto_dungeon));
pd.n_levs = pd.n_brs = 0;
panic("dungeon is not a lua table");
lua_len(L, -1);
- g.n_dgns = lua_tointeger(L, -1);
+ g.n_dgns = LUA_INTCAST(lua_tointeger(L, -1));
lua_pop(L, 1);
pd.start = 0;
if (g.n_dgns >= MAXDUNGEON)
panic("init_dungeons: too many dungeons");
- int tidx = lua_gettop(L);
+ tidx = lua_gettop(L);
lua_pushnil(L); /* first key */
i = 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))
panic("dungeon[%i] is not a lua table", i);
- char *dgn_name = get_table_str(L, "name");
- char *dgn_bonetag = get_table_str_opt(L, "bonetag", ""); /* TODO: single char or "none" */
- char *dgn_protoname = get_table_str_opt(L, "protofile", "");
- int dgn_base = get_table_int(L, "base");
- int dgn_range = get_table_int_opt(L, "range", 0);
- int dgn_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)];
- int dgn_entry = get_table_int_opt(L, "entry", 0);
- int dgn_chance = get_table_int_opt(L, "chance", 100);
- int dgn_flags = get_dgn_flags(L);
+ dgn_name = get_table_str(L, "name");
+ dgn_bonetag = get_table_str_opt(L, "bonetag", emptystr); /* TODO: single char or "none" */
+ dgn_protoname = get_table_str_opt(L, "protofile", emptystr);
+ dgn_base = get_table_int(L, "base");
+ dgn_range = get_table_int_opt(L, "range", 0);
+ dgn_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)];
+ dgn_entry = get_table_int_opt(L, "entry", 0);
+ dgn_chance = get_table_int_opt(L, "chance", 100);
+ dgn_flags = get_dgn_flags(L);
debugpline4("DUNGEON[%i]: %s, base=(%i,%i)", i, dgn_name, dgn_base, dgn_range);
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nlevels;
lua_len(L, -1);
- nlevels = lua_tointeger(L, -1);
+ nlevels = LUA_INTCAST(lua_tointeger(L, -1));
pd.tmpdungeon[i].levels = nlevels;
lua_pop(L, 1);
for (f = 0; f < nlevels; f++) {
if (lua_type(L, -1) == LUA_TTABLE) {
int bi;
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_range = get_table_int_opt(L, "range", 0);
int lvl_nlevels = get_table_int_opt(L, "nlevels", 0);
int lvl_align = dgnaligns2i[get_table_option(L, "alignment", "unaligned", dgnaligns)];
int lvl_flags = get_dgn_flags(L);
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);
tmpl->name = lvl_name;
tmpl->chainlvl = lvl_chain;
if (lua_type(L, -1) == LUA_TTABLE) {
int f, nbranches;
lua_len(L, -1);
- nbranches = lua_tointeger(L, -1);
+ nbranches = LUA_INTCAST(lua_tointeger(L, -1));
pd.tmpdungeon[i].branches = nbranches;
lua_pop(L, 1);
for (f = 0; f < nbranches; f++) {
static int FDECL(l_selection_flood, (lua_State *));
static int FDECL(l_selection_circle, (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_not, (lua_State *));
static int FDECL(l_selection_and, (lua_State *));
static int FDECL(l_selection_or, (lua_State *));
static int FDECL(l_selection_xor, (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_sub, (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 *
l_selection_check(L, index)
filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
} else {
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));
filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */
} else {
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));
/* lua_CFunction prototypes */
static int FDECL(nhl_test, (lua_State *));
static int FDECL(nhl_getmap, (lua_State *));
+#if 0
static int FDECL(nhl_setmap, (lua_State *));
+#endif
static int FDECL(nhl_pline, (lua_State *));
static int FDECL(nhl_verbalize, (lua_State *));
static int FDECL(nhl_menu, (lua_State *));
char *ter;
xchar typ;
- ter = get_table_str_opt(L, name, "");
+ ter = get_table_str_opt(L, name, emptystr);
if (name && *ter) {
typ = check_mapchr(ter);
if (typ == INVALID_TYPE)
int argc = lua_gettop(L);
if (argc == 2) {
- int x = lua_tointeger(L, 1);
- int y = lua_tointeger(L, 2);
+ int x = LUA_INTCAST(lua_tointeger(L, 1));
+ int y = LUA_INTCAST(lua_tointeger(L, 2));
if (x >= 0 && x < COLNO && y >= 0 && y < ROWNO) {
char buf[BUFSZ];
if (ltyp == LUA_TSTRING) {
const char *const boolstr[] = { "true", "false", "yes", "no", NULL };
const int boolstr2i[] = { TRUE, FALSE, TRUE, FALSE, -1 };
+
ret = luaL_checkoption(L, -1, NULL, boolstr);
+ nhUse(boolstr2i[0]);
} else if (ltyp == LUA_TBOOLEAN) {
ret = lua_toboolean(L, -1);
} else if (ltyp == LUA_TNUMBER) {
nhl_test(L)
lua_State *L;
{
+ int x, y;
+ char *name, Player[] = "Player";
+
/* discard any extra arguments passed in */
lua_settop(L, 1);
luaL_checktype(L, 1, LUA_TTABLE);
- int x = get_table_int(L, "x");
- int y = get_table_int(L, "y");
- char *name = get_table_str_opt(L, "name", "Player");
+ x = get_table_int(L, "x");
+ y = get_table_int(L, "y");
+ name = get_table_str_opt(L, "name", Player);
pline("TEST:{ x=%i, y=%i, name=\"%s\" }", x,y, name);
{"test", nhl_test},
{"getmap", nhl_getmap},
- /*{"setmap", nhl_setmap},*/
-
+#if 0
+ {"setmap", nhl_setmap},
+#endif
{"pline", nhl_pline},
{"verbalize", nhl_verbalize},
{"menu", nhl_menu},
static void FDECL(maze1xy, (coord *, int));
static void NDECL(fill_empty_maze);
static void FDECL(splev_initlev, (lev_init *));
+#if 0
+/* macosx complains that these are unused */
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_endroom, (struct sp_coder *));
static void FDECL(spo_trap, (struct sp_coder *));
static void FDECL(spo_gold, (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_terrain, (struct sp_coder *));
static void FDECL(spo_replace_terrain, (struct sp_coder *));
static void FDECL(spo_mazewalk, (struct sp_coder *));
static void FDECL(spo_wall_property, (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(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_table_region, (lua_State *, const char *, int *, int *, int *, int *, BOOLEAN_P));
}
}
+#if 0
static long
sp_code_jmpaddr(curpos, jmpaddr)
long curpos, jmpaddr;
{
return (curpos + jmpaddr);
}
-
+#endif
/*ARGUSED*/
{
char *levmsg;
int old_n, n;
+ const char *msg;
int argc = lua_gettop(L);
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;
n = strlen(msg);
get_table_align(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 };
- int a = aligns2i[get_table_option(L, "align", "random", aligns)];
+ int a = aligns2i[get_table_option(L, "align", "random", gtaligns)];
return a;
}
for (i = LOW_PM; i < NUMMONS; i++)
if (!strcmpi(mons[i].mname, s))
return i;
+ nhUse(L);
return NON_PM;
}
tmpmons.coord = SP_COORD_PACK(mx, my);
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);
int rndval;
{
int ret;
+ char buf[BUFSZ];
lua_getfield(L, 1, name);
if (lua_type(L, -1) == LUA_TNIL) {
lua_pop(L, 1);
return rndval;
}
- char buf[BUFSZ];
Sprintf(buf, "Expected integer or \"random\" for \"%s\", got %s", name, tmp);
nhl_error(L, buf);
lua_pop(L, 1);
lspo_object(L)
lua_State *L;
{
+#if 0
int nparams = 0;
+#endif
long quancnt;
object tmpobj;
int ox = -1, oy = -1;
tmpobj.id = -1;
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);
+
if (montype) {
struct permonst *pm = NULL;
if (strlen(montype) == 1 && def_char_to_monclass(*montype) != MAXMCLASSES) {
nhl_error(L, "Unknown montype");
}
if (tmpobj.id == STATUE) {
- flags |= (get_table_boolean_opt(L, "historic", 0) ? STATUE_HISTORIC : 0x00);
- flags |= (get_table_boolean_opt(L, "male", 0) ? STATUE_MALE : 0x00);
- flags |= (get_table_boolean_opt(L, "female", 0) ? STATUE_FEMALE : 0x00);
- tmpobj.spe = flags;
+ lflags |= (get_table_boolean_opt(L, "historic", 0) ? STATUE_HISTORIC : 0x00);
+ lflags |= (get_table_boolean_opt(L, "male", 0) ? STATUE_MALE : 0x00);
+ lflags |= (get_table_boolean_opt(L, "female", 0) ? STATUE_FEMALE : 0x00);
+ tmpobj.spe = lflags;
} else if (tmpobj.id == EGG) {
tmpobj.spe = get_table_boolean_opt(L, "laid_by_you", 0) ? 1 : 0;
}
lspo_engraving(L)
lua_State *L;
{
- int etyp;
+ int etyp = DUST;
char *txt = (char *) 0;
long ecoord;
const char *const engrtypes[] = { "dust", "engrave", "burn", "mark", "blood", NULL };
xchar x, y;
int argc = lua_gettop(L);
+ x = y = 0; /* FIXME: quiet a warning for else clause below.
+ should it actually be -1? */
create_des_coder();
if (argc == 1) {
txt = dupstr(luaL_checkstring(L, 3));
} else {
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)
const char *name;
int defval;
{
- char *roomstr = get_table_str_opt(L, name, "");
+ char *roomstr = get_table_str_opt(L, name, emptystr);
if (roomstr && *roomstr) {
int i;
for (i = 0; room_types[i].name; i++)
static void
spo_endroom(coder)
-struct sp_coder *coder;
+struct sp_coder *coder UNUSED;
{
if (g.coder->n_subroom > 1) {
g.coder->n_subroom--;
const int stairdirs2i[] = { 0, 1 };
long scoord;
- int ax = -1,ay = -1;
+ int ax = -1, ay = -1;
int up;
int ltype = lua_type(L, 1);
create_des_coder();
- if (argc == 1 && ltype == LUA_TSTRING)
+ if (argc == 1 && ltype == LUA_TSTRING) {
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)];
ax = luaL_checkinteger(L, 2);
ay = luaL_checkinteger(L, 3);
const int stairdirs2i[] = { 0, 1 };
long scoord;
- int ax, ay;
+ int ax = -1, ay = -1; /* FIXME: initializers added, macosx warning */
int up;
int ltype = lua_type(L, 1);
create_des_coder();
- if (argc == 1 && ltype == LUA_TSTRING)
+ if (argc == 1 && ltype == LUA_TSTRING) {
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)];
ax = luaL_checkinteger(L, 2);
ay = luaL_checkinteger(L, 3);
const char *name;
int defval;
{
- char *trapstr = get_table_str_opt(L, name, "");
+ char *trapstr = get_table_str_opt(L, name, emptystr);
if (trapstr && *trapstr) {
int i;
for (i = 0; trap_types[i].name; i++)
/* random_corridors(); */
int
lspo_random_corridors(L)
-lua_State *L;
+lua_State *L UNUSED;
{
corridor tc;
return 0;
}
+#if 0
/*ARGSUSED*/
static void
sel_set_wallify(x, y, arg)
{
wallify_map(x, y, x, y);
}
+#endif
/* TODO: wallify(selection) */
/* wallify({ x1=NN,y1=NN, x2=NN,y2=NN }); */
/* reset_level is only needed for testing purposes */
int
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);