-/* 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) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
-STATIC_DCL char *NDECL(nextmbuf);
-STATIC_DCL void FDECL(getpos_help, (BOOLEAN_P, const char *));
-STATIC_DCL int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *));
-STATIC_DCL boolean FDECL(gather_locs_interesting, (int, int, int));
-STATIC_DCL void FDECL(gather_locs, (coord **, int *, int));
-STATIC_DCL int FDECL(gloc_filter_floodfill_matcharea, (int, int));
-STATIC_DCL void FDECL(auto_describe, (int, int));
-STATIC_DCL void NDECL(do_mname);
-STATIC_DCL boolean FDECL(alreadynamed, (struct monst *, char *, char *));
-STATIC_DCL void FDECL(do_oname, (struct obj *));
-STATIC_PTR char *FDECL(docall_xname, (struct obj *));
-STATIC_DCL void NDECL(namefloorobj);
-STATIC_DCL char *FDECL(bogusmon, (char *,char *));
+static char *NDECL(nextmbuf);
+static void FDECL(getpos_help, (BOOLEAN_P, const char *));
+static int FDECL(CFDECLSPEC cmp_coord_distu, (const void *, const void *));
+static boolean FDECL(gather_locs_interesting, (int, int, int));
+static void FDECL(gather_locs, (coord **, int *, int));
+static int FDECL(gloc_filter_floodfill_matcharea, (int, int));
+static void FDECL(auto_describe, (int, int));
+static void NDECL(do_mname);
+static boolean FDECL(alreadynamed, (struct monst *, char *, char *));
+static void FDECL(do_oname, (struct obj *));
+static char *FDECL(docall_xname, (struct obj *));
+static void NDECL(namefloorobj);
+static char *FDECL(bogusmon, (char *,char *));
extern const char what_is_an_unknown_object[]; /* from pager.c */
#define NUMMBUF 5
/* manage a pool of BUFSZ buffers, so callers don't have to */
-STATIC_OVL char *
+static char *
nextmbuf()
{
static char NEARDATA bufs[NUMMBUF][BUFSZ];
}
/* the response for '?' help request in getpos() */
-STATIC_OVL void
+static void
getpos_help(force, goal)
boolean force;
const char *goal;
Sprintf(sbuf,
"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);
Sprintf(sbuf,
"Use 'H', 'J', 'K', 'L' to fast-move the cursor, %s.",
putstr(tmpwin, 0, sbuf);
putstr(tmpwin, 0, "Or enter a background symbol (ex. '<').");
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);
if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
getpos_help_keyxhelp(tmpwin,
- visctrl(Cmd.spkeys[NHKF_GETPOS_MON_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_MON_PREV]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_PREV]),
GLOC_MONS);
}
if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) {
getpos_help_keyxhelp(tmpwin,
- visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]),
GLOC_OBJS);
}
if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) {
/* these are primarily useful when choosing a travel
destination for the '_' command */
getpos_help_keyxhelp(tmpwin,
- visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]),
GLOC_DOOR);
getpos_help_keyxhelp(tmpwin,
- visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]),
GLOC_EXPLORE);
getpos_help_keyxhelp(tmpwin,
- visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]),
GLOC_INTERESTING);
}
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]);
putstr(tmpwin, 0, sbuf);
if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) {
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);
Sprintf(sbuf,
"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);
}
if (!iflags.terrainmode) {
if (getpos_getvalid) {
Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.",
- visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_VALID_PREV]));
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_PREV]));
putstr(tmpwin, 0, sbuf);
}
if (getpos_hilitefunc) {
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);
}
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);
if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */
Sprintf(sbuf,
(iflags.getpos_coords == GPCOORDS_NONE)
? "(Set 'whatis_coord' option to include coordinates with '%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
getpos call, but only matter for dowhatis (and doquickwhatis) */
doing_what_is = (goal == what_is_an_unknown_object);
if (doing_what_is) {
Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'",
- visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_Q]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_O]),
- visctrl(Cmd.spkeys[NHKF_GETPOS_PICK_V]));
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]),
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V]));
} 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);
putstr(tmpwin, 0, sbuf);
if (doing_what_is) {
Sprintf(sbuf,
" '%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);
Sprintf(sbuf,
" '%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'," : "");
putstr(tmpwin, 0, sbuf);
Sprintf(sbuf,
" '%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);
Sprintf(sbuf,
" '%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);
}
}
destroy_nhwindow(tmpwin);
}
-STATIC_OVL int
+static int
cmp_coord_distu(a, b)
const void *a;
const void *b;
&& glyph_to_cmap(levl[(x)][(y)].glyph) == S_stone \
&& !levl[(x)][(y)].seenv)
-static struct opvar *gloc_filter_map = (struct opvar *) 0;
-
#define GLOC_SAME_AREA(x,y) \
(isok((x), (y)) \
- && (selection_getpoint((x),(y), gloc_filter_map)))
-
-static int gloc_filter_floodfill_match_glyph;
+ && (selection_getpoint((x),(y), g.gloc_filter_map)))
int
gloc_filter_classify_glyph(glyph)
return 0;
}
-STATIC_OVL int
+static int
gloc_filter_floodfill_matcharea(x, y)
int x, y;
{
if (!levl[x][y].seenv)
return FALSE;
- if (glyph == gloc_filter_floodfill_match_glyph)
+ if (glyph == g.gloc_filter_floodfill_match_glyph)
return TRUE;
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 FALSE;
gloc_filter_floodfill(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);
- selection_floodfill(gloc_filter_map, x, y, FALSE);
+ selection_floodfill(g.gloc_filter_map, x, y, FALSE);
}
void
gloc_filter_init()
{
if (iflags.getloc_filter == GFILTER_AREA) {
- if (!gloc_filter_map) {
- gloc_filter_map = selection_opvar((char *) 0);
+ if (!g.gloc_filter_map) {
+ g.gloc_filter_map = selection_new();
}
/* special case: if we're in a doorway, try to figure out which
direction we're moving, and use that side of the doorway */
void
gloc_filter_done()
{
- if (gloc_filter_map) {
- opvar_free_x(gloc_filter_map);
- gloc_filter_map = (struct opvar *) 0;
+ if (g.gloc_filter_map) {
+ selection_free(g.gloc_filter_map);
+ g.gloc_filter_map = (struct selectionvar *) 0;
+
}
}
-STATIC_OVL boolean
+static boolean
gather_locs_interesting(x, y, gloc)
int x, y, gloc;
{
}
/* gather locations for monsters or objects shown on the map */
-STATIC_OVL void
+static void
gather_locs(arr_p, cnt_p, gloc)
coord **arr_p;
int *cnt_p;
return outbuf;
}
-STATIC_OVL void
+static void
auto_describe(cx, cy)
int cx, cy;
{
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
- any = zeroany;
+ any = cg.zeroany;
/* gather_locs returns array[0] == you. skip it. */
for (i = 1; i < gcount; i++) {
int gidx[NUM_GLOCS] = DUMMY;
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';
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';
if (!goal)
goal = "desired location";
if (flags.verbose) {
pline("(For instructions type a '%s')",
- visctrl(Cmd.spkeys[NHKF_GETPOS_HELP]));
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_HELP]));
msg_given = TRUE;
}
cx = ccp->x;
if (iflags.autodescribe)
msg_given = FALSE;
- if (c == Cmd.spkeys[NHKF_ESC]) {
+ if (c == g.Cmd.spkeys[NHKF_ESC]) {
cx = cy = -10;
msg_given = TRUE; /* force clear */
result = -1;
for (i = 0; i < 8; i++) {
int dx, dy;
- if (Cmd.dirchars[i] == c) {
+ if (g.Cmd.dirchars[i] == c) {
/* a normal movement letter or digit */
dx = xdir[i];
dy = ydir[i];
- } else if (Cmd.alphadirchars[i] == lowc((char) c)
- || (Cmd.num_pad && Cmd.dirchars[i] == (c & 0177))) {
+ } else if (g.Cmd.alphadirchars[i] == lowc((char) c)
+ || (g.Cmd.num_pad && g.Cmd.dirchars[i] == (c & 0177))) {
/* a shifted movement letter or Meta-digit */
if (iflags.getloc_moveskip) {
/* skip same glyphs */
goto nxtc;
}
- if (c == Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) {
- if (c == Cmd.spkeys[NHKF_GETPOS_HELP])
+ if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) {
+ if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP])
getpos_help(force, goal);
else /* ^R */
docrt(); /* redraw */
/* update message window to reflect that we're still targetting */
show_goal_msg = TRUE;
msg_given = TRUE;
- } else if (c == Cmd.spkeys[NHKF_GETPOS_SHOWVALID]
+ } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID]
&& getpos_hilitefunc) {
if (!hilite_state) {
(*getpos_hilitefunc)(0);
hilite_state = TRUE;
}
goto nxtc;
- } else if (c == Cmd.spkeys[NHKF_GETPOS_AUTODESC]) {
+ } else if (c == g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]) {
iflags.autodescribe = !iflags.autodescribe;
pline("Automatic description %sis %s.",
flags.verbose ? "of features under cursor " : "",
show_goal_msg = TRUE;
msg_given = TRUE;
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] = {
"Not limiting targets",
"Limiting targets to those in sight",
pline("%s.", view_filters[iflags.getloc_filter]);
msg_given = TRUE;
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;
pline("%s a menu to show possible targets%s.",
iflags.getloc_usemenu ? "Using" : "Not using",
? " for 'm|M', 'o|O', 'd|D', and 'x|X'" : "");
msg_given = TRUE;
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
to achieve that except by manually cycling through all spots */
for (i = 0; i < NUM_GLOCS; i++)
cx = u.ux;
cy = u.uy;
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;
pline("%skipping over similar terrain when fastmoving the cursor.",
iflags.getloc_moveskip ? "S" : "Not s");
|| glyph_to_cmap(k) == S_corr
|| glyph_to_cmap(k) == S_litcorr)
continue;
- if (c == defsyms[sidx].sym || c == (int) showsyms[sidx])
+ if (c == defsyms[sidx].sym || c == (int) g.showsyms[sidx])
matching[sidx] = (char) ++k;
}
if (k) {
goto foundc;
/* next, try glyph that's remembered here
(might be trap or object) */
- if (level.flags.hero_memory
+ if (g.level.flags.hero_memory
/* !terrainmode: don't move to remembered
trap or object if not currently shown */
&& !iflags.terrainmode) {
goto foundc;
}
/* last, try actual terrain here (shouldn't
- we be using lastseentyp[][] instead?) */
+ we be using g.lastseentyp[][] instead?) */
if (levl[tx][ty].seenv) {
k = back_to_glyph(tx, ty);
if (glyph_is_cmap(k)
Strcpy(note, "aborted");
else /* hjkl */
Sprintf(note, "use '%c', '%c', '%c', '%c' or '%s'",
- Cmd.move_W, Cmd.move_S, Cmd.move_N, Cmd.move_E,
- visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]));
+ g.Cmd.move_W, g.Cmd.move_S, g.Cmd.move_N, g.Cmd.move_E,
+ visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
pline("Unknown direction: '%s' (%s).", visctrl((char) c),
note);
msg_given = TRUE;
int lth;
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;
if (lth > PL_PSIZ) {
lth = PL_PSIZ;
/* check whether user-supplied name matches or nearly matches an unnameable
monster's name; if so, give an alternate reject message for do_mname() */
-STATIC_OVL boolean
+static boolean
alreadynamed(mtmp, monnambuf, usrbuf)
struct monst *mtmp;
char *monnambuf, *usrbuf;
}
/* allow player to assign a name to some chosen monster */
-STATIC_OVL void
+static void
do_mname()
{
char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ];
mtmp = u.usteed;
} else {
pline("This %s creature is called %s and cannot be renamed.",
- beautiful(), plname);
+ beautiful(), g.plname);
return;
}
} else
(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
* used with extreme care. Applying a name to an object no longer
* allocates a replacement object, so that old risk is gone.
*/
-STATIC_OVL
+static
void
do_oname(obj)
register struct obj *obj;
a valid artifact name */
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);
- --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 *
/* if obj is owned by a shop, increase your bill */
if (obj->unpaid)
alter_cost(obj, 0L);
- if (via_naming) {
+ if (g.via_naming) {
/* violate illiteracy conduct since successfully wrote arti-name */
u.uconduct.literate++;
}
win = create_nhwindow(NHW_MENU);
start_menu(win);
- any = zeroany;
+ any = cg.zeroany;
any.a_char = 'm'; /* group accelerator 'C' */
add_menu(win, NO_GLYPH, &any, abc ? 0 : any.a_char, 'C', ATR_NONE,
"a monster", MENU_UNSELECTED);
- if (invent) {
+ if (g.invent) {
/* we use y and n as accelerators so that we can accept user's
response keyed to old "name an individual object?" prompt */
any.a_char = 'i'; /* group accelerator 'y' */
}
/* for use by safe_qbuf() */
-STATIC_PTR char *
+static char *
docall_xname(obj)
struct obj *obj;
{
}
}
-STATIC_OVL void
+static void
namefloorobj()
{
coord cc;
been moved off the hero's '@' yet, but there's no way to adjust
the help text once getpos() has started */
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)
return;
if (cc.x == u.ux && cc.y == u.uy) {
char tmpbuf[BUFSZ];
/* straight role name */
- unames[0] = ((Upolyd ? u.mfemale : flags.female) && urole.name.f)
- ? urole.name.f
- : urole.name.m;
+ unames[0] = ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f)
+ ? g.urole.name.f
+ : g.urole.name.m;
/* random rank title for hero's role
note: the 30 is hardcoded in xlev_to_rank, so should be
const char *
rndghostname()
{
- return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] : (const char *) plname;
+ return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] : (const char *) g.plname;
}
/*
boolean name_at_start, has_adjectives;
char *bp;
- if (program_state.gameover)
+ if (g.program_state.gameover)
suppress |= SUPPRESS_HALLUCINATION;
if (article == ARTICLE_YOUR && !mtmp->mtame)
article = ARTICLE_THE;
do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION);
do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE);
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);
do_saddle = !(suppress & SUPPRESS_SADDLE);
do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat);
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 */
-STATIC_OVL char *
+static char *
bogusmon(buf, code)
char *buf, *code;
{