bad merge fix

This commit is contained in:
nhmall
2019-11-16 17:33:37 -05:00
parent 6aef1f13a1
commit 0bc2cd281c

View File

@@ -1,30 +1,30 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1560611967 2019/06/15 15:19:27 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */ /* NetHack 3.6 do_name.c $NHDT-Date: 1573940540 2019/11/16 21:42:20 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.150 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2018. */ /*-Copyright (c) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #include "hack.h"
STATIC_DCL char *NDECL(nextmbuf); static char *NDECL(nextmbuf);
STATIC_DCL void FDECL(getpos_help, (BOOLEAN_P, const char *)); static void FDECL(getpos_help, (BOOLEAN_P, const char *));
STATIC_DCL int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *)); static int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *));
STATIC_DCL boolean FDECL(gather_locs_interesting, (int, int, int)); static boolean FDECL(gather_locs_interesting, (int, int, int));
STATIC_DCL void FDECL(gather_locs, (coord **, int *, int)); static void FDECL(gather_locs, (coord **, int *, int));
STATIC_DCL int FDECL(gloc_filter_floodfill_matcharea, (int, int)); static int FDECL(gloc_filter_floodfill_matcharea, (int, int));
STATIC_DCL void FDECL(auto_describe, (int, int)); static void FDECL(auto_describe, (int, int));
STATIC_DCL void NDECL(do_mname); static void NDECL(do_mname);
STATIC_DCL boolean FDECL(alreadynamed, (struct monst *, char *, char *)); static boolean FDECL(alreadynamed, (struct monst *, char *, char *));
STATIC_DCL void FDECL(do_oname, (struct obj *)); static void FDECL(do_oname, (struct obj *));
STATIC_PTR char *FDECL(docall_xname, (struct obj *)); static char *FDECL(docall_xname, (struct obj *));
STATIC_DCL void NDECL(namefloorobj); static void NDECL(namefloorobj);
STATIC_DCL char *FDECL(bogusmon, (char *,char *)); static char *FDECL(bogusmon, (char *,char *));
extern const char what_is_an_unknown_object[]; /* from pager.c */ extern const char what_is_an_unknown_object[]; /* from pager.c */
#define NUMMBUF 5 #define NUMMBUF 5
/* manage a pool of BUFSZ buffers, so callers don't have to */ /* manage a pool of BUFSZ buffers, so callers don't have to */
STATIC_OVL char * static char *
nextmbuf() nextmbuf()
{ {
static char NEARDATA bufs[NUMMBUF][BUFSZ]; static char NEARDATA bufs[NUMMBUF][BUFSZ];
@@ -87,7 +87,7 @@ int gloc;
} }
/* the response for '?' help request in getpos() */ /* the response for '?' help request in getpos() */
STATIC_OVL void static void
getpos_help(force, goal) getpos_help(force, goal)
boolean force; boolean force;
const char *goal; const char *goal;
@@ -100,7 +100,7 @@ const char *goal;
Sprintf(sbuf, Sprintf(sbuf,
"Use '%c', '%c', '%c', '%c' to move the cursor to %s.", /* hjkl */ "Use '%c', '%c', '%c', '%c' to move the cursor to %s.", /* hjkl */
Cmd.move_W, Cmd.move_S, Cmd.move_N, Cmd.move_E, goal); g.Cmd.move_W, g.Cmd.move_S, g.Cmd.move_N, g.Cmd.move_E, goal);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
"Use 'H', 'J', 'K', 'L' to fast-move the cursor, %s.", "Use 'H', 'J', 'K', 'L' to fast-move the cursor, %s.",
@@ -108,47 +108,47 @@ const char *goal;
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
putstr(tmpwin, 0, "Or enter a background symbol (ex. '<')."); putstr(tmpwin, 0, "Or enter a background symbol (ex. '<').");
Sprintf(sbuf, "Use '%s' to move the cursor on yourself.", Sprintf(sbuf, "Use '%s' to move the cursor on yourself.",
visctrl(Cmd.spkeys[NHKF_GETPOS_SELF])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_SELF]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_MON_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_MON_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_PREV]),
GLOC_MONS); GLOC_MONS);
} }
if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) {
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]),
GLOC_OBJS); GLOC_OBJS);
} }
if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) {
/* these are primarily useful when choosing a travel /* these are primarily useful when choosing a travel
destination for the '_' command */ destination for the '_' command */
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]),
GLOC_DOOR); GLOC_DOOR);
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
GLOC_EXPLORE); GLOC_EXPLORE);
getpos_help_keyxhelp(tmpwin, getpos_help_keyxhelp(tmpwin,
visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
GLOC_INTERESTING); GLOC_INTERESTING);
} }
Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.", Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.",
visctrl(Cmd.spkeys[NHKF_GETPOS_MOVESKIP]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]),
fastmovemode[!iflags.getloc_moveskip]); fastmovemode[!iflags.getloc_moveskip]);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) { if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) {
Sprintf(sbuf, "Use '%s' to toggle menu listing for possible targets.", Sprintf(sbuf, "Use '%s' to toggle menu listing for possible targets.",
visctrl(Cmd.spkeys[NHKF_GETPOS_MENU])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_MENU]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
"Use '%s' to change the mode of limiting possible targets.", "Use '%s' to change the mode of limiting possible targets.",
visctrl(Cmd.spkeys[NHKF_GETPOS_LIMITVIEW])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
if (!iflags.terrainmode) { if (!iflags.terrainmode) {
@@ -156,56 +156,56 @@ const char *goal;
if (getpos_getvalid) { if (getpos_getvalid) {
Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.", Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.",
visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]),
visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_PREV])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_PREV]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
if (getpos_hilitefunc) { if (getpos_hilitefunc) {
Sprintf(sbuf, "Use '%s' to display valid locations.", Sprintf(sbuf, "Use '%s' to display valid locations.",
visctrl(Cmd.spkeys[NHKF_GETPOS_SHOWVALID])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
Sprintf(sbuf, "Use '%s' to toggle automatic description.", Sprintf(sbuf, "Use '%s' to toggle automatic description.",
visctrl(Cmd.spkeys[NHKF_GETPOS_AUTODESC])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */ if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */
Sprintf(sbuf, Sprintf(sbuf,
(iflags.getpos_coords == GPCOORDS_NONE) (iflags.getpos_coords == GPCOORDS_NONE)
? "(Set 'whatis_coord' option to include coordinates with '%s' text.)" ? "(Set 'whatis_coord' option to include coordinates with '%s' text.)"
: "(Reset 'whatis_coord' option to omit coordinates from '%s' text.)", : "(Reset 'whatis_coord' option to omit coordinates from '%s' text.)",
visctrl(Cmd.spkeys[NHKF_GETPOS_AUTODESC])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]));
} }
/* disgusting hack; the alternate selection characters work for any /* disgusting hack; the alternate selection characters work for any
getpos call, but only matter for dowhatis (and doquickwhatis) */ getpos call, but only matter for dowhatis (and doquickwhatis) */
doing_what_is = (goal == what_is_an_unknown_object); doing_what_is = (goal == what_is_an_unknown_object);
if (doing_what_is) { if (doing_what_is) {
Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'", Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_Q]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_O]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]),
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_V])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V]));
} else { } else {
Sprintf(kbuf, "'%s'", visctrl(Cmd.spkeys[NHKF_GETPOS_PICK])); Sprintf(kbuf, "'%s'", visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
} }
Sprintf(sbuf, "Type a %s when you are at the right place.", kbuf); Sprintf(sbuf, "Type a %s when you are at the right place.", kbuf);
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
if (doing_what_is) { if (doing_what_is) {
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, show 'more info', move to another spot.", " '%s' describe current spot, show 'more info', move to another spot.",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_V])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot,%s move to another spot;", " '%s' describe current spot,%s move to another spot;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]), visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]),
flags.help ? " prompt if 'more info'," : ""); flags.help ? " prompt if 'more info'," : "");
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, move to another spot;", " '%s' describe current spot, move to another spot;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_Q])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
Sprintf(sbuf, Sprintf(sbuf,
" '%s' describe current spot, stop looking at things;", " '%s' describe current spot, stop looking at things;",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_O])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]));
putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, sbuf);
} }
} }
@@ -216,7 +216,7 @@ const char *goal;
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
} }
STATIC_OVL int static int
cmp_coord_distu(a, b) cmp_coord_distu(a, b)
const void *a; const void *a;
const void *b; const void *b;
@@ -244,13 +244,9 @@ const void *b;
&& glyph_to_cmap(levl[(x)][(y)].glyph) == S_stone \ && glyph_to_cmap(levl[(x)][(y)].glyph) == S_stone \
&& !levl[(x)][(y)].seenv) && !levl[(x)][(y)].seenv)
static struct opvar *gloc_filter_map = (struct opvar *) 0;
#define GLOC_SAME_AREA(x,y) \ #define GLOC_SAME_AREA(x,y) \
(isok((x), (y)) \ (isok((x), (y)) \
&& (selection_getpoint((x),(y), gloc_filter_map))) && (selection_getpoint((x),(y), g.gloc_filter_map)))
static int gloc_filter_floodfill_match_glyph;
int int
gloc_filter_classify_glyph(glyph) gloc_filter_classify_glyph(glyph)
@@ -276,7 +272,7 @@ int glyph;
return 0; return 0;
} }
STATIC_OVL int static int
gloc_filter_floodfill_matcharea(x, y) gloc_filter_floodfill_matcharea(x, y)
int x, y; int x, y;
{ {
@@ -285,11 +281,11 @@ int x, y;
if (!levl[x][y].seenv) if (!levl[x][y].seenv)
return FALSE; return FALSE;
if (glyph == gloc_filter_floodfill_match_glyph) if (glyph == g.gloc_filter_floodfill_match_glyph)
return TRUE; return TRUE;
if (gloc_filter_classify_glyph(glyph) if (gloc_filter_classify_glyph(glyph)
== gloc_filter_classify_glyph(gloc_filter_floodfill_match_glyph)) == gloc_filter_classify_glyph(g.gloc_filter_floodfill_match_glyph))
return TRUE; return TRUE;
return FALSE; return FALSE;
@@ -299,18 +295,18 @@ void
gloc_filter_floodfill(x, y) gloc_filter_floodfill(x, y)
int x, y; int x, y;
{ {
gloc_filter_floodfill_match_glyph = back_to_glyph(x, y); g.gloc_filter_floodfill_match_glyph = back_to_glyph(x, y);
set_selection_floodfillchk(gloc_filter_floodfill_matcharea); set_selection_floodfillchk(gloc_filter_floodfill_matcharea);
selection_floodfill(gloc_filter_map, x, y, FALSE); selection_floodfill(g.gloc_filter_map, x, y, FALSE);
} }
void void
gloc_filter_init() gloc_filter_init()
{ {
if (iflags.getloc_filter == GFILTER_AREA) { if (iflags.getloc_filter == GFILTER_AREA) {
if (!gloc_filter_map) { if (!g.gloc_filter_map) {
gloc_filter_map = selection_opvar((char *) 0); g.gloc_filter_map = selection_new();
} }
/* special case: if we're in a doorway, try to figure out which /* special case: if we're in a doorway, try to figure out which
direction we're moving, and use that side of the doorway */ direction we're moving, and use that side of the doorway */
@@ -329,13 +325,14 @@ gloc_filter_init()
void void
gloc_filter_done() gloc_filter_done()
{ {
if (gloc_filter_map) { if (g.gloc_filter_map) {
opvar_free_x(gloc_filter_map); selection_free(g.gloc_filter_map);
gloc_filter_map = (struct opvar *) 0; g.gloc_filter_map = (struct selectionvar *) 0;
} }
} }
STATIC_OVL boolean static boolean
gather_locs_interesting(x, y, gloc) gather_locs_interesting(x, y, gloc)
int x, y, gloc; int x, y, gloc;
{ {
@@ -407,7 +404,7 @@ int x, y, gloc;
} }
/* gather locations for monsters or objects shown on the map */ /* gather locations for monsters or objects shown on the map */
STATIC_OVL void static void
gather_locs(arr_p, cnt_p, gloc) gather_locs(arr_p, cnt_p, gloc)
coord **arr_p; coord **arr_p;
int *cnt_p; int *cnt_p;
@@ -534,7 +531,7 @@ char *outbuf, cmode;
return outbuf; return outbuf;
} }
STATIC_OVL void static void
auto_describe(cx, cy) auto_describe(cx, cy)
int cx, cy; int cx, cy;
{ {
@@ -585,7 +582,7 @@ int gloc;
tmpwin = create_nhwindow(NHW_MENU); tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin); start_menu(tmpwin);
any = zeroany; any = cg.zeroany;
/* gather_locs returns array[0] == you. skip it. */ /* gather_locs returns array[0] == you. skip it. */
for (i = 1; i < gcount; i++) { for (i = 1; i < gcount; i++) {
@@ -666,18 +663,18 @@ const char *goal;
int gidx[NUM_GLOCS] = DUMMY; int gidx[NUM_GLOCS] = DUMMY;
for (i = 0; i < SIZE(pick_chars_def); i++) for (i = 0; i < SIZE(pick_chars_def); i++)
pick_chars[i] = Cmd.spkeys[pick_chars_def[i].nhkf]; pick_chars[i] = g.Cmd.spkeys[pick_chars_def[i].nhkf];
pick_chars[SIZE(pick_chars_def)] = '\0'; pick_chars[SIZE(pick_chars_def)] = '\0';
for (i = 0; i < SIZE(mMoOdDxX_def); i++) for (i = 0; i < SIZE(mMoOdDxX_def); i++)
mMoOdDxX[i] = Cmd.spkeys[mMoOdDxX_def[i]]; mMoOdDxX[i] = g.Cmd.spkeys[mMoOdDxX_def[i]];
mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0'; mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0';
if (!goal) if (!goal)
goal = "desired location"; goal = "desired location";
if (flags.verbose) { if (flags.verbose) {
pline("(For instructions type a '%s')", pline("(For instructions type a '%s')",
visctrl(Cmd.spkeys[NHKF_GETPOS_HELP])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_HELP]));
msg_given = TRUE; msg_given = TRUE;
} }
cx = ccp->x; cx = ccp->x;
@@ -712,7 +709,7 @@ const char *goal;
if (iflags.autodescribe) if (iflags.autodescribe)
msg_given = FALSE; msg_given = FALSE;
if (c == Cmd.spkeys[NHKF_ESC]) { if (c == g.Cmd.spkeys[NHKF_ESC]) {
cx = cy = -10; cx = cy = -10;
msg_given = TRUE; /* force clear */ msg_given = TRUE; /* force clear */
result = -1; result = -1;
@@ -734,12 +731,12 @@ const char *goal;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
int dx, dy; int dx, dy;
if (Cmd.dirchars[i] == c) { if (g.Cmd.dirchars[i] == c) {
/* a normal movement letter or digit */ /* a normal movement letter or digit */
dx = xdir[i]; dx = xdir[i];
dy = ydir[i]; dy = ydir[i];
} else if (Cmd.alphadirchars[i] == lowc((char) c) } else if (g.Cmd.alphadirchars[i] == lowc((char) c)
|| (Cmd.num_pad && Cmd.dirchars[i] == (c & 0177))) { || (g.Cmd.num_pad && g.Cmd.dirchars[i] == (c & 0177))) {
/* a shifted movement letter or Meta-digit */ /* a shifted movement letter or Meta-digit */
if (iflags.getloc_moveskip) { if (iflags.getloc_moveskip) {
/* skip same glyphs */ /* skip same glyphs */
@@ -782,15 +779,15 @@ const char *goal;
goto nxtc; goto nxtc;
} }
if (c == Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) { if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) {
if (c == Cmd.spkeys[NHKF_GETPOS_HELP]) if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP])
getpos_help(force, goal); getpos_help(force, goal);
else /* ^R */ else /* ^R */
docrt(); /* redraw */ docrt(); /* redraw */
/* update message window to reflect that we're still targetting */ /* update message window to reflect that we're still targetting */
show_goal_msg = TRUE; show_goal_msg = TRUE;
msg_given = TRUE; msg_given = TRUE;
} else if (c == Cmd.spkeys[NHKF_GETPOS_SHOWVALID] } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID]
&& getpos_hilitefunc) { && getpos_hilitefunc) {
if (!hilite_state) { if (!hilite_state) {
(*getpos_hilitefunc)(0); (*getpos_hilitefunc)(0);
@@ -798,7 +795,7 @@ const char *goal;
hilite_state = TRUE; hilite_state = TRUE;
} }
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_AUTODESC]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]) {
iflags.autodescribe = !iflags.autodescribe; iflags.autodescribe = !iflags.autodescribe;
pline("Automatic description %sis %s.", pline("Automatic description %sis %s.",
flags.verbose ? "of features under cursor " : "", flags.verbose ? "of features under cursor " : "",
@@ -807,7 +804,7 @@ const char *goal;
show_goal_msg = TRUE; show_goal_msg = TRUE;
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) {
static const char *const view_filters[NUM_GFILTER] = { static const char *const view_filters[NUM_GFILTER] = {
"Not limiting targets", "Not limiting targets",
"Limiting targets to those in sight", "Limiting targets to those in sight",
@@ -825,7 +822,7 @@ const char *goal;
pline("%s.", view_filters[iflags.getloc_filter]); pline("%s.", view_filters[iflags.getloc_filter]);
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_MENU]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MENU]) {
iflags.getloc_usemenu = !iflags.getloc_usemenu; iflags.getloc_usemenu = !iflags.getloc_usemenu;
pline("%s a menu to show possible targets%s.", pline("%s a menu to show possible targets%s.",
iflags.getloc_usemenu ? "Using" : "Not using", iflags.getloc_usemenu ? "Using" : "Not using",
@@ -833,7 +830,7 @@ const char *goal;
? " for 'm|M', 'o|O', 'd|D', and 'x|X'" : ""); ? " for 'm|M', 'o|O', 'd|D', and 'x|X'" : "");
msg_given = TRUE; msg_given = TRUE;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_SELF]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SELF]) {
/* reset 'm&M', 'o&O', &c; otherwise, there's no way for player /* reset 'm&M', 'o&O', &c; otherwise, there's no way for player
to achieve that except by manually cycling through all spots */ to achieve that except by manually cycling through all spots */
for (i = 0; i < NUM_GLOCS; i++) for (i = 0; i < NUM_GLOCS; i++)
@@ -841,7 +838,7 @@ const char *goal;
cx = u.ux; cx = u.ux;
cy = u.uy; cy = u.uy;
goto nxtc; goto nxtc;
} else if (c == Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) { } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) {
iflags.getloc_moveskip = !iflags.getloc_moveskip; iflags.getloc_moveskip = !iflags.getloc_moveskip;
pline("%skipping over similar terrain when fastmoving the cursor.", pline("%skipping over similar terrain when fastmoving the cursor.",
iflags.getloc_moveskip ? "S" : "Not s"); iflags.getloc_moveskip ? "S" : "Not s");
@@ -887,7 +884,7 @@ const char *goal;
|| glyph_to_cmap(k) == S_corr || glyph_to_cmap(k) == S_corr
|| glyph_to_cmap(k) == S_litcorr) || glyph_to_cmap(k) == S_litcorr)
continue; continue;
if (c == defsyms[sidx].sym || c == (int) showsyms[sidx]) if (c == defsyms[sidx].sym || c == (int) g.showsyms[sidx])
matching[sidx] = (char) ++k; matching[sidx] = (char) ++k;
} }
if (k) { if (k) {
@@ -908,7 +905,7 @@ const char *goal;
goto foundc; goto foundc;
/* next, try glyph that's remembered here /* next, try glyph that's remembered here
(might be trap or object) */ (might be trap or object) */
if (level.flags.hero_memory if (g.level.flags.hero_memory
/* !terrainmode: don't move to remembered /* !terrainmode: don't move to remembered
trap or object if not currently shown */ trap or object if not currently shown */
&& !iflags.terrainmode) { && !iflags.terrainmode) {
@@ -918,7 +915,7 @@ const char *goal;
goto foundc; goto foundc;
} }
/* last, try actual terrain here (shouldn't /* last, try actual terrain here (shouldn't
we be using lastseentyp[][] instead?) */ we be using g.lastseentyp[][] instead?) */
if (levl[tx][ty].seenv) { if (levl[tx][ty].seenv) {
k = back_to_glyph(tx, ty); k = back_to_glyph(tx, ty);
if (glyph_is_cmap(k) if (glyph_is_cmap(k)
@@ -946,8 +943,8 @@ const char *goal;
Strcpy(note, "aborted"); Strcpy(note, "aborted");
else /* hjkl */ else /* hjkl */
Sprintf(note, "use '%c', '%c', '%c', '%c' or '%s'", Sprintf(note, "use '%c', '%c', '%c', '%c' or '%s'",
Cmd.move_W, Cmd.move_S, Cmd.move_N, Cmd.move_E, g.Cmd.move_W, g.Cmd.move_S, g.Cmd.move_N, g.Cmd.move_E,
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK])); visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
pline("Unknown direction: '%s' (%s).", visctrl((char) c), pline("Unknown direction: '%s' (%s).", visctrl((char) c),
note); note);
msg_given = TRUE; msg_given = TRUE;
@@ -1071,7 +1068,7 @@ const char *name;
int lth; int lth;
char buf[PL_PSIZ]; char buf[PL_PSIZ];
/* dogname & catname are PL_PSIZ arrays; object names have same limit */ /* g.dogname & g.catname are PL_PSIZ arrays; object names have same limit */
lth = (name && *name) ? ((int) strlen(name) + 1) : 0; lth = (name && *name) ? ((int) strlen(name) + 1) : 0;
if (lth > PL_PSIZ) { if (lth > PL_PSIZ) {
lth = PL_PSIZ; lth = PL_PSIZ;
@@ -1086,7 +1083,7 @@ const char *name;
/* check whether user-supplied name matches or nearly matches an unnameable /* check whether user-supplied name matches or nearly matches an unnameable
monster's name; if so, give an alternate reject message for do_mname() */ monster's name; if so, give an alternate reject message for do_mname() */
STATIC_OVL boolean static boolean
alreadynamed(mtmp, monnambuf, usrbuf) alreadynamed(mtmp, monnambuf, usrbuf)
struct monst *mtmp; struct monst *mtmp;
char *monnambuf, *usrbuf; char *monnambuf, *usrbuf;
@@ -1116,7 +1113,7 @@ char *monnambuf, *usrbuf;
} }
/* allow player to assign a name to some chosen monster */ /* allow player to assign a name to some chosen monster */
STATIC_OVL void static void
do_mname() do_mname()
{ {
char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ]; char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ];
@@ -1140,7 +1137,7 @@ do_mname()
mtmp = u.usteed; mtmp = u.usteed;
} else { } else {
pline("This %s creature is called %s and cannot be renamed.", pline("This %s creature is called %s and cannot be renamed.",
beautiful(), plname); beautiful(), g.plname);
return; return;
} }
} else } else
@@ -1195,14 +1192,12 @@ do_mname()
(void) christen_monst(mtmp, buf); (void) christen_monst(mtmp, buf);
} }
STATIC_VAR int via_naming = 0;
/* /*
* This routine used to change the address of 'obj' so be unsafe if not * This routine used to change the address of 'obj' so be unsafe if not
* used with extreme care. Applying a name to an object no longer * used with extreme care. Applying a name to an object no longer
* allocates a replacement object, so that old risk is gone. * allocates a replacement object, so that old risk is gone.
*/ */
STATIC_OVL static
void void
do_oname(obj) do_oname(obj)
register struct obj *obj; register struct obj *obj;
@@ -1274,9 +1269,9 @@ register struct obj *obj;
a valid artifact name */ a valid artifact name */
u.uconduct.literate++; u.uconduct.literate++;
} }
++via_naming; /* This ought to be an argument rather than a static... */ ++g.via_naming; /* This ought to be an argument rather than a static... */
obj = oname(obj, buf); obj = oname(obj, buf);
--via_naming; /* ...but oname() is used in a lot of places, so defer. */ --g.via_naming; /* ...but oname() is used in a lot of places, so defer. */
} }
struct obj * struct obj *
@@ -1316,7 +1311,7 @@ const char *name;
/* if obj is owned by a shop, increase your bill */ /* if obj is owned by a shop, increase your bill */
if (obj->unpaid) if (obj->unpaid)
alter_cost(obj, 0L); alter_cost(obj, 0L);
if (via_naming) { if (g.via_naming) {
/* violate illiteracy conduct since successfully wrote arti-name */ /* violate illiteracy conduct since successfully wrote arti-name */
u.uconduct.literate++; u.uconduct.literate++;
} }
@@ -1354,11 +1349,11 @@ docallcmd()
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
start_menu(win); start_menu(win);
any = zeroany; any = cg.zeroany;
any.a_char = 'm'; /* group accelerator 'C' */ any.a_char = 'm'; /* group accelerator 'C' */
add_menu(win, NO_GLYPH, &any, abc ? 0 : any.a_char, 'C', ATR_NONE, add_menu(win, NO_GLYPH, &any, abc ? 0 : any.a_char, 'C', ATR_NONE,
"a monster", MENU_UNSELECTED); "a monster", MENU_UNSELECTED);
if (invent) { if (g.invent) {
/* we use y and n as accelerators so that we can accept user's /* we use y and n as accelerators so that we can accept user's
response keyed to old "name an individual object?" prompt */ response keyed to old "name an individual object?" prompt */
any.a_char = 'i'; /* group accelerator 'y' */ any.a_char = 'i'; /* group accelerator 'y' */
@@ -1432,7 +1427,7 @@ docallcmd()
} }
/* for use by safe_qbuf() */ /* for use by safe_qbuf() */
STATIC_PTR char * static char *
docall_xname(obj) docall_xname(obj)
struct obj *obj; struct obj *obj;
{ {
@@ -1512,7 +1507,7 @@ struct obj *obj;
} }
} }
STATIC_OVL void static void
namefloorobj() namefloorobj()
{ {
coord cc; coord cc;
@@ -1526,7 +1521,7 @@ namefloorobj()
been moved off the hero's '@' yet, but there's no way to adjust been moved off the hero's '@' yet, but there's no way to adjust
the help text once getpos() has started */ the help text once getpos() has started */
Sprintf(buf, "object on map (or '.' for one %s you)", Sprintf(buf, "object on map (or '.' for one %s you)",
(u.uundetected && hides_under(youmonst.data)) ? "over" : "under"); (u.uundetected && hides_under(g.youmonst.data)) ? "over" : "under");
if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0) if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0)
return; return;
if (cc.x == u.ux && cc.y == u.uy) { if (cc.x == u.ux && cc.y == u.uy) {
@@ -1557,9 +1552,9 @@ namefloorobj()
char tmpbuf[BUFSZ]; char tmpbuf[BUFSZ];
/* straight role name */ /* straight role name */
unames[0] = ((Upolyd ? u.mfemale : flags.female) && urole.name.f) unames[0] = ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f)
? urole.name.f ? g.urole.name.f
: urole.name.m; : g.urole.name.m;
/* random rank title for hero's role /* random rank title for hero's role
note: the 30 is hardcoded in xlev_to_rank, so should be note: the 30 is hardcoded in xlev_to_rank, so should be
@@ -1607,7 +1602,7 @@ static const char *const ghostnames[] = {
const char * const char *
rndghostname() rndghostname()
{ {
return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] : (const char *) plname; return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] : (const char *) g.plname;
} }
/* /*
@@ -1657,7 +1652,7 @@ boolean called;
boolean name_at_start, has_adjectives; boolean name_at_start, has_adjectives;
char *bp; char *bp;
if (program_state.gameover) if (g.program_state.gameover)
suppress |= SUPPRESS_HALLUCINATION; suppress |= SUPPRESS_HALLUCINATION;
if (article == ARTICLE_YOUR && !mtmp->mtame) if (article == ARTICLE_YOUR && !mtmp->mtame)
article = ARTICLE_THE; article = ARTICLE_THE;
@@ -1665,7 +1660,7 @@ boolean called;
do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION); do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION);
do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE); do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE);
do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR
&& !program_state.gameover && mtmp != u.usteed && !g.program_state.gameover && mtmp != u.usteed
&& !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT); && !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT);
do_saddle = !(suppress & SUPPRESS_SADDLE); do_saddle = !(suppress & SUPPRESS_SADDLE);
do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat); do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat);
@@ -1978,8 +1973,44 @@ struct monst *mon, *other_mon;
return outbuf; return outbuf;
} }
/* for debugging messages, where data might be suspect and we aren't
taking what the hero does or doesn't know into consideration */
char *
minimal_monnam(mon, ckloc)
struct monst *mon;
boolean ckloc;
{
struct permonst *ptr;
char *outbuf = nextmbuf();
if (!mon) {
Strcpy(outbuf, "[Null monster]");
} else if ((ptr = mon->data) == 0) {
Strcpy(outbuf, "[Null mon->data]");
} else if (ptr < &mons[0]) {
Sprintf(outbuf, "[Invalid mon->data %s < %s]",
fmt_ptr((genericptr_t) mon->data),
fmt_ptr((genericptr_t) &mons[0]));
} else if (ptr >= &mons[NUMMONS]) {
Sprintf(outbuf, "[Invalid mon->data %s >= %s]",
fmt_ptr((genericptr_t) mon->data),
fmt_ptr((genericptr_t) &mons[NUMMONS]));
} else if (ckloc && ptr == &mons[PM_LONG_WORM]
&& g.level.monsters[mon->mx][mon->my] != mon) {
Sprintf(outbuf, "%s <%d,%d>",
mons[PM_LONG_WORM_TAIL].mname, mon->mx, mon->my);
} else {
Sprintf(outbuf, "%s%s <%d,%d>",
mon->mtame ? "tame " : mon->mpeaceful ? "peaceful " : "",
mon->data->mname, mon->mx, mon->my);
if (mon->cham != NON_PM)
Sprintf(eos(outbuf), "{%s}", mons[mon->cham].mname);
}
return outbuf;
}
/* fake monsters used to be in a hard-coded array, now in a data file */ /* fake monsters used to be in a hard-coded array, now in a data file */
STATIC_OVL char * static char *
bogusmon(buf, code) bogusmon(buf, code)
char *buf, *code; char *buf, *code;
{ {