yet more formatting

Reformat some trailing &&, || operators followed by end-of-line comment,
missed by the earlier continuation formating.

An
  #if 0
    something {
  #else
    something_else {
  #endif
construct in rhack(cmd.c) confused the automated reformatter, resulting
in some code from inside a function ending up in column 1.
This commit is contained in:
PatR
2015-11-01 01:17:54 -08:00
parent bdb5cb2b73
commit a9eb5b2ca8
6 changed files with 470 additions and 436 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 apply.c $NHDT-Date: 1445301113 2015/10/20 00:31:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.207 $ */ /* NetHack 3.6 apply.c $NHDT-Date: 1446369459 2015/11/01 09:17:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.208 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -32,8 +32,8 @@ STATIC_DCL int FDECL(use_pole, (struct obj *));
STATIC_DCL int FDECL(use_cream_pie, (struct obj *)); STATIC_DCL int FDECL(use_cream_pie, (struct obj *));
STATIC_DCL int FDECL(use_grapple, (struct obj *)); STATIC_DCL int FDECL(use_grapple, (struct obj *));
STATIC_DCL int FDECL(do_break_wand, (struct obj *)); STATIC_DCL int FDECL(do_break_wand, (struct obj *));
STATIC_DCL boolean STATIC_DCL boolean FDECL(figurine_location_checks, (struct obj *,
FDECL(figurine_location_checks, (struct obj *, coord *, BOOLEAN_P)); coord *, BOOLEAN_P));
STATIC_DCL void FDECL(add_class, (char *, CHAR_P)); STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
STATIC_DCL void FDECL(setapplyclasses, (char *)); STATIC_DCL void FDECL(setapplyclasses, (char *));
STATIC_DCL boolean FDECL(is_valid_jump_pos, (int, int, int, BOOLEAN_P)); STATIC_DCL boolean FDECL(is_valid_jump_pos, (int, int, int, BOOLEAN_P));
@@ -50,18 +50,18 @@ STATIC_OVL int
use_camera(obj) use_camera(obj)
struct obj *obj; struct obj *obj;
{ {
register struct monst *mtmp; struct monst *mtmp;
if (Underwater) { if (Underwater) {
pline("Using your camera underwater would void the warranty."); pline("Using your camera underwater would void the warranty.");
return (0); return 0;
} }
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
if (obj->spe <= 0) { if (obj->spe <= 0) {
pline1(nothing_happens); pline1(nothing_happens);
return (1); return 1;
} }
consume_obj_charge(obj, TRUE); consume_obj_charge(obj, TRUE);
@@ -98,6 +98,7 @@ struct obj *obj;
return 0; return 0;
} else if (obj->cursed) { } else if (obj->cursed) {
long old; long old;
switch (rn2(3)) { switch (rn2(3)) {
case 2: case 2:
old = Glib; old = Glib;
@@ -492,24 +493,26 @@ struct obj *obj;
boolean boolean
um_dist(x, y, n) um_dist(x, y, n)
register xchar x, y, n; xchar x, y, n;
{ {
return ((boolean)(abs(u.ux - x) > n || abs(u.uy - y) > n)); return (boolean) (abs(u.ux - x) > n || abs(u.uy - y) > n);
} }
int int
number_leashed() number_leashed()
{ {
register int i = 0; int i = 0;
register struct obj *obj; struct obj *obj;
for (obj = invent; obj; obj = obj->nobj) for (obj = invent; obj; obj = obj->nobj)
if (obj->otyp == LEASH && obj->leashmon != 0) if (obj->otyp == LEASH && obj->leashmon != 0)
i++; i++;
return (i); return i;
} }
void o_unleash(otmp) /* otmp is about to be destroyed or stolen */ /* otmp is about to be destroyed or stolen */
void
o_unleash(otmp)
register struct obj *otmp; register struct obj *otmp;
{ {
register struct monst *mtmp; register struct monst *mtmp;
@@ -520,7 +523,9 @@ register struct obj *otmp;
otmp->leashmon = 0; otmp->leashmon = 0;
} }
void m_unleash(mtmp, feedback) /* mtmp is about to die, or become untame */ /* mtmp is about to die, or become untame */
void
m_unleash(mtmp, feedback)
register struct monst *mtmp; register struct monst *mtmp;
boolean feedback; boolean feedback;
{ {
@@ -538,7 +543,9 @@ boolean feedback;
mtmp->mleashed = 0; mtmp->mleashed = 0;
} }
void unleash_all() /* player is about to die (for bones) */ /* player is about to die (for bones) */
void
unleash_all()
{ {
register struct obj *otmp; register struct obj *otmp;
register struct monst *mtmp; register struct monst *mtmp;
@@ -556,7 +563,7 @@ static boolean
leashable(mtmp) leashable(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
return mtmp->mnum != PM_LONG_WORM; return (boolean) (mtmp->mnum != PM_LONG_WORM);
} }
/* ARGSUSED */ /* ARGSUSED */
@@ -638,18 +645,20 @@ got_target:
return; return;
} }
struct obj *get_mleash(mtmp) /* assuming mtmp->mleashed has been checked */ /* assuming mtmp->mleashed has been checked */
register struct monst *mtmp; struct obj *
get_mleash(mtmp)
struct monst *mtmp;
{ {
register struct obj *otmp; struct obj *otmp;
otmp = invent; otmp = invent;
while (otmp) { while (otmp) {
if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id) if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id)
return (otmp); return otmp;
otmp = otmp->nobj; otmp = otmp->nobj;
} }
return ((struct obj *) 0); return (struct obj *) 0;
} }
boolean boolean
@@ -669,7 +678,7 @@ next_to_u()
if (otmp->otyp == LEASH if (otmp->otyp == LEASH
&& otmp->leashmon == (int) mtmp->m_id) { && otmp->leashmon == (int) mtmp->m_id) {
if (otmp->cursed) if (otmp->cursed)
return (FALSE); return FALSE;
You_feel("%s leash go slack.", You_feel("%s leash go slack.",
(number_leashed() > 1) ? "a" : "the"); (number_leashed() > 1) ? "a" : "the");
mtmp->mleashed = 0; mtmp->mleashed = 0;
@@ -681,7 +690,7 @@ next_to_u()
/* no pack mules for the Amulet */ /* no pack mules for the Amulet */
if (u.usteed && mon_has_amulet(u.usteed)) if (u.usteed && mon_has_amulet(u.usteed))
return FALSE; return FALSE;
return (TRUE); return TRUE;
} }
void void
@@ -756,9 +765,11 @@ register xchar x, y;
const char * const char *
beautiful() beautiful()
{ {
return (ACURR(A_CHA) > 14) return ((ACURR(A_CHA) > 14)
? (poly_gender() == 1 ? "beautiful" : "handsome") ? ((poly_gender() == 1)
: "ugly"; ? "beautiful"
: "handsome")
: "ugly");
} }
#define WEAK 3 /* from eat.c */ #define WEAK 3 /* from eat.c */
@@ -1180,16 +1191,18 @@ struct obj **optr;
} }
} }
boolean snuff_candle(otmp) /* call in drop, throw, and put in box, etc. */ /* call in drop, throw, and put in box, etc. */
register struct obj *otmp; boolean
snuff_candle(otmp)
struct obj *otmp;
{ {
register boolean candle = Is_candle(otmp); boolean candle = Is_candle(otmp);
if ((candle || otmp->otyp == CANDELABRUM_OF_INVOCATION) if ((candle || otmp->otyp == CANDELABRUM_OF_INVOCATION)
&& otmp->lamplit) { && otmp->lamplit) {
char buf[BUFSZ]; char buf[BUFSZ];
xchar x, y; xchar x, y;
register boolean many = candle ? otmp->quan > 1L : otmp->spe > 1; boolean many = candle ? (otmp->quan > 1L) : (otmp->spe > 1);
(void) get_obj_location(otmp, &x, &y, 0); (void) get_obj_location(otmp, &x, &y, 0);
if (otmp->where == OBJ_MINVENT ? cansee(x, y) : !Blind) if (otmp->where == OBJ_MINVENT ? cansee(x, y) : !Blind)
@@ -1197,9 +1210,9 @@ register struct obj *otmp;
(candle ? "" : "candelabrum's "), (many ? "s'" : "'s"), (candle ? "" : "candelabrum's "), (many ? "s'" : "'s"),
(many ? "s are" : " is")); (many ? "s are" : " is"));
end_burn(otmp, TRUE); end_burn(otmp, TRUE);
return (TRUE); return TRUE;
} }
return (FALSE); return FALSE;
} }
/* called when lit lamp is hit by water or put into a container or /* called when lit lamp is hit by water or put into a container or
@@ -1555,7 +1568,7 @@ int magic; /* 0=Physical, otherwise skill level */
return 0; return 0;
} else if (u.usteed && u.utrap) { } else if (u.usteed && u.utrap) {
pline("%s is stuck in a trap.", Monnam(u.usteed)); pline("%s is stuck in a trap.", Monnam(u.usteed));
return (0); return 0;
} }
pline("Where do you want to jump?"); pline("Where do you want to jump?");
@@ -1644,9 +1657,9 @@ struct obj *corpse;
STATIC_OVL void STATIC_OVL void
use_tinning_kit(obj) use_tinning_kit(obj)
register struct obj *obj; struct obj *obj;
{ {
register struct obj *corpse, *can; struct obj *corpse, *can;
/* This takes only 1 move. If this is to be changed to take many /* This takes only 1 move. If this is to be changed to take many
* moves, we've got to deal with decaying corpses... * moves, we've got to deal with decaying corpses...
@@ -2692,12 +2705,11 @@ struct obj *obj;
return 1; return 1;
} }
static const char not_enough_room[] = static const char
"There's not enough room here to use that.", not_enough_room[] = "There's not enough room here to use that.",
where_to_hit[] = "Where do you want to hit?", where_to_hit[] = "Where do you want to hit?",
cant_see_spot[] = cant_see_spot[] = "won't hit anything if you can't see that spot.",
"won't hit anything if you can't see that spot.", cant_reach[] = "can't reach that spot from here.";
cant_reach[] = "can't reach that spot from here.";
/* find pos of monster in range, if only one monster */ /* find pos of monster in range, if only one monster */
boolean boolean
@@ -2707,6 +2719,7 @@ int min_range, max_range;
{ {
struct monst *mtmp; struct monst *mtmp;
struct monst *selmon = NULL; struct monst *selmon = NULL;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (mtmp && !DEADMONSTER(mtmp) && !mtmp->mtame if (mtmp && !DEADMONSTER(mtmp) && !mtmp->mtame
&& cansee(mtmp->mx, mtmp->my) && cansee(mtmp->mx, mtmp->my)
@@ -2734,6 +2747,7 @@ int state;
tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos)); tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos));
} else if (state == 1) { } else if (state == 1) {
int x, y, dx, dy; int x, y, dx, dy;
for (dx = -4; dx <= 4; dx++) for (dx = -4; dx <= 4; dx++)
for (dy = -4; dy <= 4; dy++) { for (dy = -4; dy <= 4; dy++) {
x = dx + (int) u.ux; x = dx + (int) u.ux;
@@ -2762,11 +2776,11 @@ struct obj *obj;
/* Are you allowed to use the pole? */ /* Are you allowed to use the pole? */
if (u.uswallow) { if (u.uswallow) {
pline(not_enough_room); pline(not_enough_room);
return (0); return 0;
} }
if (obj != uwep) { if (obj != uwep) {
if (!wield_tool(obj, "swing")) if (!wield_tool(obj, "swing"))
return (0); return 0;
else else
res = 1; res = 1;
} }
@@ -2817,14 +2831,14 @@ struct obj *obj;
glyph = glyph_at(cc.x, cc.y); glyph = glyph_at(cc.x, cc.y);
if (distu(cc.x, cc.y) > max_range) { if (distu(cc.x, cc.y) > max_range) {
pline("Too far!"); pline("Too far!");
return (res); return res;
} else if (distu(cc.x, cc.y) < min_range) { } else if (distu(cc.x, cc.y) < min_range) {
pline("Too close!"); pline("Too close!");
return (res); return res;
} else if (!cansee(cc.x, cc.y) && !glyph_is_monster(glyph) } else if (!cansee(cc.x, cc.y) && !glyph_is_monster(glyph)
&& !glyph_is_invisible(glyph) && !glyph_is_statue(glyph)) { && !glyph_is_invisible(glyph) && !glyph_is_statue(glyph)) {
You(cant_see_spot); You(cant_see_spot);
return (res); return res;
} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */ } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
You(cant_reach); You(cant_reach);
return res; return res;
@@ -2842,8 +2856,8 @@ struct obj *obj;
check_caitiff(mtmp); check_caitiff(mtmp);
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
(void) thitmonst(mtmp, uwep); (void) thitmonst(mtmp, uwep);
} else if (glyph_is_statue(glyph) && /* might be hallucinatory */ } else if (glyph_is_statue(glyph) /* might be hallucinatory */
sobj_at(STATUE, bhitpos.x, bhitpos.y)) { && sobj_at(STATUE, bhitpos.x, bhitpos.y)) {
struct trap *t = t_at(bhitpos.x, bhitpos.y); struct trap *t = t_at(bhitpos.x, bhitpos.y);
if (t && t->ttyp == STATUE_TRAP if (t && t->ttyp == STATUE_TRAP
@@ -2868,7 +2882,7 @@ struct obj *obj;
You("miss; there is no one there to hit."); You("miss; there is no one there to hit.");
} }
u_wipe_engr(2); /* same as for melee or throwing */ u_wipe_engr(2); /* same as for melee or throwing */
return (1); return 1;
} }
STATIC_OVL int STATIC_OVL int
@@ -2906,7 +2920,7 @@ struct obj *obj;
costly_alteration(obj, COST_SPLAT); costly_alteration(obj, COST_SPLAT);
obj_extract_self(obj); obj_extract_self(obj);
delobj(obj); delobj(obj);
return (0); return 0;
} }
STATIC_OVL int STATIC_OVL int
@@ -2922,11 +2936,11 @@ struct obj *obj;
/* Are you allowed to use the hook? */ /* Are you allowed to use the hook? */
if (u.uswallow) { if (u.uswallow) {
pline(not_enough_room); pline(not_enough_room);
return (0); return 0;
} }
if (obj != uwep) { if (obj != uwep) {
if (!wield_tool(obj, "cast")) if (!wield_tool(obj, "cast"))
return (0); return 0;
else else
res = 1; res = 1;
} }
@@ -2949,10 +2963,10 @@ struct obj *obj;
max_range = 8; max_range = 8;
if (distu(cc.x, cc.y) > max_range) { if (distu(cc.x, cc.y) > max_range) {
pline("Too far!"); pline("Too far!");
return (res); return res;
} else if (!cansee(cc.x, cc.y)) { } else if (!cansee(cc.x, cc.y)) {
You(cant_see_spot); You(cant_see_spot);
return (res); return res;
} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */ } else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
You(cant_reach); You(cant_reach);
return res; return res;
@@ -3005,7 +3019,7 @@ struct obj *obj;
(void) pickup_object(otmp, 1L, FALSE); (void) pickup_object(otmp, 1L, FALSE);
/* If pickup fails, leave it alone */ /* If pickup fails, leave it alone */
newsym(cc.x, cc.y); newsym(cc.x, cc.y);
return (1); return 1;
} }
break; break;
case 2: /* Monster */ case 2: /* Monster */
@@ -3023,7 +3037,7 @@ struct obj *obj;
You("pull in %s!", mon_nam(mtmp)); You("pull in %s!", mon_nam(mtmp));
mtmp->mundetected = 0; mtmp->mundetected = 0;
rloc_to(mtmp, cc.x, cc.y); rloc_to(mtmp, cc.x, cc.y);
return (1); return 1;
} else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data))
|| rn2(4)) { || rn2(4)) {
flags.confirm = FALSE; flags.confirm = FALSE;
@@ -3031,7 +3045,7 @@ struct obj *obj;
flags.confirm = save_confirm; flags.confirm = save_confirm;
check_caitiff(mtmp); check_caitiff(mtmp);
(void) thitmonst(mtmp, uwep); (void) thitmonst(mtmp, uwep);
return (1); return 1;
} }
/* FALL THROUGH */ /* FALL THROUGH */
case 3: /* Surface */ case 3: /* Surface */
@@ -3042,18 +3056,18 @@ struct obj *obj;
hurtle(sgn(cc.x - u.ux), sgn(cc.y - u.uy), 1, FALSE); hurtle(sgn(cc.x - u.ux), sgn(cc.y - u.uy), 1, FALSE);
spoteffects(TRUE); spoteffects(TRUE);
} }
return (1); return 1;
default: /* Yourself (oops!) */ default: /* Yourself (oops!) */
if (P_SKILL(typ) <= P_BASIC) { if (P_SKILL(typ) <= P_BASIC) {
You("hook yourself!"); You("hook yourself!");
losehp(Maybe_Half_Phys(rn1(10, 10)), "a grappling hook", losehp(Maybe_Half_Phys(rn1(10, 10)), "a grappling hook",
KILLED_BY); KILLED_BY);
return (1); return 1;
} }
break; break;
} }
pline1(nothing_happens); pline1(nothing_happens);
return (1); return 1;
} }
#define BY_OBJECT ((struct monst *) 0) #define BY_OBJECT ((struct monst *) 0)
@@ -3075,7 +3089,8 @@ struct obj *obj;
boolean is_fragile = (!strcmp(OBJ_DESCR(objects[obj->otyp]), "balsa")); boolean is_fragile = (!strcmp(OBJ_DESCR(objects[obj->otyp]), "balsa"));
if (!paranoid_query(ParanoidBreakwand, if (!paranoid_query(ParanoidBreakwand,
safe_qbuf(confirm, "Are you really sure you want to break ", safe_qbuf(confirm,
"Are you really sure you want to break ",
"?", obj, yname, ysimple_name, "the wand"))) "?", obj, yname, ysimple_name, "the wand")))
return 0; return 0;
@@ -3180,6 +3195,7 @@ struct obj *obj;
if (obj->otyp == WAN_DIGGING) { if (obj->otyp == WAN_DIGGING) {
schar typ; schar typ;
if (dig_check(BY_OBJECT, FALSE, x, y)) { if (dig_check(BY_OBJECT, FALSE, x, y)) {
if (IS_WALL(levl[x][y].typ) || IS_DOOR(levl[x][y].typ)) { if (IS_WALL(levl[x][y].typ) || IS_DOOR(levl[x][y].typ)) {
/* normally, pits and holes don't anger guards, but they /* normally, pits and holes don't anger guards, but they
@@ -3196,18 +3212,17 @@ struct obj *obj;
typ = fillholetyp(x, y, FALSE); typ = fillholetyp(x, y, FALSE);
if (typ != ROOM) { if (typ != ROOM) {
levl[x][y].typ = typ; levl[x][y].typ = typ;
liquid_flow( liquid_flow(x, y, typ, t_at(x, y),
x, y, typ, t_at(x, y), fillmsg
fillmsg ? (char *) 0 ? (char *) 0
: "Some holes are quickly filled with %s!"); : "Some holes are quickly filled with %s!");
fillmsg = TRUE; fillmsg = TRUE;
} else } else
digactualhole( digactualhole(x, y, BY_OBJECT, (rn2(obj->spe) < 3
x, y, BY_OBJECT, || (!Can_dig_down(&u.uz)
(rn2(obj->spe) < 3 && !levl[x][y].candig))
|| (!Can_dig_down(&u.uz) && !levl[x][y].candig)) ? PIT
? PIT : HOLE);
: HOLE);
} }
continue; continue;
} else if (obj->otyp == WAN_CREATE_MONSTER) { } else if (obj->otyp == WAN_CREATE_MONSTER) {
@@ -3335,6 +3350,7 @@ char class_list[];
add_class(class_list, FOOD_CLASS); add_class(class_list, FOOD_CLASS);
} }
/* the 'a' command */
int int
doapply() doapply()
{ {
@@ -3343,7 +3359,7 @@ doapply()
char class_list[MAXOCLASSES + 2]; char class_list[MAXOCLASSES + 2];
if (check_capacity((char *) 0)) if (check_capacity((char *) 0))
return (0); return 0;
setapplyclasses(class_list); /* tools[] */ setapplyclasses(class_list); /* tools[] */
obj = getobj(class_list, "use or apply"); obj = getobj(class_list, "use or apply");
@@ -3363,14 +3379,15 @@ doapply()
if (obj == ublindf) { if (obj == ublindf) {
if (!cursed(obj)) if (!cursed(obj))
Blindf_off(obj); Blindf_off(obj);
} else if (!ublindf) } else if (!ublindf) {
Blindf_on(obj); Blindf_on(obj);
else } else {
You("are already %s.", ublindf->otyp == TOWEL You("are already %s.", ublindf->otyp == TOWEL
? "covered by a towel" ? "covered by a towel"
: ublindf->otyp == BLINDFOLD : ublindf->otyp == BLINDFOLD
? "wearing a blindfold" ? "wearing a blindfold"
: "wearing lenses"); : "wearing lenses");
}
break; break;
case CREAM_PIE: case CREAM_PIE:
res = use_cream_pie(obj); res = use_cream_pie(obj);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 artifact.c $NHDT-Date: 1445301116 2015/10/20 00:31:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.95 $ */ /* NetHack 3.6 artifact.c $NHDT-Date: 1446369462 2015/11/01 09:17:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.96 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -8,9 +8,9 @@
/* /*
* Note: both artilist[] and artiexist[] have a dummy element #0, * Note: both artilist[] and artiexist[] have a dummy element #0,
* so loops over them should normally start at #1. The primary * so loops over them should normally start at #1. The primary
* exception is the save & restore code, which doesn't care about * exception is the save & restore code, which doesn't care about
* the contents, just the total size. * the contents, just the total size.
*/ */
extern boolean notonhead; /* for long worms */ extern boolean notonhead; /* for long worms */
@@ -105,8 +105,8 @@ artiname(artinum)
int artinum; int artinum;
{ {
if (artinum <= 0 || artinum > NROFARTIFACTS) if (artinum <= 0 || artinum > NROFARTIFACTS)
return (""); return "";
return (artilist[artinum].name); return artilist[artinum].name;
} }
/* /*
@@ -239,11 +239,11 @@ short *otyp;
boolean boolean
exist_artifact(otyp, name) exist_artifact(otyp, name)
register int otyp; int otyp;
register const char *name; const char *name;
{ {
register const struct artifact *a; register const struct artifact *a;
register boolean *arex; boolean *arex;
if (otyp && *name) if (otyp && *name)
for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++) for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++)
@@ -254,9 +254,9 @@ register const char *name;
void void
artifact_exists(otmp, name, mod) artifact_exists(otmp, name, mod)
register struct obj *otmp; struct obj *otmp;
register const char *name; const char *name;
register boolean mod; boolean mod;
{ {
register const struct artifact *a; register const struct artifact *a;
@@ -294,7 +294,7 @@ unsigned long abil;
{ {
const struct artifact *arti = get_artifact(otmp); const struct artifact *arti = get_artifact(otmp);
return ((boolean)(arti && (arti->spfx & abil))); return (boolean) (arti && (arti->spfx & abil) != 0L);
} }
/* used so that callers don't need to known about SPFX_ codes */ /* used so that callers don't need to known about SPFX_ codes */
@@ -306,7 +306,7 @@ struct obj *obj;
if (obj->otyp == LUCKSTONE) if (obj->otyp == LUCKSTONE)
return TRUE; return TRUE;
return (obj->oartifact && spec_ability(obj, SPFX_LUCK)); return (boolean) (obj->oartifact && spec_ability(obj, SPFX_LUCK));
} }
/* used to check whether a monster is getting reflection from an artifact */ /* used to check whether a monster is getting reflection from an artifact */
@@ -348,10 +348,11 @@ struct obj *obj;
return FALSE; return FALSE;
} }
/* returns 1 if name is restricted for otmp->otyp */
boolean boolean
restrict_name(otmp, name) /* returns 1 if name is restricted for otmp->otyp */ restrict_name(otmp, name)
register struct obj *otmp; struct obj *otmp;
register const char *name; const char *name;
{ {
register const struct artifact *a; register const struct artifact *a;
const char *aname, *odesc, *other; const char *aname, *odesc, *other;
@@ -394,8 +395,8 @@ register const char *name;
if (!strncmpi(aname, "the ", 4)) if (!strncmpi(aname, "the ", 4))
aname += 4; aname += 4;
if (!strcmp(aname, name)) if (!strcmp(aname, name))
return ((boolean)((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0 return (boolean) ((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0
|| otmp->quan > 1L)); || otmp->quan > 1L);
} }
return FALSE; return FALSE;
@@ -403,25 +404,25 @@ register const char *name;
STATIC_OVL boolean STATIC_OVL boolean
attacks(adtyp, otmp) attacks(adtyp, otmp)
register int adtyp; int adtyp;
register struct obj *otmp; struct obj *otmp;
{ {
register const struct artifact *weap; register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0) if ((weap = get_artifact(otmp)) != 0)
return ((boolean)(weap->attk.adtyp == adtyp)); return (boolean) (weap->attk.adtyp == adtyp);
return FALSE; return FALSE;
} }
boolean boolean
defends(adtyp, otmp) defends(adtyp, otmp)
register int adtyp; int adtyp;
register struct obj *otmp; struct obj *otmp;
{ {
register const struct artifact *weap; register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0) if ((weap = get_artifact(otmp)) != 0)
return ((boolean)(weap->defn.adtyp == adtyp)); return (boolean) (weap->defn.adtyp == adtyp);
return FALSE; return FALSE;
} }
@@ -434,7 +435,7 @@ struct obj *otmp;
register const struct artifact *weap; register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0) if ((weap = get_artifact(otmp)) != 0)
return (boolean)(weap->cary.adtyp == adtyp); return (boolean) (weap->cary.adtyp == adtyp);
return FALSE; return FALSE;
} }
@@ -451,8 +452,8 @@ boolean being_worn;
arti = get_artifact(otmp); arti = get_artifact(otmp);
if (!arti) if (!arti)
return FALSE; return FALSE;
return (arti->cspfx & SPFX_PROTECT) != 0 return (boolean) ((arti->cspfx & SPFX_PROTECT) != 0
|| (being_worn && (arti->spfx & SPFX_PROTECT) != 0); || (being_worn && (arti->spfx & SPFX_PROTECT) != 0));
} }
/* /*
@@ -467,8 +468,8 @@ long wp_mask;
{ {
long *mask = 0; long *mask = 0;
register const struct artifact *oart = get_artifact(otmp); register const struct artifact *oart = get_artifact(otmp);
uchar dtyp; register uchar dtyp;
long spfx; register long spfx;
if (!oart) if (!oart)
return; return;
@@ -632,8 +633,7 @@ long wp_mask;
STATIC_VAR boolean touch_blasted; /* for retouch_object() */ STATIC_VAR boolean touch_blasted; /* for retouch_object() */
/* /*
* creature (usually player) tries to touch (pick up or wield) an artifact * creature (usually hero) tries to touch (pick up or wield) an artifact obj.
* obj.
* Returns 0 if the object refuses to be touched. * Returns 0 if the object refuses to be touched.
* This routine does not change any object chains. * This routine does not change any object chains.
* Ignores such things as gauntlets, assuming the artifact is not * Ignores such things as gauntlets, assuming the artifact is not
@@ -669,8 +669,7 @@ struct monst *mon;
&& (oart->alignment != mon_aligntyp(mon)); && (oart->alignment != mon_aligntyp(mon));
} else { /* an M3_WANTSxxx monster or a fake player */ } else { /* an M3_WANTSxxx monster or a fake player */
/* special monsters trying to take the Amulet, invocation tools or /* special monsters trying to take the Amulet, invocation tools or
quest item can touch anything except for `spec_applies' artifacts quest item can touch anything except `spec_applies' artifacts */
*/
badclass = badalign = FALSE; badclass = badalign = FALSE;
} }
/* weapons which attack specific categories of monsters are /* weapons which attack specific categories of monsters are
@@ -723,8 +722,9 @@ int dtyp;
return FALSE; return FALSE;
if (dtyp == AD_PHYS) if (dtyp == AD_PHYS)
return FALSE; /* nothing is immune to phys dmg */ return FALSE; /* nothing is immune to phys dmg */
return (weap->attk.adtyp == dtyp || weap->defn.adtyp == dtyp return (boolean) (weap->attk.adtyp == dtyp
|| weap->cary.adtyp == dtyp); || weap->defn.adtyp == dtyp
|| weap->cary.adtyp == dtyp);
} }
STATIC_OVL boolean STATIC_OVL boolean
@@ -799,7 +799,7 @@ struct monst *mtmp;
impossible("Weird weapon special attack."); impossible("Weird weapon special attack.");
} }
} }
return (0); return 0;
} }
/* return the M2 flags of monster that an artifact's special attacks apply /* return the M2 flags of monster that an artifact's special attacks apply
@@ -808,7 +808,8 @@ long
spec_m2(otmp) spec_m2(otmp)
struct obj *otmp; struct obj *otmp;
{ {
register const struct artifact *artifact = get_artifact(otmp); const struct artifact *artifact = get_artifact(otmp);
if (artifact) if (artifact)
return artifact->mtype; return artifact->mtype;
return 0L; return 0L;
@@ -820,7 +821,7 @@ spec_abon(otmp, mon)
struct obj *otmp; struct obj *otmp;
struct monst *mon; struct monst *mon;
{ {
register const struct artifact *weap = get_artifact(otmp); const struct artifact *weap = get_artifact(otmp);
/* no need for an extra check for `NO_ATTK' because this will /* no need for an extra check for `NO_ATTK' because this will
always return 0 for any artifact which has that attribute */ always return 0 for any artifact which has that attribute */
@@ -839,8 +840,8 @@ int tmp;
{ {
register const struct artifact *weap = get_artifact(otmp); register const struct artifact *weap = get_artifact(otmp);
if (!weap || (weap->attk.adtyp == AD_PHYS && /* check for `NO_ATTK' */ if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */
weap->attk.damn == 0 && weap->attk.damd == 0)) && weap->attk.damn == 0 && weap->attk.damd == 0))
spec_dbon_applies = FALSE; spec_dbon_applies = FALSE;
else if (otmp->oartifact == ART_GRIMTOOTH) else if (otmp->oartifact == ART_GRIMTOOTH)
/* Grimtooth has SPFX settings to warn against elves but we want its /* Grimtooth has SPFX settings to warn against elves but we want its
@@ -1292,7 +1293,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
else if (vis) else if (vis)
pline("Somehow, %s misses wildly.", mon_nam(magr)); pline("Somehow, %s misses wildly.", mon_nam(magr));
*dmgptr = 0; *dmgptr = 0;
return ((boolean)(youattack || vis)); return (boolean) (youattack || vis);
} }
if (noncorporeal(mdef->data) || amorphous(mdef->data)) { if (noncorporeal(mdef->data) || amorphous(mdef->data)) {
pline("%s slices through %s %s.", wepdesc, pline("%s slices through %s %s.", wepdesc,
@@ -1345,6 +1346,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
*dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER; *dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
} else { } else {
int drain = monhp_per_lvl(mdef); int drain = monhp_per_lvl(mdef);
*dmgptr += drain; *dmgptr += drain;
mdef->mhpmax -= drain; mdef->mhpmax -= drain;
mdef->m_lev--; mdef->m_lev--;
@@ -1358,8 +1360,9 @@ int dieroll; /* needed for Magicbane and vorpal blades */
if (Blind) if (Blind)
You_feel("an %s drain your %s!", You_feel("an %s drain your %s!",
otmp->oartifact == ART_STORMBRINGER ? "unholy blade" (otmp->oartifact == ART_STORMBRINGER)
: "object", ? "unholy blade"
: "object",
life); life);
else if (otmp->oartifact == ART_STORMBRINGER) else if (otmp->oartifact == ART_STORMBRINGER)
pline_The("%s blade drains your %s!", hcolor(NH_BLACK), life); pline_The("%s blade drains your %s!", hcolor(NH_BLACK), life);
@@ -1382,6 +1385,7 @@ static NEARDATA const char recharge_type[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
static NEARDATA const char invoke_types[] = { ALL_CLASSES, 0 }; static NEARDATA const char invoke_types[] = { ALL_CLASSES, 0 };
/* #invoke: an "ugly check" filters out most objects */ /* #invoke: an "ugly check" filters out most objects */
/* the #invoke command */
int int
doinvoke() doinvoke()
{ {
@@ -1584,8 +1588,7 @@ register struct obj *obj;
} else { } else {
long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI), long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI),
iprop = u.uprops[oart->inv_prop].intrinsic; iprop = u.uprops[oart->inv_prop].intrinsic;
boolean on = boolean on = (eprop & W_ARTI) != 0; /* true if prop just set */
(eprop & W_ARTI) != 0; /* true if invoked prop just set */
if (on && obj->age > monstermoves) { if (on && obj->age > monstermoves) {
/* the artifact is tired :-) */ /* the artifact is tired :-) */
@@ -1671,7 +1674,7 @@ boolean
artifact_light(obj) artifact_light(obj)
struct obj *obj; struct obj *obj;
{ {
return (get_artifact(obj) && obj->oartifact == ART_SUNSWORD); return (boolean) (get_artifact(obj) && obj->oartifact == ART_SUNSWORD);
} }
/* KMH -- Talking artifacts are finally implemented */ /* KMH -- Talking artifacts are finally implemented */
@@ -1702,7 +1705,7 @@ uchar inv_prop;
{ {
const struct artifact *arti = get_artifact(otmp); const struct artifact *arti = get_artifact(otmp);
return ((boolean)(arti && (arti->inv_prop == inv_prop))); return (boolean) (arti && (arti->inv_prop == inv_prop));
} }
/* Return the price sold to the hero of a given artifact or unique item */ /* Return the price sold to the hero of a given artifact or unique item */
@@ -1711,9 +1714,9 @@ arti_cost(otmp)
struct obj *otmp; struct obj *otmp;
{ {
if (!otmp->oartifact) if (!otmp->oartifact)
return ((long) objects[otmp->otyp].oc_cost); return (long) objects[otmp->otyp].oc_cost;
else if (artilist[(int) otmp->oartifact].cost) else if (artilist[(int) otmp->oartifact].cost)
return (artilist[(int) otmp->oartifact].cost); return artilist[(int) otmp->oartifact].cost;
else else
return (100L * (long) objects[otmp->otyp].oc_cost); return (100L * (long) objects[otmp->otyp].oc_cost);
} }
@@ -1775,7 +1778,6 @@ long *abil;
/* /*
* Return the first item that is conveying a particular intrinsic. * Return the first item that is conveying a particular intrinsic.
*/ */
struct obj * struct obj *
what_gives(abil) what_gives(abil)
long *abil; long *abil;
@@ -1784,10 +1786,11 @@ long *abil;
uchar dtyp; uchar dtyp;
unsigned long spfx; unsigned long spfx;
long wornbits; long wornbits;
long wornmask = long wornmask = (W_ARM | W_ARMC | W_ARMH | W_ARMS
(W_ARM | W_ARMC | W_ARMH | W_ARMS | W_ARMG | W_ARMF | W_ARMU | W_ARMG | W_ARMF | W_ARMU
| W_AMUL | W_RINGL | W_RINGR | W_TOOL | W_ART | W_ARTI); | W_AMUL | W_RINGL | W_RINGR | W_TOOL
/* [do W_ART and W_ARTI actually belong here?] */ /* [do W_ART and W_ARTI actually belong here?] */
| W_ART | W_ARTI);
if (u.twoweap) if (u.twoweap)
wornmask |= W_SWAPWEP; wornmask |= W_SWAPWEP;
@@ -1797,7 +1800,7 @@ long *abil;
for (obj = invent; obj; obj = obj->nobj) { for (obj = invent; obj; obj = obj->nobj) {
if (obj->oartifact if (obj->oartifact
&& ((abil != &EWarn_of_mon) || context.warntype.obj)) { && (abil != &EWarn_of_mon || context.warntype.obj)) {
const struct artifact *art = get_artifact(obj); const struct artifact *art = get_artifact(obj);
if (art) { if (art) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 bones.c $NHDT-Date: 1432512767 2015/05/25 00:12:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */ /* NetHack 3.6 bones.c $NHDT-Date: 1446369463 2015/11/01 09:17:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -25,14 +25,15 @@ d_level *lev;
if (ledger_no(&save_dlevel)) if (ledger_no(&save_dlevel))
assign_level(lev, &save_dlevel); assign_level(lev, &save_dlevel);
return (boolean)( return (boolean) (((sptr = Is_special(lev)) != 0 && !sptr->boneid)
((sptr = Is_special(lev)) != 0 && !sptr->boneid) || !dungeons[lev->dnum].boneid
|| !dungeons[lev->dnum].boneid /* no bones on the last or multiway branch levels
/* no bones on the last or multiway branch levels */ in any dungeon (level 1 isn't multiway) */
/* in any dungeon (level 1 isn't multiway). */ || Is_botlevel(lev)
|| Is_botlevel(lev) || (Is_branchlev(lev) && lev->dlevel > 1) || (Is_branchlev(lev) && lev->dlevel > 1)
/* no bones in the invocation level */ /* no bones in the invocation level */
|| (In_hell(lev) && lev->dlevel == dunlevs_in_dungeon(lev) - 1)); || (In_hell(lev)
&& lev->dlevel == dunlevs_in_dungeon(lev) - 1));
} }
/* Call this function for each fruit object saved in the bones level: it marks /* Call this function for each fruit object saved in the bones level: it marks
@@ -311,12 +312,12 @@ can_make_bones()
return FALSE; return FALSE;
} }
if (depth(&u.uz) <= 0 || /* bulletproofing for endgame */ if (depth(&u.uz) <= 0 /* bulletproofing for endgame */
(!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */ || (!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */
&& !wizard)) && !wizard))
return FALSE; return FALSE;
/* don't let multiple restarts generate multiple copies of objects /* don't let multiple restarts generate multiple copies of objects
* in bones files */ in bones files */
if (discover) if (discover)
return FALSE; return FALSE;
return TRUE; return TRUE;
@@ -552,19 +553,19 @@ getbones()
char c, *bonesid, oldbonesid[10]; char c, *bonesid, oldbonesid[10];
if (discover) /* save bones files for real games */ if (discover) /* save bones files for real games */
return (0); return 0;
if (!flags.bones) if (!flags.bones)
return (0); return 0;
/* wizard check added by GAN 02/05/87 */ /* wizard check added by GAN 02/05/87 */
if (rn2(3) /* only once in three times do we find bones */ if (rn2(3) /* only once in three times do we find bones */
&& !wizard) && !wizard)
return (0); return 0;
if (no_bones_level(&u.uz)) if (no_bones_level(&u.uz))
return (0); return 0;
fd = open_bonesfile(&u.uz, &bonesid); fd = open_bonesfile(&u.uz, &bonesid);
if (fd < 0) if (fd < 0)
return (0); return 0;
if (validate(fd, bones) != 0) { if (validate(fd, bones) != 0) {
if (!wizard) if (!wizard)
@@ -576,7 +577,7 @@ getbones()
if (yn("Get bones?") == 'n') { if (yn("Get bones?") == 'n') {
(void) nhclose(fd); (void) nhclose(fd);
compress_bonesfile(); compress_bonesfile();
return (0); return 0;
} }
} }
mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */ mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */
@@ -626,7 +627,7 @@ getbones()
if (wizard) { if (wizard) {
if (yn("Unlink bones?") == 'n') { if (yn("Unlink bones?") == 'n') {
compress_bonesfile(); compress_bonesfile();
return (ok); return ok;
} }
} }
if (!delete_bonesfile(&u.uz)) { if (!delete_bonesfile(&u.uz)) {
@@ -637,9 +638,9 @@ getbones()
* -- just generate a new level for those N-1 games. * -- just generate a new level for those N-1 games.
*/ */
/* pline("Cannot unlink bones."); */ /* pline("Cannot unlink bones."); */
return (0); return 0;
} }
return (ok); return ok;
} }
/*bones.c*/ /*bones.c*/

270
src/cmd.c
View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1445301117 2015/10/20 00:31:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.202 $ */ /* NetHack 3.6 cmd.c $NHDT-Date: 1446369464 2015/11/01 09:17:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.205 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -209,9 +209,9 @@ timed_occupation(VOID_ARGS)
* The exception to this is taking off items, since they can be taken * The exception to this is taking off items, since they can be taken
* off in a number of ways in the intervening time, screwing up ordering. * off in a number of ways in the intervening time, screwing up ordering.
* *
* Currently: Take off all armor. * Currently: Take off all armor.
* Picking Locks / Forcing Chests. * Picking Locks / Forcing Chests.
* Setting traps. * Setting traps.
*/ */
void void
reset_occupations() reset_occupations()
@@ -290,7 +290,7 @@ char ch;
return; return;
} }
/* A ch == 0 resets the saveq. Only save keystrokes when not /* A ch == 0 resets the saveq. Only save keystrokes when not
* replaying a previous command. * replaying a previous command.
*/ */
void void
@@ -329,7 +329,9 @@ doextcmd(VOID_ARGS) /* here after # - now read a full-word command */
return retval; return retval;
} }
int doextlist(VOID_ARGS) /* here after #? - now list all full-word commands */ /* here after #? - now list all full-word commands */
int
doextlist(VOID_ARGS)
{ {
register const struct ext_func_tab *efp; register const struct ext_func_tab *efp;
char buf[BUFSZ]; char buf[BUFSZ];
@@ -353,12 +355,13 @@ int doextlist(VOID_ARGS) /* here after #? - now list all full-word commands */
#ifdef TTY_GRAPHICS #ifdef TTY_GRAPHICS
#define MAX_EXT_CMD 50 /* Change if we ever have > 50 ext cmds */ #define MAX_EXT_CMD 50 /* Change if we ever have > 50 ext cmds */
/*
* This is currently used only by the tty port and is /*
* controlled via runtime option 'extmenu'. * This is currently used only by the tty port and is
* ``# ?'' is counted towards the limit of the number of commands, * controlled via runtime option 'extmenu'.
* so we actually support MAX_EXT_CMD-1 "real" extended commands. * ``# ?'' is counted towards the limit of the number of commands,
*/ * so we actually support MAX_EXT_CMD-1 "real" extended commands.
*/
int int
extcmd_via_menu() /* here after # - now show pick-list of possible commands */ extcmd_via_menu() /* here after # - now show pick-list of possible commands */
{ {
@@ -666,8 +669,7 @@ wiz_level_tele(VOID_ARGS)
return 0; return 0;
} }
/* #monpolycontrol command - choose new form for shapechangers, polymorphees /* #monpolycontrol command - choose new form for shapechangers, polymorphees */
*/
STATIC_PTR int STATIC_PTR int
wiz_mon_polycontrol(VOID_ARGS) wiz_mon_polycontrol(VOID_ARGS)
{ {
@@ -875,13 +877,13 @@ wiz_map_levltyp(VOID_ARGS)
for (x = 1; x < COLNO; x++) { for (x = 1; x < COLNO; x++) {
terrain = levl[x][y].typ; terrain = levl[x][y].typ;
/* assumes there aren't more than 10+26+26 terrain types */ /* assumes there aren't more than 10+26+26 terrain types */
row[x - 1] = row[x - 1] = (char) ((terrain == 0 && !may_dig(x, y))
(char) ((terrain == 0 && !may_dig(x, y)) ? '*'
? '*' : (terrain < 10)
: (terrain < 10) ? '0' + terrain
? '0' + terrain : (terrain < 36)
: (terrain < 36) ? 'a' + terrain - 10 ? 'a' + terrain - 10
: 'A' + terrain - 36); : 'A' + terrain - 36);
} }
if (levl[0][y].typ != 0 || may_dig(0, y)) if (levl[0][y].typ != 0 || may_dig(0, y))
row[x++] = '!'; row[x++] = '!';
@@ -1282,7 +1284,8 @@ walking_on_water()
{ {
if (u.uinwater || Levitation || Flying) if (u.uinwater || Levitation || Flying)
return FALSE; return FALSE;
return (Wwalking && (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy))); return (boolean) (Wwalking
&& (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)));
} }
/* check whether hero is wearing something that player definitely knows /* check whether hero is wearing something that player definitely knows
@@ -1377,8 +1380,7 @@ int final;
char buf[BUFSZ], tmpbuf[BUFSZ]; char buf[BUFSZ], tmpbuf[BUFSZ];
/* note that if poly'd, we need to use u.mfemale instead of flags.female /* note that if poly'd, we need to use u.mfemale instead of flags.female
to access hero's saved gender-as-human/elf/&c rather than current one to access hero's saved gender-as-human/elf/&c rather than current one */
*/
innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0; innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0;
role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m; role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m;
rank_titl = rank_of(u.ulevel, Role_switch, innategend); rank_titl = rank_of(u.ulevel, Role_switch, innategend);
@@ -1459,9 +1461,9 @@ int final;
for tricky phrasing otherwise necessitated by possibility of having for tricky phrasing otherwise necessitated by possibility of having
helm of opposite alignment mask a permanent alignment conversion */ helm of opposite alignment mask a permanent alignment conversion */
difgend = (innategend != flags.initgend); difgend = (innategend != flags.initgend);
difalgn = difalgn = (((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0)
((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0) + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL])
+ ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL]) ? 2 : 0); ? 2 : 0));
if (difalgn & 1) { /* have temporary alignment so report permanent one */ if (difalgn & 1) { /* have temporary alignment so report permanent one */
Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT])); Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT]));
you_are(buf, ""); you_are(buf, "");
@@ -1607,16 +1609,16 @@ int final;
be set; we want to ignore steed in that situation */ be set; we want to ignore steed in that situation */
&& !(final == ENL_GAMEOVERDEAD && !(final == ENL_GAMEOVERDEAD
&& !strcmp(killer.name, "riding accident"))); && !strcmp(killer.name, "riding accident")));
const char *steedname = const char *steedname = (!Riding ? (char *) 0
!Riding : x_monnam(u.usteed,
? (char *) 0 u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE,
: x_monnam(u.usteed, u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE, (char *) 0,
(char *) 0, (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION), (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
FALSE); FALSE));
/*\ /*\
* Status (many are abbreviated on bottom line; others are or * Status (many are abbreviated on bottom line; others are or
* should be discernible to the hero hence to the player) * should be discernible to the hero hence to the player)
\*/ \*/
putstr(en_win, 0, ""); /* separator after title or characteristics */ putstr(en_win, 0, ""); /* separator after title or characteristics */
putstr(en_win, 0, final ? "Final Status:" : "Current Status:"); putstr(en_win, 0, final ? "Final Status:" : "Current Status:");
@@ -1839,11 +1841,11 @@ int final;
/* report being weaponless; distinguish whether gloves are worn */ /* report being weaponless; distinguish whether gloves are worn */
if (!uwep) { if (!uwep) {
you_are(uarmg ? "empty handed" /* gloves imply hands */ you_are(uarmg ? "empty handed" /* gloves imply hands */
/* no weapon and no gloves */ : humanoid(youmonst.data)
: humanoid(youmonst.data) /* hands but no weapon and no gloves */
? "bare handed" ? "bare handed"
/* alternate phrasing for paws or lack of hands */ /* alternate phrasing for paws or lack of hands */
: "not wielding anything", : "not wielding anything",
""); "");
/* two-weaponing implies a weapon (not other odd stuff) in each hand */ /* two-weaponing implies a weapon (not other odd stuff) in each hand */
} else if (u.twoweap) { } else if (u.twoweap) {
@@ -1883,7 +1885,7 @@ int final;
char buf[BUFSZ]; char buf[BUFSZ];
/*\ /*\
* Attributes * Attributes
\*/ \*/
putstr(en_win, 0, ""); putstr(en_win, 0, "");
putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:"); putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:");
@@ -2219,7 +2221,7 @@ int final;
if (wizard) if (wizard)
Sprintf(eos(buf), " (%d)", u.ugangr); Sprintf(eos(buf), " (%d)", u.ugangr);
enl_msg(u_gname(), " is", " was", buf, ""); enl_msg(u_gname(), " is", " was", buf, "");
} else } else {
/* /*
* We need to suppress this when the game is over, because death * We need to suppress this when the game is over, because death
* can change the value calculated by can_pray(), potentially * can change the value calculated by can_pray(), potentially
@@ -2227,20 +2229,24 @@ int final;
*/ */
if (!final) { if (!final) {
#if 0 #if 0
/* "can [not] safely pray" vs "could [not] have safely prayed" */ /* "can [not] safely pray" vs "could [not] have safely prayed" */
Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ", Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
final ? "have " : "", final ? "ed" : ""); final ? "have " : "", final ? "ed" : "");
#else #else
Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not "); Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
#endif #endif
if (wizard) if (wizard)
Sprintf(eos(buf), " (%d)", u.ublesscnt); Sprintf(eos(buf), " (%d)", u.ublesscnt);
you_can(buf, ""); you_can(buf, "");
}
} }
/* named fruit debugging (doesn't really belong here...) */
if (wizard) { if (wizard) {
int fcount = 0; int fcount = 0;
struct fruit *f; struct fruit *f;
char buf2[BUFSZ]; char buf2[BUFSZ];
for (f = ffruit; f; f = f->nextf) { for (f = ffruit; f; f = f->nextf) {
Sprintf(buf, "Fruit %d ", ++fcount); Sprintf(buf, "Fruit %d ", ++fcount);
Sprintf(buf2, "%s (id %d)", f->fname, f->fid); Sprintf(buf2, "%s (id %d)", f->fname, f->fid);
@@ -2515,9 +2521,9 @@ int final;
if (!u.uconduct.gnostic) if (!u.uconduct.gnostic)
you_have_been("an atheist"); you_have_been("an atheist");
if (!u.uconduct.weaphit) if (!u.uconduct.weaphit) {
you_have_never("hit with a wielded weapon"); you_have_never("hit with a wielded weapon");
else if (wizard) { } else if (wizard) {
Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit, Sprintf(buf, "used a wielded weapon %ld time%s", u.uconduct.weaphit,
plur(u.uconduct.weaphit)); plur(u.uconduct.weaphit));
you_have_X(buf); you_have_X(buf);
@@ -2525,9 +2531,9 @@ int final;
if (!u.uconduct.killer) if (!u.uconduct.killer)
you_have_been("a pacifist"); you_have_been("a pacifist");
if (!u.uconduct.literate) if (!u.uconduct.literate) {
you_have_been("illiterate"); you_have_been("illiterate");
else if (wizard) { } else if (wizard) {
Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate, Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate,
plur(u.uconduct.literate)); plur(u.uconduct.literate));
you_have_X(buf); you_have_X(buf);
@@ -2542,25 +2548,25 @@ int final;
you_have_X(buf); you_have_X(buf);
} }
if (!u.uconduct.polypiles) if (!u.uconduct.polypiles) {
you_have_never("polymorphed an object"); you_have_never("polymorphed an object");
else if (wizard) { } else if (wizard) {
Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles, Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles,
plur(u.uconduct.polypiles)); plur(u.uconduct.polypiles));
you_have_X(buf); you_have_X(buf);
} }
if (!u.uconduct.polyselfs) if (!u.uconduct.polyselfs) {
you_have_never("changed form"); you_have_never("changed form");
else if (wizard) { } else if (wizard) {
Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs, Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs,
plur(u.uconduct.polyselfs)); plur(u.uconduct.polyselfs));
you_have_X(buf); you_have_X(buf);
} }
if (!u.uconduct.wishes) if (!u.uconduct.wishes) {
you_have_X("used no wishes"); you_have_X("used no wishes");
else { } else {
Sprintf(buf, "used %ld wish%s", u.uconduct.wishes, Sprintf(buf, "used %ld wish%s", u.uconduct.wishes,
(u.uconduct.wishes > 1L) ? "es" : ""); (u.uconduct.wishes > 1L) ? "es" : "");
you_have_X(buf); you_have_X(buf);
@@ -2595,8 +2601,7 @@ static const struct func_tab cmdlist[] = {
{ C('i'), TRUE, wiz_identify }, { C('i'), TRUE, wiz_identify },
{ C('l'), TRUE, doredraw }, /* if number_pad is set */ { C('l'), TRUE, doredraw }, /* if number_pad is set */
{ C('n'), TRUE, donamelevel }, /* if number_pad is set */ { C('n'), TRUE, donamelevel }, /* if number_pad is set */
{ C('o'), TRUE, { C('o'), TRUE, dooverview_or_wiz_where }, /* depends on wizard status */
dooverview_or_wiz_where }, /* depending on wizard status */
{ C('p'), TRUE, doprev_message }, { C('p'), TRUE, doprev_message },
{ C('r'), TRUE, doredraw }, { C('r'), TRUE, doredraw },
{ C('t'), TRUE, dotele }, { C('t'), TRUE, dotele },
@@ -2608,7 +2613,7 @@ static const struct func_tab cmdlist[] = {
{ 'A', FALSE, doddoremarm }, { 'A', FALSE, doddoremarm },
{ M('a'), TRUE, doorganize }, { M('a'), TRUE, doorganize },
{ M('A'), TRUE, donamelevel }, /* #annotate */ { M('A'), TRUE, donamelevel }, /* #annotate */
/* 'b', 'B' : go sw */ /* 'b', 'B' : go sw */
{ 'c', FALSE, doclose }, { 'c', FALSE, doclose },
{ 'C', TRUE, docallcmd }, { 'C', TRUE, docallcmd },
{ M('c'), TRUE, dotalk }, { M('c'), TRUE, dotalk },
@@ -2620,21 +2625,21 @@ static const struct func_tab cmdlist[] = {
{ 'E', FALSE, doengrave }, { 'E', FALSE, doengrave },
{ M('e'), TRUE, enhance_weapon_skill }, { M('e'), TRUE, enhance_weapon_skill },
{ 'f', FALSE, dofire }, { 'f', FALSE, dofire },
/* 'F' : fight (one time) */ /* 'F' : fight (one time) */
{ M('f'), FALSE, doforce }, { M('f'), FALSE, doforce },
/* 'g', 'G' : multiple go */ /* 'g', 'G' : multiple go */
/* 'h', 'H' : go west */ /* 'h', 'H' : go west */
{ 'h', TRUE, dohelp }, /* if number_pad is set */ { 'h', TRUE, dohelp }, /* if number_pad is set */
{ 'i', TRUE, ddoinv }, { 'i', TRUE, ddoinv },
{ 'I', TRUE, dotypeinv }, /* Robert Viduya */ { 'I', TRUE, dotypeinv }, /* Robert Viduya */
{ M('i'), TRUE, doinvoke }, { M('i'), TRUE, doinvoke },
/* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */ /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */
{ 'j', FALSE, dojump }, /* if number_pad is on */ { 'j', FALSE, dojump }, /* if number_pad is on */
{ M('j'), FALSE, dojump }, { M('j'), FALSE, dojump },
{ 'k', FALSE, dokick }, /* if number_pad is on */ { 'k', FALSE, dokick }, /* if number_pad is on */
{ 'l', FALSE, doloot }, /* if number_pad is on */ { 'l', FALSE, doloot }, /* if number_pad is on */
{ M('l'), FALSE, doloot }, { M('l'), FALSE, doloot },
/* 'n' prefixes a count if number_pad is on */ /* 'n' prefixes a count if number_pad is on */
{ M('m'), TRUE, domonability }, { M('m'), TRUE, domonability },
{ 'N', TRUE, docallcmd }, /* if number_pad is on */ { 'N', TRUE, docallcmd }, /* if number_pad is on */
{ M('n'), TRUE, docallcmd }, { M('n'), TRUE, docallcmd },
@@ -2660,7 +2665,7 @@ static const struct func_tab cmdlist[] = {
{ 'T', FALSE, dotakeoff }, { 'T', FALSE, dotakeoff },
{ M('t'), TRUE, doturn }, { M('t'), TRUE, doturn },
{ M('T'), FALSE, dotip }, /* #tip */ { M('T'), FALSE, dotip }, /* #tip */
/* 'u', 'U' : go ne */ /* 'u', 'U' : go ne */
{ 'u', FALSE, dountrap }, /* if number_pad is on */ { 'u', FALSE, dountrap }, /* if number_pad is on */
{ M('u'), FALSE, dountrap }, { M('u'), FALSE, dountrap },
{ 'v', TRUE, doversion }, { 'v', TRUE, doversion },
@@ -2671,7 +2676,7 @@ static const struct func_tab cmdlist[] = {
{ M('w'), FALSE, dowipe }, { M('w'), FALSE, dowipe },
{ 'x', FALSE, doswapweapon }, { 'x', FALSE, doswapweapon },
{ 'X', FALSE, dotwoweapon }, { 'X', FALSE, dotwoweapon },
/* 'y', 'Y' : go nw */ /* 'y', 'Y' : go nw */
{ 'z', FALSE, dozap }, { 'z', FALSE, dozap },
{ 'Z', TRUE, docast }, { 'Z', TRUE, docast },
{ '<', FALSE, doup }, { '<', FALSE, doup },
@@ -3112,7 +3117,8 @@ void
reset_commands(initial) reset_commands(initial)
boolean initial; boolean initial;
{ {
static const char sdir[] = "hykulnjb><", sdir_swap_yz[] = "hzkulnjb><", static const char sdir[] = "hykulnjb><",
sdir_swap_yz[] = "hzkulnjb><",
ndir[] = "47896321><", ndir[] = "47896321><",
ndir_phone_layout[] = "41236987><"; ndir_phone_layout[] = "41236987><";
static const int ylist[] = { static const int ylist[] = {
@@ -3390,62 +3396,66 @@ register char *cmd;
int res, NDECL((*func)); int res, NDECL((*func));
#if 0 #if 0
for (tlist = cmdlist; tlist->f_char; tlist++) { /* obsolete - scan through the cmdlist array looking for *cmd */
if ((*cmd & 0xff) != (tlist->f_char & 0xff)) continue; for (tlist = cmdlist; tlist->f_char; tlist++) {
if ((*cmd & 0xff) != (tlist->f_char & 0xff))
continue;
#else #else
/* current - use *cmd to directly index cmdlist array */
if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) { if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
#endif #endif
if (u.uburied && !tlist->can_if_buried) {
if (u.uburied && !tlist->can_if_buried) { You_cant("do that while you are buried!");
You_cant("do that while you are buried!"); res = 0;
res = 0; } else {
} else { /* we discard 'const' because some compilers seem to have
/* we discard 'const' because some compilers seem to have trouble with the pointer passed to set_occupation() */
trouble with the pointer passed to set_occupation() */ func = ((struct func_tab *) tlist)->f_funct;
func = ((struct func_tab *) tlist)->f_funct; if (tlist->f_text && !occupation && multi)
if (tlist->f_text && !occupation && multi) set_occupation(func, tlist->f_text, multi);
set_occupation(func, tlist->f_text, multi); res = (*func)(); /* perform the command */
res = (*func)(); /* perform the command */ }
if (!res) {
context.move = FALSE;
multi = 0;
}
return;
} }
if (!res) { /* if we reach here, cmd wasn't found in cmdlist[] */
context.move = FALSE; bad_command = TRUE;
multi = 0;
}
return;
} }
/* if we reach here, cmd wasn't found in cmdlist[] */
bad_command = TRUE;
}
if (bad_command) { if (bad_command) {
char expcmd[10]; char expcmd[10];
register char c, *cp = expcmd; register char c, *cp = expcmd;
while ((c = *cmd++) != '\0' while ((c = *cmd++) != '\0'
&& (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) { && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) {
if (c >= 040 && c < 0177) { if (c >= 040 && c < 0177) {
*cp++ = c; *cp++ = c;
} else if (c & 0200) { } else if (c & 0200) {
*cp++ = 'M'; *cp++ = 'M';
*cp++ = '-'; *cp++ = '-';
*cp++ = c & ~0200; *cp++ = c & ~0200;
} else { } else {
*cp++ = '^'; *cp++ = '^';
*cp++ = c ^ 0100; *cp++ = c ^ 0100;
}
} }
*cp = '\0';
if (!prefix_seen || !iflags.cmdassist
|| !help_dir(0, "Invalid direction key!"))
Norep("Unknown command '%s'.", expcmd);
} }
*cp = '\0'; /* didn't move */
if (!prefix_seen || !iflags.cmdassist context.move = FALSE;
|| !help_dir(0, "Invalid direction key!")) multi = 0;
Norep("Unknown command '%s'.", expcmd); return;
}
/* didn't move */
context.move = FALSE;
multi = 0;
return;
} }
int xytod(x, y) /* convert an x,y pair into a direction code */ /* convert an x,y pair into a direction code */
int
xytod(x, y)
schar x, y; schar x, y;
{ {
register int dd; register int dd;
@@ -3453,11 +3463,12 @@ schar x, y;
for (dd = 0; dd < 8; dd++) for (dd = 0; dd < 8; dd++)
if (x == xdir[dd] && y == ydir[dd]) if (x == xdir[dd] && y == ydir[dd])
return dd; return dd;
return -1; return -1;
} }
void dtoxy(cc, dd) /* convert a direction code into an x,y pair */ /* convert a direction code into an x,y pair */
void
dtoxy(cc, dd)
coord *cc; coord *cc;
register int dd; register int dd;
{ {
@@ -3466,7 +3477,9 @@ register int dd;
return; return;
} }
int movecmd(sym) /* also sets u.dz, but returns false for <> */ /* also sets u.dz, but returns false for <> */
int
movecmd(sym)
char sym; char sym;
{ {
register const char *dp = index(Cmd.dirchars, sym); register const char *dp = index(Cmd.dirchars, sym);
@@ -3478,10 +3491,10 @@ char sym;
u.dy = ydir[dp - Cmd.dirchars]; u.dy = ydir[dp - Cmd.dirchars];
u.dz = zdir[dp - Cmd.dirchars]; u.dz = zdir[dp - Cmd.dirchars];
#if 0 /* now handled elsewhere */ #if 0 /* now handled elsewhere */
if (u.dx && u.dy && NODIAG(u.umonnum)) { if (u.dx && u.dy && NODIAG(u.umonnum)) {
u.dx = u.dy = 0; u.dx = u.dy = 0;
return 0; return 0;
} }
#endif #endif
return !u.dz; return !u.dz;
} }
@@ -3495,13 +3508,12 @@ dxdy_moveok()
return u.dx || u.dy; return u.dx || u.dy;
} }
/* decide whether a character (user input keystroke) requests screen repaint /* decide whether a character (user input keystroke) requests screen repaint */
*/
boolean boolean
redraw_cmd(c) redraw_cmd(c)
char c; char c;
{ {
return (c == C('r') || (Cmd.num_pad && c == C('l'))); return (boolean) (c == C('r') || (Cmd.num_pad && c == C('l')));
} }
/* /*
@@ -3807,9 +3819,9 @@ int x, y, mod;
if (mod == CLICK_1) { if (mod == CLICK_1) {
cmd[0] = Cmd.dirchars[dir]; cmd[0] = Cmd.dirchars[dir];
} else { } else {
cmd[0] = cmd[0] = (Cmd.num_pad
(Cmd.num_pad ? M(Cmd.dirchars[dir]) ? M(Cmd.dirchars[dir])
: (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */ : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
} }
return cmd; return cmd;
@@ -3906,7 +3918,7 @@ parse()
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
if (prezero) if (prezero)
in_line[0] = '\033'; in_line[0] = '\033';
return (in_line); return in_line;
} }
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
@@ -4006,7 +4018,7 @@ readchar()
readchar_queue = click_to_cmd(x, y, mod); readchar_queue = click_to_cmd(x, y, mod);
sym = *readchar_queue++; sym = *readchar_queue++;
} }
return ((char) sym); return (char) sym;
} }
STATIC_PTR int STATIC_PTR int

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 detect.c $NHDT-Date: 1436753510 2015/07/13 02:11:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */ /* NetHack 3.6 detect.c $NHDT-Date: 1446369464 2015/11/01 09:17:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -44,8 +44,9 @@ char oclass;
return (struct obj *) 0; return (struct obj *) 0;
} }
/* Recursively search obj for an object made of specified material and return /* Recursively search obj for an object made of specified material.
* 1st found */ * Return first found.
*/
struct obj * struct obj *
o_material(obj, material) o_material(obj, material)
struct obj *obj; struct obj *obj;
@@ -85,10 +86,10 @@ struct obj *obj;
STATIC_OVL boolean STATIC_OVL boolean
check_map_spot(x, y, oclass, material) check_map_spot(x, y, oclass, material)
int x, y; int x, y;
register char oclass; char oclass;
unsigned material; unsigned material;
{ {
register int glyph; int glyph;
register struct obj *otmp; register struct obj *otmp;
register struct monst *mtmp; register struct monst *mtmp;
@@ -96,14 +97,12 @@ unsigned material;
if (glyph_is_object(glyph)) { if (glyph_is_object(glyph)) {
/* there's some object shown here */ /* there's some object shown here */
if (oclass == ALL_CLASSES) { if (oclass == ALL_CLASSES) {
return ( return (boolean) !(level.objects[x][y] /* stale if nothing here */
(boolean)(!(level.objects[x][y] || /* stale if nothing here */ || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent));
((mtmp = m_at(x, y)) != 0 && (mtmp->minvent)))));
} else { } else {
if (material if (material
&& objects[glyph_to_obj(glyph)].oc_material == material) { && objects[glyph_to_obj(glyph)].oc_material == material) {
/* the object shown here is of interest because material /* object shown here is of interest because material matches */
* matches */
for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
if (o_material(otmp, GOLD)) if (o_material(otmp, GOLD))
return FALSE; return FALSE;
@@ -117,8 +116,7 @@ unsigned material;
return TRUE; return TRUE;
} }
if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) { if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) {
/* the object shown here is of interest because its class /* obj shown here is of interest because its class matches */
* matches */
for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
if (o_in(otmp, oclass)) if (o_in(otmp, oclass))
return FALSE; return FALSE;
@@ -137,18 +135,18 @@ unsigned material;
} }
/* /*
When doing detection, remove stale data from the map display (corpses * When doing detection, remove stale data from the map display (corpses
rotted away, objects carried away by monsters, etc) so that it won't * rotted away, objects carried away by monsters, etc) so that it won't
reappear after the detection has completed. Return true if noticeable * reappear after the detection has completed. Return true if noticeable
change occurs. * change occurs.
*/ */
STATIC_OVL boolean STATIC_OVL boolean
clear_stale_map(oclass, material) clear_stale_map(oclass, material)
register char oclass; char oclass;
unsigned material; unsigned material;
{ {
register int zx, zy; register int zx, zy;
register boolean change_made = FALSE; boolean change_made = FALSE;
for (zx = 1; zx < COLNO; zx++) for (zx = 1; zx < COLNO; zx++)
for (zy = 0; zy < ROWNO; zy++) for (zy = 0; zy < ROWNO; zy++)
@@ -218,13 +216,13 @@ register struct obj *sobj;
Strcpy(buf, "You feel materially poor."); Strcpy(buf, "You feel materially poor.");
strange_feeling(sobj, buf); strange_feeling(sobj, buf);
} }
return (1); return 1;
} }
/* only under me - no separate display required */ /* only under me - no separate display required */
if (stale) if (stale)
docrt(); docrt();
You("notice some gold between your %s.", makeplural(body_part(FOOT))); You("notice some gold between your %s.", makeplural(body_part(FOOT)));
return (0); return 0;
outgoldmap: outgoldmap:
cls(); cls();
@@ -281,11 +279,11 @@ outgoldmap:
under_water(2); under_water(2);
if (u.uburied) if (u.uburied)
under_ground(2); under_ground(2);
return (0); return 0;
} }
/* returns 1 if nothing was detected */ /* returns 1 if nothing was detected */
/* returns 0 if something was detected */ /* returns 0 if something was detected */
int int
food_detect(sobj) food_detect(sobj)
register struct obj *sobj; register struct obj *sobj;
@@ -333,9 +331,9 @@ register struct obj *sobj;
? " then starts to tingle" ? " then starts to tingle"
: ""); : "");
if (sobj->blessed && !u.uedibility) { if (sobj->blessed && !u.uedibility) {
boolean savebeginner = boolean savebeginner = flags.beginner;
flags.beginner; /* prevent non-delivery of */
flags.beginner = FALSE; /* message */ flags.beginner = FALSE; /* prevent non-delivery of message */
strange_feeling(sobj, buf); strange_feeling(sobj, buf);
flags.beginner = savebeginner; flags.beginner = savebeginner;
u.uedibility = 1; u.uedibility = 1;
@@ -394,14 +392,14 @@ register struct obj *sobj;
if (u.uburied) if (u.uburied)
under_ground(2); under_ground(2);
} }
return (0); return 0;
} }
/* /*
* Used for scrolls, potions, spells, and crystal balls. Returns: * Used for scrolls, potions, spells, and crystal balls. Returns:
* *
* 1 - nothing was detected * 1 - nothing was detected
* 0 - something was detected * 0 - something was detected
*/ */
int int
object_detect(detector, class) object_detect(detector, class)
@@ -501,7 +499,7 @@ int class; /* an object class, 0 for all */
iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied; iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
u.uinwater = u.uburied = 0; u.uinwater = u.uburied = 0;
/* /*
* Map all buried objects first. * Map all buried objects first.
*/ */
for (obj = level.buriedobjlist; obj; obj = obj->nobj) for (obj = level.buriedobjlist; obj; obj = obj->nobj)
if (!class || (otmp = o_in(obj, class))) { if (!class || (otmp = o_in(obj, class))) {
@@ -726,10 +724,11 @@ int how; /* 1 for misleading map feedback */
return result; return result;
} }
/* the detections are pulled out so they can */ /* the detections are pulled out so they can
/* also be used in the crystal ball routine */ * also be used in the crystal ball routine
/* returns 1 if nothing was detected */ * returns 1 if nothing was detected
/* returns 0 if something was detected */ * returns 0 if something was detected
*/
int int
trap_detect(sobj) trap_detect(sobj)
register struct obj *sobj; register struct obj *sobj;
@@ -790,11 +789,11 @@ register struct obj *sobj;
Sprintf(buf, "Your %s stop itching.", makeplural(body_part(TOE))); Sprintf(buf, "Your %s stop itching.", makeplural(body_part(TOE)));
strange_feeling(sobj, buf); strange_feeling(sobj, buf);
return (1); return 1;
} }
/* traps exist, but only under me - no separate display required */ /* traps exist, but only under me - no separate display required */
Your("%s itch.", makeplural(body_part(TOE))); Your("%s itch.", makeplural(body_part(TOE)));
return (0); return 0;
outtrapmap: outtrapmap:
cls(); cls();
@@ -835,7 +834,7 @@ outtrapmap:
under_water(2); under_water(2);
if (u.uburied) if (u.uburied)
under_ground(2); under_ground(2);
return (0); return 0;
} }
const char * const char *
@@ -1248,12 +1247,14 @@ int findit() /* returns number of things found */
int num = 0; int num = 0;
if (u.uswallow) if (u.uswallow)
return (0); return 0;
do_clear_area(u.ux, u.uy, BOLT_LIM, findone, (genericptr_t) &num); do_clear_area(u.ux, u.uy, BOLT_LIM, findone, (genericptr_t) &num);
return (num); return num;
} }
int openit() /* returns number of things found and opened */ /* returns number of things found and opened */
int
openit()
{ {
int num = 0; int num = 0;
@@ -1265,11 +1266,11 @@ int openit() /* returns number of things found and opened */
pline("%s opens its mouth!", Monnam(u.ustuck)); pline("%s opens its mouth!", Monnam(u.ustuck));
} }
expels(u.ustuck, u.ustuck->data, TRUE); expels(u.ustuck, u.ustuck->data, TRUE);
return (-1); return -1;
} }
do_clear_area(u.ux, u.uy, BOLT_LIM, openone, (genericptr_t) &num); do_clear_area(u.ux, u.uy, BOLT_LIM, openone, (genericptr_t) &num);
return (num); return num;
} }
/* callback hack for overriding vision in do_clear_area() */ /* callback hack for overriding vision in do_clear_area() */
@@ -1331,10 +1332,9 @@ register int aflag; /* intrinsic autosearch vs explicit searching */
if (!aflag) if (!aflag)
pline("What are you looking for? The exit?"); pline("What are you looking for? The exit?");
} else { } else {
int fund = int fund = (uwep && uwep->oartifact
(uwep && uwep->oartifact && spec_ability(uwep, SPFX_SEARCH)) && spec_ability(uwep, SPFX_SEARCH)) ? uwep->spe : 0;
? uwep->spe
: 0;
if (ublindf && ublindf->otyp == LENSES && !Blind) if (ublindf && ublindf->otyp == LENSES && !Blind)
fund += 2; /* JDS: lenses help searching */ fund += 2; /* JDS: lenses help searching */
if (fund > 5) if (fund > 5)
@@ -1343,99 +1343,95 @@ register int aflag; /* intrinsic autosearch vs explicit searching */
for (y = u.uy - 1; y < u.uy + 2; y++) { for (y = u.uy - 1; y < u.uy + 2; y++) {
if (!isok(x, y)) if (!isok(x, y))
continue; continue;
if (x != u.ux || y != u.uy) { if (x == u.ux && y == u.uy)
if (Blind && !aflag) continue;
feel_location(x, y);
if (levl[x][y].typ == SDOOR) { if (Blind && !aflag)
if (rnl(7 - fund)) feel_location(x, y);
continue; if (levl[x][y].typ == SDOOR) {
cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */ if (rnl(7 - fund))
exercise(A_WIS, TRUE); continue;
nomul(0); cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */
feel_location(x, y); /* make sure it shows up */ exercise(A_WIS, TRUE);
You("find a hidden door."); nomul(0);
} else if (levl[x][y].typ == SCORR) { feel_location(x, y); /* make sure it shows up */
if (rnl(7 - fund)) You("find a hidden door.");
continue; } else if (levl[x][y].typ == SCORR) {
levl[x][y].typ = CORR; if (rnl(7 - fund))
unblock_point(x, y); /* vision */ continue;
exercise(A_WIS, TRUE); levl[x][y].typ = CORR;
nomul(0); unblock_point(x, y); /* vision */
feel_location(x, y); /* make sure it shows up */ exercise(A_WIS, TRUE);
You("find a hidden passage."); nomul(0);
} else { feel_location(x, y); /* make sure it shows up */
/* Be careful not to find anything in an SCORR or You("find a hidden passage.");
* SDOOR */ } else {
if ((mtmp = m_at(x, y)) && !aflag) { /* Be careful not to find anything in an SCORR or SDOOR */
if (mtmp->m_ap_type) { if ((mtmp = m_at(x, y)) != 0 && !aflag) {
seemimic(mtmp); if (mtmp->m_ap_type) {
find: seemimic(mtmp);
exercise(A_WIS, TRUE); find:
if (!canspotmon(mtmp)) { exercise(A_WIS, TRUE);
if (glyph_is_invisible(
levl[x][y].glyph)) {
/* found invisible monster in a square
* which already has an 'I' in it.
* Logically, this should still take
* time and lead to a return(1), but
* if
* we did that the player would keep
* finding the same monster every
* turn.
*/
continue;
} else {
You_feel("an unseen monster!");
map_invisible(x, y);
}
} else if (!sensemon(mtmp))
You("find %s.", mtmp->mtame
? y_monnam(mtmp)
: a_monnam(mtmp));
return (1);
}
if (!canspotmon(mtmp)) { if (!canspotmon(mtmp)) {
if (mtmp->mundetected if (glyph_is_invisible(levl[x][y].glyph)) {
&& (is_hider(mtmp->data) /* found invisible monster in a square
|| mtmp->data->mlet == S_EEL)) * which already has an 'I' in it.
mtmp->mundetected = 0; * Logically, this should still take
newsym(x, y); * time and lead to a return(1), but
goto find; * if we did that the player would keep
} * finding the same monster every turn.
*/
continue;
} else {
You_feel("an unseen monster!");
map_invisible(x, y);
}
} else if (!sensemon(mtmp))
You("find %s.", mtmp->mtame
? y_monnam(mtmp)
: a_monnam(mtmp));
return 1;
} }
if (!canspotmon(mtmp)) {
/* see if an invisible monster has moved--if Blind, if (mtmp->mundetected
* feel_location() already did it && (is_hider(mtmp->data)
*/ || mtmp->data->mlet == S_EEL))
if (!aflag && !mtmp && !Blind mtmp->mundetected = 0;
&& glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y); newsym(x, y);
goto find;
} }
}
if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) { /* see if an invisible monster has moved--if Blind,
nomul(0); * feel_location() already did it
*/
if (!aflag && !mtmp && !Blind
&& glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
}
if (trap->ttyp == STATUE_TRAP) { if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) {
if (activate_statue_trap(trap, x, y, FALSE)) nomul(0);
exercise(A_WIS, TRUE); if (trap->ttyp == STATUE_TRAP) {
return (1); if (activate_statue_trap(trap, x, y, FALSE))
} else { exercise(A_WIS, TRUE);
find_trap(trap); return 1;
} } else {
find_trap(trap);
} }
} }
} }
} }
} }
return (1); return 1;
} }
/* the 's' command -- explicit searching */ /* the 's' command -- explicit searching */
int int
dosearch() dosearch()
{ {
return (dosearch0(0)); return dosearch0(0);
} }
/* Pre-map the sokoban levels */ /* Pre-map the sokoban levels */
@@ -1497,14 +1493,17 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */
for (x = 1; x < COLNO; x++) for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) { for (y = 0; y < ROWNO; y++) {
seenv = (full || level.flags.hero_memory) seenv = (full || level.flags.hero_memory)
? levl[x][y].seenv : cansee(x, y) ? SVALL : 0; ? levl[x][y].seenv : cansee(x, y) ? SVALL : 0;
if (full) { if (full) {
levl[x][y].seenv = SVALL; levl[x][y].seenv = SVALL;
glyph = back_to_glyph(x, y); glyph = back_to_glyph(x, y);
levl[x][y].seenv = seenv; levl[x][y].seenv = seenv;
} else { } else {
levl_glyph = level.flags.hero_memory ? levl[x][y].glyph levl_glyph = level.flags.hero_memory
: seenv ? back_to_glyph(x, y) : default_glyph; ? levl[x][y].glyph
: seenv
? back_to_glyph(x, y)
: default_glyph;
/* glyph_at() returns the displayed glyph, which might /* glyph_at() returns the displayed glyph, which might
be a monster. levl[][].glyph contains the remembered be a monster. levl[][].glyph contains the remembered
glyph, which will never be a monster (unless it is glyph, which will never be a monster (unless it is
@@ -1556,9 +1555,11 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */
} }
show_glyph(x, y, glyph); show_glyph(x, y, glyph);
} }
/* [TODO: highlight hero's location somehow] */ /* [TODO: highlight hero's location somehow] */
u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied; u.uinwater = iflags.save_uinwater, u.uburied = iflags.save_uburied;
if (save_swallowed) u.uswallow = 1; if (save_swallowed)
u.uswallow = 1;
flush_screen(1); flush_screen(1);
if (full) { if (full) {
Strcpy(buf, "underlying terrain"); Strcpy(buf, "underlying terrain");

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 dig.c $NHDT-Date: 1446191874 2015/10/30 07:57:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.98 $ */ /* NetHack 3.6 dig.c $NHDT-Date: 1446369465 2015/11/01 09:17:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -152,19 +152,19 @@ xchar x, y;
if (!ispick && !is_axe(otmp)) if (!ispick && !is_axe(otmp))
return DIGTYP_UNDIGGABLE; return DIGTYP_UNDIGGABLE;
return (ispick && sobj_at(STATUE, x, y) return ((ispick && sobj_at(STATUE, x, y))
? DIGTYP_STATUE ? DIGTYP_STATUE
: ispick && sobj_at(BOULDER, x, y) : (ispick && sobj_at(BOULDER, x, y))
? DIGTYP_BOULDER ? DIGTYP_BOULDER
: closed_door(x, y) : closed_door(x, y)
? DIGTYP_DOOR ? DIGTYP_DOOR
: IS_TREE(levl[x][y].typ) : IS_TREE(levl[x][y].typ)
? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE) ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE)
: ispick && IS_ROCK(levl[x][y].typ) : (ispick && IS_ROCK(levl[x][y].typ)
&& (!level.flags.arboreal && (!level.flags.arboreal
|| IS_WALL(levl[x][y].typ)) || IS_WALL(levl[x][y].typ)))
? DIGTYP_ROCK ? DIGTYP_ROCK
: DIGTYP_UNDIGGABLE); : DIGTYP_UNDIGGABLE);
} }
boolean boolean
@@ -1013,7 +1013,6 @@ struct obj *obj;
/* MRKR: use_pick_axe() is split in two to allow autodig to bypass */ /* MRKR: use_pick_axe() is split in two to allow autodig to bypass */
/* the "In what direction do you want to dig?" query. */ /* the "In what direction do you want to dig?" query. */
/* use_pick_axe2() uses the existing u.dx, u.dy and u.dz */ /* use_pick_axe2() uses the existing u.dx, u.dy and u.dz */
int int
use_pick_axe2(obj) use_pick_axe2(obj)
struct obj *obj; struct obj *obj;
@@ -1596,8 +1595,7 @@ char *msg;
return FALSE; return FALSE;
if (!isok(cc->x, cc->y)) if (!isok(cc->x, cc->y))
return FALSE; return FALSE;
if (msg) *msg = '\0';
*msg = '\0';
room = &levl[cc->x][cc->y]; room = &levl[cc->x][cc->y];
ltyp = room->typ; ltyp = room->typ;
@@ -1626,21 +1624,21 @@ char *msg;
/* "set of iron bars" */ /* "set of iron bars" */
Strcpy(msg, "The bars go much deeper than your pit."); Strcpy(msg, "The bars go much deeper than your pit.");
#if 0 #if 0
} else if (is_lava(cc->x,cc->y)) { } else if (is_lava(cc->x, cc->y)) {
} else if (is_ice(cc->x,cc->y)) { } else if (is_ice(cc->x, cc->y)) {
} else if (is_pool(cc->x,cc->y)) { } else if (is_pool(cc->x, cc->y)) {
} else if (IS_GRAVE(ltyp)) { } else if (IS_GRAVE(ltyp)) {
#endif #endif
} else if (IS_SINK(ltyp)) { } else if (IS_SINK(ltyp)) {
Strcpy(msg, "A tangled mass of plumbing remains below the sink."); Strcpy(msg, "A tangled mass of plumbing remains below the sink.");
return FALSE; return FALSE;
} else if ((cc->x == xupladder && cc->y == yupladder) || /* "ladder up" */ } else if ((cc->x == xupladder && cc->y == yupladder) /* ladder up */
(cc->x == xdnladder || (cc->x == xdnladder && cc->y == ydnladder)) { /* " down */
&& cc->y == ydnladder)) { /* "ladder down" */
Strcpy(msg, "The ladder is unaffected."); Strcpy(msg, "The ladder is unaffected.");
return FALSE; return FALSE;
} else { } else {
const char *supporting = (const char *) 0; const char *supporting = (const char *) 0;
if (IS_FOUNTAIN(ltyp)) if (IS_FOUNTAIN(ltyp))
supporting = "fountain"; supporting = "fountain";
else if (IS_THRONE(ltyp)) else if (IS_THRONE(ltyp))
@@ -1657,9 +1655,10 @@ char *msg;
&& !sstairs.up)) && !sstairs.up))
/* "staircase down" */ /* "staircase down" */
supporting = "stairs"; supporting = "stairs";
else if ((ltyp == DRAWBRIDGE_DOWN) || /* "lowered drawbridge" */ else if (ltyp == DRAWBRIDGE_DOWN /* "lowered drawbridge" */
(ltyp == DBWALL)) /* "raised drawbridge" */ || ltyp == DBWALL) /* "raised drawbridge" */
supporting = "drawbridge"; supporting = "drawbridge";
if (supporting) { if (supporting) {
Sprintf(msg, "The %s%ssupporting structures remain intact.", Sprintf(msg, "The %s%ssupporting structures remain intact.",
supporting ? s_suffix(supporting) : "", supporting ? s_suffix(supporting) : "",
@@ -1717,6 +1716,7 @@ coord *cc;
{ {
xchar check_x, check_y; xchar check_x, check_y;
struct obj *otmp, *otmp2; struct obj *otmp, *otmp2;
if (u.utraptype == TT_BURIEDBALL) if (u.utraptype == TT_BURIEDBALL)
for (otmp = level.buriedobjlist; otmp; otmp = otmp2) { for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
otmp2 = otmp->nobj; otmp2 = otmp->nobj;
@@ -1793,8 +1793,8 @@ buried_ball_to_freedom()
} }
} }
/* move objects from fobj/nexthere lists to buriedobjlist, keeping position */ /* move objects from fobj/nexthere lists to buriedobjlist, keeping position
/* information */ information */
struct obj * struct obj *
bury_an_obj(otmp, dealloced) bury_an_obj(otmp, dealloced)
struct obj *otmp; struct obj *otmp;
@@ -1895,9 +1895,9 @@ int x, y;
for (otmp = level.buriedobjlist; otmp; otmp = otmp2) { for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
otmp2 = otmp->nobj; otmp2 = otmp->nobj;
if (otmp->ox == x && otmp->oy == y) { if (otmp->ox == x && otmp->oy == y) {
if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) if (bball && otmp == bball && u.utraptype == TT_BURIEDBALL) {
buried_ball_to_punishment(); buried_ball_to_punishment();
else { } else {
obj_extract_self(otmp); obj_extract_self(otmp);
if (otmp->timed) if (otmp->timed)
(void) stop_timer(ROT_ORGANIC, obj_to_any(otmp)); (void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));