-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL int FDECL(use_cream_pie, (struct obj *));
STATIC_DCL int FDECL(use_grapple, (struct obj *));
STATIC_DCL int FDECL(do_break_wand, (struct obj *));
-STATIC_DCL boolean
-FDECL(figurine_location_checks, (struct obj *, coord *, BOOLEAN_P));
+STATIC_DCL boolean FDECL(figurine_location_checks, (struct obj *,
+ coord *, BOOLEAN_P));
STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
STATIC_DCL void FDECL(setapplyclasses, (char *));
STATIC_DCL boolean FDECL(is_valid_jump_pos, (int, int, int, BOOLEAN_P));
use_camera(obj)
struct obj *obj;
{
- register struct monst *mtmp;
+ struct monst *mtmp;
if (Underwater) {
pline("Using your camera underwater would void the warranty.");
- return (0);
+ return 0;
}
if (!getdir((char *) 0))
- return (0);
+ return 0;
if (obj->spe <= 0) {
pline1(nothing_happens);
- return (1);
+ return 1;
}
consume_obj_charge(obj, TRUE);
return 0;
} else if (obj->cursed) {
long old;
+
switch (rn2(3)) {
case 2:
old = Glib;
boolean
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
number_leashed()
{
- register int i = 0;
- register struct obj *obj;
+ int i = 0;
+ struct obj *obj;
for (obj = invent; obj; obj = obj->nobj)
if (obj->otyp == LEASH && obj->leashmon != 0)
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 monst *mtmp;
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;
boolean feedback;
{
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 monst *mtmp;
leashable(mtmp)
struct monst *mtmp;
{
- return mtmp->mnum != PM_LONG_WORM;
+ return (boolean) (mtmp->mnum != PM_LONG_WORM);
}
/* ARGSUSED */
return;
}
-struct obj *get_mleash(mtmp) /* assuming mtmp->mleashed has been checked */
-register struct monst *mtmp;
+/* assuming mtmp->mleashed has been checked */
+struct obj *
+get_mleash(mtmp)
+struct monst *mtmp;
{
- register struct obj *otmp;
+ struct obj *otmp;
otmp = invent;
while (otmp) {
if (otmp->otyp == LEASH && otmp->leashmon == (int) mtmp->m_id)
- return (otmp);
+ return otmp;
otmp = otmp->nobj;
}
- return ((struct obj *) 0);
+ return (struct obj *) 0;
}
boolean
if (otmp->otyp == LEASH
&& otmp->leashmon == (int) mtmp->m_id) {
if (otmp->cursed)
- return (FALSE);
+ return FALSE;
You_feel("%s leash go slack.",
(number_leashed() > 1) ? "a" : "the");
mtmp->mleashed = 0;
/* no pack mules for the Amulet */
if (u.usteed && mon_has_amulet(u.usteed))
return FALSE;
- return (TRUE);
+ return TRUE;
}
void
const char *
beautiful()
{
- return (ACURR(A_CHA) > 14)
- ? (poly_gender() == 1 ? "beautiful" : "handsome")
- : "ugly";
+ return ((ACURR(A_CHA) > 14)
+ ? ((poly_gender() == 1)
+ ? "beautiful"
+ : "handsome")
+ : "ugly");
}
#define WEAK 3 /* from eat.c */
}
}
-boolean snuff_candle(otmp) /* call in drop, throw, and put in box, etc. */
-register struct obj *otmp;
+/* call in drop, throw, and put in box, etc. */
+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)
&& otmp->lamplit) {
char buf[BUFSZ];
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);
if (otmp->where == OBJ_MINVENT ? cansee(x, y) : !Blind)
(candle ? "" : "candelabrum's "), (many ? "s'" : "'s"),
(many ? "s are" : " is"));
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
return 0;
} else if (u.usteed && u.utrap) {
pline("%s is stuck in a trap.", Monnam(u.usteed));
- return (0);
+ return 0;
}
pline("Where do you want to jump?");
STATIC_OVL void
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
* moves, we've got to deal with decaying corpses...
return 1;
}
-static const char not_enough_room[] =
- "There's not enough room here to use that.",
- where_to_hit[] = "Where do you want to hit?",
- cant_see_spot[] =
- "won't hit anything if you can't see that spot.",
- cant_reach[] = "can't reach that spot from here.";
+static const char
+ not_enough_room[] = "There's not enough room here to use that.",
+ where_to_hit[] = "Where do you want to hit?",
+ cant_see_spot[] = "won't hit anything if you can't see that spot.",
+ cant_reach[] = "can't reach that spot from here.";
/* find pos of monster in range, if only one monster */
boolean
{
struct monst *mtmp;
struct monst *selmon = NULL;
+
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (mtmp && !DEADMONSTER(mtmp) && !mtmp->mtame
&& cansee(mtmp->mx, mtmp->my)
tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos));
} else if (state == 1) {
int x, y, dx, dy;
+
for (dx = -4; dx <= 4; dx++)
for (dy = -4; dy <= 4; dy++) {
x = dx + (int) u.ux;
/* Are you allowed to use the pole? */
if (u.uswallow) {
pline(not_enough_room);
- return (0);
+ return 0;
}
if (obj != uwep) {
if (!wield_tool(obj, "swing"))
- return (0);
+ return 0;
else
res = 1;
}
glyph = glyph_at(cc.x, cc.y);
if (distu(cc.x, cc.y) > max_range) {
pline("Too far!");
- return (res);
+ return res;
} else if (distu(cc.x, cc.y) < min_range) {
pline("Too close!");
- return (res);
+ return res;
} else if (!cansee(cc.x, cc.y) && !glyph_is_monster(glyph)
&& !glyph_is_invisible(glyph) && !glyph_is_statue(glyph)) {
You(cant_see_spot);
- return (res);
+ return res;
} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
You(cant_reach);
return res;
check_caitiff(mtmp);
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
(void) thitmonst(mtmp, uwep);
- } else if (glyph_is_statue(glyph) && /* might be hallucinatory */
- sobj_at(STATUE, bhitpos.x, bhitpos.y)) {
+ } else if (glyph_is_statue(glyph) /* might be hallucinatory */
+ && sobj_at(STATUE, bhitpos.x, bhitpos.y)) {
struct trap *t = t_at(bhitpos.x, bhitpos.y);
if (t && t->ttyp == STATUE_TRAP
You("miss; there is no one there to hit.");
}
u_wipe_engr(2); /* same as for melee or throwing */
- return (1);
+ return 1;
}
STATIC_OVL int
costly_alteration(obj, COST_SPLAT);
obj_extract_self(obj);
delobj(obj);
- return (0);
+ return 0;
}
STATIC_OVL int
/* Are you allowed to use the hook? */
if (u.uswallow) {
pline(not_enough_room);
- return (0);
+ return 0;
}
if (obj != uwep) {
if (!wield_tool(obj, "cast"))
- return (0);
+ return 0;
else
res = 1;
}
max_range = 8;
if (distu(cc.x, cc.y) > max_range) {
pline("Too far!");
- return (res);
+ return res;
} else if (!cansee(cc.x, cc.y)) {
You(cant_see_spot);
- return (res);
+ return res;
} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
You(cant_reach);
return res;
(void) pickup_object(otmp, 1L, FALSE);
/* If pickup fails, leave it alone */
newsym(cc.x, cc.y);
- return (1);
+ return 1;
}
break;
case 2: /* Monster */
You("pull in %s!", mon_nam(mtmp));
mtmp->mundetected = 0;
rloc_to(mtmp, cc.x, cc.y);
- return (1);
+ return 1;
} else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data))
|| rn2(4)) {
flags.confirm = FALSE;
flags.confirm = save_confirm;
check_caitiff(mtmp);
(void) thitmonst(mtmp, uwep);
- return (1);
+ return 1;
}
/* FALL THROUGH */
case 3: /* Surface */
hurtle(sgn(cc.x - u.ux), sgn(cc.y - u.uy), 1, FALSE);
spoteffects(TRUE);
}
- return (1);
+ return 1;
default: /* Yourself (oops!) */
if (P_SKILL(typ) <= P_BASIC) {
You("hook yourself!");
losehp(Maybe_Half_Phys(rn1(10, 10)), "a grappling hook",
KILLED_BY);
- return (1);
+ return 1;
}
break;
}
pline1(nothing_happens);
- return (1);
+ return 1;
}
#define BY_OBJECT ((struct monst *) 0)
boolean is_fragile = (!strcmp(OBJ_DESCR(objects[obj->otyp]), "balsa"));
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")))
return 0;
if (obj->otyp == WAN_DIGGING) {
schar typ;
+
if (dig_check(BY_OBJECT, FALSE, x, y)) {
if (IS_WALL(levl[x][y].typ) || IS_DOOR(levl[x][y].typ)) {
/* normally, pits and holes don't anger guards, but they
typ = fillholetyp(x, y, FALSE);
if (typ != ROOM) {
levl[x][y].typ = typ;
- liquid_flow(
- x, y, typ, t_at(x, y),
- fillmsg ? (char *) 0
- : "Some holes are quickly filled with %s!");
+ liquid_flow(x, y, typ, t_at(x, y),
+ fillmsg
+ ? (char *) 0
+ : "Some holes are quickly filled with %s!");
fillmsg = TRUE;
} else
- digactualhole(
- x, y, BY_OBJECT,
- (rn2(obj->spe) < 3
- || (!Can_dig_down(&u.uz) && !levl[x][y].candig))
- ? PIT
- : HOLE);
+ digactualhole(x, y, BY_OBJECT, (rn2(obj->spe) < 3
+ || (!Can_dig_down(&u.uz)
+ && !levl[x][y].candig))
+ ? PIT
+ : HOLE);
}
continue;
} else if (obj->otyp == WAN_CREATE_MONSTER) {
add_class(class_list, FOOD_CLASS);
}
+/* the 'a' command */
int
doapply()
{
char class_list[MAXOCLASSES + 2];
if (check_capacity((char *) 0))
- return (0);
+ return 0;
setapplyclasses(class_list); /* tools[] */
obj = getobj(class_list, "use or apply");
if (obj == ublindf) {
if (!cursed(obj))
Blindf_off(obj);
- } else if (!ublindf)
+ } else if (!ublindf) {
Blindf_on(obj);
- else
+ } else {
You("are already %s.", ublindf->otyp == TOWEL
? "covered by a towel"
: ublindf->otyp == BLINDFOLD
? "wearing a blindfold"
: "wearing lenses");
+ }
break;
case CREAM_PIE:
res = use_cream_pie(obj);
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
/*
* Note: both artilist[] and artiexist[] have a dummy element #0,
- * so loops over them should normally start at #1. The primary
- * exception is the save & restore code, which doesn't care about
- * the contents, just the total size.
+ * so loops over them should normally start at #1. The primary
+ * exception is the save & restore code, which doesn't care about
+ * the contents, just the total size.
*/
extern boolean notonhead; /* for long worms */
int artinum;
{
if (artinum <= 0 || artinum > NROFARTIFACTS)
- return ("");
- return (artilist[artinum].name);
+ return "";
+ return artilist[artinum].name;
}
/*
boolean
exist_artifact(otyp, name)
-register int otyp;
-register const char *name;
+int otyp;
+const char *name;
{
register const struct artifact *a;
- register boolean *arex;
+ boolean *arex;
if (otyp && *name)
for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++)
void
artifact_exists(otmp, name, mod)
-register struct obj *otmp;
-register const char *name;
-register boolean mod;
+struct obj *otmp;
+const char *name;
+boolean mod;
{
register const struct artifact *a;
{
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 */
if (obj->otyp == LUCKSTONE)
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 */
return FALSE;
}
+/* returns 1 if name is restricted for otmp->otyp */
boolean
-restrict_name(otmp, name) /* returns 1 if name is restricted for otmp->otyp */
-register struct obj *otmp;
-register const char *name;
+restrict_name(otmp, name)
+struct obj *otmp;
+const char *name;
{
register const struct artifact *a;
const char *aname, *odesc, *other;
if (!strncmpi(aname, "the ", 4))
aname += 4;
if (!strcmp(aname, name))
- return ((boolean)((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0
- || otmp->quan > 1L));
+ return (boolean) ((a->spfx & (SPFX_NOGEN | SPFX_RESTR)) != 0
+ || otmp->quan > 1L);
}
return FALSE;
STATIC_OVL boolean
attacks(adtyp, otmp)
-register int adtyp;
-register struct obj *otmp;
+int adtyp;
+struct obj *otmp;
{
register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0)
- return ((boolean)(weap->attk.adtyp == adtyp));
+ return (boolean) (weap->attk.adtyp == adtyp);
return FALSE;
}
boolean
defends(adtyp, otmp)
-register int adtyp;
-register struct obj *otmp;
+int adtyp;
+struct obj *otmp;
{
register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0)
- return ((boolean)(weap->defn.adtyp == adtyp));
+ return (boolean) (weap->defn.adtyp == adtyp);
return FALSE;
}
register const struct artifact *weap;
if ((weap = get_artifact(otmp)) != 0)
- return (boolean)(weap->cary.adtyp == adtyp);
+ return (boolean) (weap->cary.adtyp == adtyp);
return FALSE;
}
arti = get_artifact(otmp);
if (!arti)
return FALSE;
- return (arti->cspfx & SPFX_PROTECT) != 0
- || (being_worn && (arti->spfx & SPFX_PROTECT) != 0);
+ return (boolean) ((arti->cspfx & SPFX_PROTECT) != 0
+ || (being_worn && (arti->spfx & SPFX_PROTECT) != 0));
}
/*
{
long *mask = 0;
register const struct artifact *oart = get_artifact(otmp);
- uchar dtyp;
- long spfx;
+ register uchar dtyp;
+ register long spfx;
if (!oart)
return;
STATIC_VAR boolean touch_blasted; /* for retouch_object() */
/*
- * creature (usually player) tries to touch (pick up or wield) an artifact
- * obj.
+ * creature (usually hero) tries to touch (pick up or wield) an artifact obj.
* Returns 0 if the object refuses to be touched.
* This routine does not change any object chains.
* Ignores such things as gauntlets, assuming the artifact is not
&& (oart->alignment != mon_aligntyp(mon));
} else { /* an M3_WANTSxxx monster or a fake player */
/* 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;
}
/* weapons which attack specific categories of monsters are
return FALSE;
if (dtyp == AD_PHYS)
return FALSE; /* nothing is immune to phys dmg */
- return (weap->attk.adtyp == dtyp || weap->defn.adtyp == dtyp
- || weap->cary.adtyp == dtyp);
+ return (boolean) (weap->attk.adtyp == dtyp
+ || weap->defn.adtyp == dtyp
+ || weap->cary.adtyp == dtyp);
}
STATIC_OVL boolean
impossible("Weird weapon special attack.");
}
}
- return (0);
+ return 0;
}
/* return the M2 flags of monster that an artifact's special attacks apply
spec_m2(otmp)
struct obj *otmp;
{
- register const struct artifact *artifact = get_artifact(otmp);
+ const struct artifact *artifact = get_artifact(otmp);
+
if (artifact)
return artifact->mtype;
return 0L;
struct obj *otmp;
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
always return 0 for any artifact which has that attribute */
{
register const struct artifact *weap = get_artifact(otmp);
- if (!weap || (weap->attk.adtyp == AD_PHYS && /* check for `NO_ATTK' */
- weap->attk.damn == 0 && weap->attk.damd == 0))
+ if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */
+ && weap->attk.damn == 0 && weap->attk.damd == 0))
spec_dbon_applies = FALSE;
else if (otmp->oartifact == ART_GRIMTOOTH)
/* Grimtooth has SPFX settings to warn against elves but we want its
else if (vis)
pline("Somehow, %s misses wildly.", mon_nam(magr));
*dmgptr = 0;
- return ((boolean)(youattack || vis));
+ return (boolean) (youattack || vis);
}
if (noncorporeal(mdef->data) || amorphous(mdef->data)) {
pline("%s slices through %s %s.", wepdesc,
*dmgptr = 2 * mdef->mhp + FATAL_DAMAGE_MODIFIER;
} else {
int drain = monhp_per_lvl(mdef);
+
*dmgptr += drain;
mdef->mhpmax -= drain;
mdef->m_lev--;
if (Blind)
You_feel("an %s drain your %s!",
- otmp->oartifact == ART_STORMBRINGER ? "unholy blade"
- : "object",
+ (otmp->oartifact == ART_STORMBRINGER)
+ ? "unholy blade"
+ : "object",
life);
else if (otmp->oartifact == ART_STORMBRINGER)
pline_The("%s blade drains your %s!", hcolor(NH_BLACK), life);
static NEARDATA const char invoke_types[] = { ALL_CLASSES, 0 };
/* #invoke: an "ugly check" filters out most objects */
+/* the #invoke command */
int
doinvoke()
{
} else {
long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI),
iprop = u.uprops[oart->inv_prop].intrinsic;
- boolean on =
- (eprop & W_ARTI) != 0; /* true if invoked prop just set */
+ boolean on = (eprop & W_ARTI) != 0; /* true if prop just set */
if (on && obj->age > monstermoves) {
/* the artifact is tired :-) */
artifact_light(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 */
{
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 */
struct obj *otmp;
{
if (!otmp->oartifact)
- return ((long) objects[otmp->otyp].oc_cost);
+ return (long) objects[otmp->otyp].oc_cost;
else if (artilist[(int) otmp->oartifact].cost)
- return (artilist[(int) otmp->oartifact].cost);
+ return artilist[(int) otmp->oartifact].cost;
else
return (100L * (long) objects[otmp->otyp].oc_cost);
}
/*
* Return the first item that is conveying a particular intrinsic.
*/
-
struct obj *
what_gives(abil)
long *abil;
uchar dtyp;
unsigned long spfx;
long wornbits;
- long wornmask =
- (W_ARM | W_ARMC | W_ARMH | W_ARMS | W_ARMG | W_ARMF | W_ARMU
- | W_AMUL | W_RINGL | W_RINGR | W_TOOL | W_ART | W_ARTI);
- /* [do W_ART and W_ARTI actually belong here?] */
+ long wornmask = (W_ARM | W_ARMC | W_ARMH | W_ARMS
+ | W_ARMG | W_ARMF | W_ARMU
+ | W_AMUL | W_RINGL | W_RINGR | W_TOOL
+ /* [do W_ART and W_ARTI actually belong here?] */
+ | W_ART | W_ARTI);
if (u.twoweap)
wornmask |= W_SWAPWEP;
for (obj = invent; obj; obj = obj->nobj) {
if (obj->oartifact
- && ((abil != &EWarn_of_mon) || context.warntype.obj)) {
+ && (abil != &EWarn_of_mon || context.warntype.obj)) {
const struct artifact *art = get_artifact(obj);
if (art) {
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
if (ledger_no(&save_dlevel))
assign_level(lev, &save_dlevel);
- return (boolean)(
- ((sptr = Is_special(lev)) != 0 && !sptr->boneid)
- || !dungeons[lev->dnum].boneid
- /* no bones on the last or multiway branch levels */
- /* in any dungeon (level 1 isn't multiway). */
- || Is_botlevel(lev) || (Is_branchlev(lev) && lev->dlevel > 1)
- /* no bones in the invocation level */
- || (In_hell(lev) && lev->dlevel == dunlevs_in_dungeon(lev) - 1));
+ return (boolean) (((sptr = Is_special(lev)) != 0 && !sptr->boneid)
+ || !dungeons[lev->dnum].boneid
+ /* no bones on the last or multiway branch levels
+ in any dungeon (level 1 isn't multiway) */
+ || Is_botlevel(lev)
+ || (Is_branchlev(lev) && lev->dlevel > 1)
+ /* no bones in the invocation level */
+ || (In_hell(lev)
+ && lev->dlevel == dunlevs_in_dungeon(lev) - 1));
}
/* Call this function for each fruit object saved in the bones level: it marks
return FALSE;
}
- if (depth(&u.uz) <= 0 || /* bulletproofing for endgame */
- (!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */
- && !wizard))
+ if (depth(&u.uz) <= 0 /* bulletproofing for endgame */
+ || (!rn2(1 + (depth(&u.uz) >> 2)) /* fewer ghosts on low levels */
+ && !wizard))
return FALSE;
/* don't let multiple restarts generate multiple copies of objects
- * in bones files */
+ in bones files */
if (discover)
return FALSE;
return TRUE;
char c, *bonesid, oldbonesid[10];
if (discover) /* save bones files for real games */
- return (0);
+ return 0;
if (!flags.bones)
- return (0);
+ return 0;
/* wizard check added by GAN 02/05/87 */
if (rn2(3) /* only once in three times do we find bones */
&& !wizard)
- return (0);
+ return 0;
if (no_bones_level(&u.uz))
- return (0);
+ return 0;
fd = open_bonesfile(&u.uz, &bonesid);
if (fd < 0)
- return (0);
+ return 0;
if (validate(fd, bones) != 0) {
if (!wizard)
if (yn("Get bones?") == 'n') {
(void) nhclose(fd);
compress_bonesfile();
- return (0);
+ return 0;
}
}
mread(fd, (genericptr_t) &c, sizeof c); /* length incl. '\0' */
if (wizard) {
if (yn("Unlink bones?") == 'n') {
compress_bonesfile();
- return (ok);
+ return ok;
}
}
if (!delete_bonesfile(&u.uz)) {
* -- just generate a new level for those N-1 games.
*/
/* pline("Cannot unlink bones."); */
- return (0);
+ return 0;
}
- return (ok);
+ return ok;
}
/*bones.c*/
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
* 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.
*
- * Currently: Take off all armor.
- * Picking Locks / Forcing Chests.
- * Setting traps.
+ * Currently: Take off all armor.
+ * Picking Locks / Forcing Chests.
+ * Setting traps.
*/
void
reset_occupations()
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.
*/
void
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;
char buf[BUFSZ];
#ifdef TTY_GRAPHICS
#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'.
- * ``# ?'' is counted towards the limit of the number of commands,
- * so we actually support MAX_EXT_CMD-1 "real" extended commands.
- */
+
+/*
+ * This is currently used only by the tty port and is
+ * controlled via runtime option 'extmenu'.
+ * ``# ?'' is counted towards the limit of the number of commands,
+ * so we actually support MAX_EXT_CMD-1 "real" extended commands.
+ */
int
extcmd_via_menu() /* here after # - now show pick-list of possible commands */
{
return 0;
}
-/* #monpolycontrol command - choose new form for shapechangers, polymorphees
- */
+/* #monpolycontrol command - choose new form for shapechangers, polymorphees */
STATIC_PTR int
wiz_mon_polycontrol(VOID_ARGS)
{
for (x = 1; x < COLNO; x++) {
terrain = levl[x][y].typ;
/* assumes there aren't more than 10+26+26 terrain types */
- row[x - 1] =
- (char) ((terrain == 0 && !may_dig(x, y))
- ? '*'
- : (terrain < 10)
- ? '0' + terrain
- : (terrain < 36) ? 'a' + terrain - 10
- : 'A' + terrain - 36);
+ row[x - 1] = (char) ((terrain == 0 && !may_dig(x, y))
+ ? '*'
+ : (terrain < 10)
+ ? '0' + terrain
+ : (terrain < 36)
+ ? 'a' + terrain - 10
+ : 'A' + terrain - 36);
}
if (levl[0][y].typ != 0 || may_dig(0, y))
row[x++] = '!';
{
if (u.uinwater || Levitation || Flying)
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
char buf[BUFSZ], tmpbuf[BUFSZ];
/* 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;
role_titl = (innategend && urole.name.f) ? urole.name.f : urole.name.m;
rank_titl = rank_of(u.ulevel, Role_switch, innategend);
for tricky phrasing otherwise necessitated by possibility of having
helm of opposite alignment mask a permanent alignment conversion */
difgend = (innategend != flags.initgend);
- difalgn =
- ((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0)
- + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL]) ? 2 : 0);
+ difalgn = (((u.ualign.type != u.ualignbase[A_CURRENT]) ? 1 : 0)
+ + ((u.ualignbase[A_CURRENT] != u.ualignbase[A_ORIGINAL])
+ ? 2 : 0));
if (difalgn & 1) { /* have temporary alignment so report permanent one */
Sprintf(buf, "actually %s", align_str(u.ualignbase[A_CURRENT]));
you_are(buf, "");
be set; we want to ignore steed in that situation */
&& !(final == ENL_GAMEOVERDEAD
&& !strcmp(killer.name, "riding accident")));
- const char *steedname =
- !Riding
- ? (char *) 0
- : x_monnam(u.usteed, u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE,
- (char *) 0, (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
- FALSE);
+ const char *steedname = (!Riding ? (char *) 0
+ : x_monnam(u.usteed,
+ u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE,
+ (char *) 0,
+ (SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION),
+ FALSE));
/*\
* 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, final ? "Final Status:" : "Current Status:");
/* report being weaponless; distinguish whether gloves are worn */
if (!uwep) {
you_are(uarmg ? "empty handed" /* gloves imply hands */
- /* no weapon and no gloves */
- : humanoid(youmonst.data)
- ? "bare handed"
- /* alternate phrasing for paws or lack of hands */
- : "not wielding anything",
+ : humanoid(youmonst.data)
+ /* hands but no weapon and no gloves */
+ ? "bare handed"
+ /* alternate phrasing for paws or lack of hands */
+ : "not wielding anything",
"");
/* two-weaponing implies a weapon (not other odd stuff) in each hand */
} else if (u.twoweap) {
char buf[BUFSZ];
/*\
- * Attributes
+ * Attributes
\*/
putstr(en_win, 0, "");
putstr(en_win, 0, final ? "Final Attributes:" : "Current Attributes:");
if (wizard)
Sprintf(eos(buf), " (%d)", u.ugangr);
enl_msg(u_gname(), " is", " was", buf, "");
- } else
+ } else {
/*
* We need to suppress this when the game is over, because death
* can change the value calculated by can_pray(), potentially
*/
if (!final) {
#if 0
- /* "can [not] safely pray" vs "could [not] have safely prayed" */
- Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
- final ? "have " : "", final ? "ed" : "");
+ /* "can [not] safely pray" vs "could [not] have safely prayed" */
+ Sprintf(buf, "%s%ssafely pray%s", can_pray(FALSE) ? "" : "not ",
+ final ? "have " : "", final ? "ed" : "");
#else
- Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
+ Sprintf(buf, "%ssafely pray", can_pray(FALSE) ? "" : "not ");
#endif
- if (wizard)
- Sprintf(eos(buf), " (%d)", u.ublesscnt);
- you_can(buf, "");
+ if (wizard)
+ Sprintf(eos(buf), " (%d)", u.ublesscnt);
+ you_can(buf, "");
+ }
}
+
+ /* named fruit debugging (doesn't really belong here...) */
if (wizard) {
int fcount = 0;
struct fruit *f;
char buf2[BUFSZ];
+
for (f = ffruit; f; f = f->nextf) {
Sprintf(buf, "Fruit %d ", ++fcount);
Sprintf(buf2, "%s (id %d)", f->fname, f->fid);
if (!u.uconduct.gnostic)
you_have_been("an atheist");
- if (!u.uconduct.weaphit)
+ if (!u.uconduct.weaphit) {
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,
plur(u.uconduct.weaphit));
you_have_X(buf);
if (!u.uconduct.killer)
you_have_been("a pacifist");
- if (!u.uconduct.literate)
+ if (!u.uconduct.literate) {
you_have_been("illiterate");
- else if (wizard) {
+ } else if (wizard) {
Sprintf(buf, "read items or engraved %ld time%s", u.uconduct.literate,
plur(u.uconduct.literate));
you_have_X(buf);
you_have_X(buf);
}
- if (!u.uconduct.polypiles)
+ if (!u.uconduct.polypiles) {
you_have_never("polymorphed an object");
- else if (wizard) {
+ } else if (wizard) {
Sprintf(buf, "polymorphed %ld item%s", u.uconduct.polypiles,
plur(u.uconduct.polypiles));
you_have_X(buf);
}
- if (!u.uconduct.polyselfs)
+ if (!u.uconduct.polyselfs) {
you_have_never("changed form");
- else if (wizard) {
+ } else if (wizard) {
Sprintf(buf, "changed form %ld time%s", u.uconduct.polyselfs,
plur(u.uconduct.polyselfs));
you_have_X(buf);
}
- if (!u.uconduct.wishes)
+ if (!u.uconduct.wishes) {
you_have_X("used no wishes");
- else {
+ } else {
Sprintf(buf, "used %ld wish%s", u.uconduct.wishes,
(u.uconduct.wishes > 1L) ? "es" : "");
you_have_X(buf);
{ C('i'), TRUE, wiz_identify },
{ C('l'), TRUE, doredraw }, /* if number_pad is set */
{ C('n'), TRUE, donamelevel }, /* if number_pad is set */
- { C('o'), TRUE,
- dooverview_or_wiz_where }, /* depending on wizard status */
+ { C('o'), TRUE, dooverview_or_wiz_where }, /* depends on wizard status */
{ C('p'), TRUE, doprev_message },
{ C('r'), TRUE, doredraw },
{ C('t'), TRUE, dotele },
{ 'A', FALSE, doddoremarm },
{ M('a'), TRUE, doorganize },
{ M('A'), TRUE, donamelevel }, /* #annotate */
- /* 'b', 'B' : go sw */
+ /* 'b', 'B' : go sw */
{ 'c', FALSE, doclose },
{ 'C', TRUE, docallcmd },
{ M('c'), TRUE, dotalk },
{ 'E', FALSE, doengrave },
{ M('e'), TRUE, enhance_weapon_skill },
{ 'f', FALSE, dofire },
- /* 'F' : fight (one time) */
+ /* 'F' : fight (one time) */
{ M('f'), FALSE, doforce },
- /* 'g', 'G' : multiple go */
- /* 'h', 'H' : go west */
+ /* 'g', 'G' : multiple go */
+ /* 'h', 'H' : go west */
{ 'h', TRUE, dohelp }, /* if number_pad is set */
{ 'i', TRUE, ddoinv },
{ 'I', TRUE, dotypeinv }, /* Robert Viduya */
{ 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 */
{ M('j'), FALSE, dojump },
{ 'k', FALSE, dokick }, /* if number_pad is on */
{ 'l', FALSE, doloot }, /* if number_pad is on */
{ 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 },
{ 'N', TRUE, docallcmd }, /* if number_pad is on */
{ M('n'), TRUE, docallcmd },
{ 'T', FALSE, dotakeoff },
{ M('t'), TRUE, doturn },
{ M('T'), FALSE, dotip }, /* #tip */
- /* 'u', 'U' : go ne */
+ /* 'u', 'U' : go ne */
{ 'u', FALSE, dountrap }, /* if number_pad is on */
{ M('u'), FALSE, dountrap },
{ 'v', TRUE, doversion },
{ M('w'), FALSE, dowipe },
{ 'x', FALSE, doswapweapon },
{ 'X', FALSE, dotwoweapon },
- /* 'y', 'Y' : go nw */
+ /* 'y', 'Y' : go nw */
{ 'z', FALSE, dozap },
{ 'Z', TRUE, docast },
{ '<', FALSE, doup },
reset_commands(initial)
boolean initial;
{
- static const char sdir[] = "hykulnjb><", sdir_swap_yz[] = "hzkulnjb><",
+ static const char sdir[] = "hykulnjb><",
+ sdir_swap_yz[] = "hzkulnjb><",
ndir[] = "47896321><",
ndir_phone_layout[] = "41236987><";
static const int ylist[] = {
int res, NDECL((*func));
#if 0
- for (tlist = cmdlist; tlist->f_char; tlist++) {
- if ((*cmd & 0xff) != (tlist->f_char & 0xff)) continue;
+ /* obsolete - scan through the cmdlist array looking for *cmd */
+ for (tlist = cmdlist; tlist->f_char; tlist++) {
+ if ((*cmd & 0xff) != (tlist->f_char & 0xff))
+ continue;
#else
+ /* current - use *cmd to directly index cmdlist array */
if ((tlist = Cmd.commands[*cmd & 0xff]) != 0) {
#endif
-
- if (u.uburied && !tlist->can_if_buried) {
- You_cant("do that while you are buried!");
- res = 0;
- } else {
- /* we discard 'const' because some compilers seem to have
- trouble with the pointer passed to set_occupation() */
- func = ((struct func_tab *) tlist)->f_funct;
- if (tlist->f_text && !occupation && multi)
- set_occupation(func, tlist->f_text, multi);
- res = (*func)(); /* perform the command */
- }
- if (!res) {
- context.move = FALSE;
- multi = 0;
+ if (u.uburied && !tlist->can_if_buried) {
+ You_cant("do that while you are buried!");
+ res = 0;
+ } else {
+ /* we discard 'const' because some compilers seem to have
+ trouble with the pointer passed to set_occupation() */
+ func = ((struct func_tab *) tlist)->f_funct;
+ if (tlist->f_text && !occupation && multi)
+ set_occupation(func, tlist->f_text, multi);
+ res = (*func)(); /* perform the command */
+ }
+ if (!res) {
+ context.move = FALSE;
+ multi = 0;
+ }
+ return;
}
- return;
+ /* if we reach here, cmd wasn't found in cmdlist[] */
+ bad_command = TRUE;
}
- /* if we reach here, cmd wasn't found in cmdlist[] */
- bad_command = TRUE;
-}
-if (bad_command) {
- char expcmd[10];
- register char c, *cp = expcmd;
-
- while ((c = *cmd++) != '\0'
- && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) {
- if (c >= 040 && c < 0177) {
- *cp++ = c;
- } else if (c & 0200) {
- *cp++ = 'M';
- *cp++ = '-';
- *cp++ = c & ~0200;
- } else {
- *cp++ = '^';
- *cp++ = c ^ 0100;
+ if (bad_command) {
+ char expcmd[10];
+ register char c, *cp = expcmd;
+
+ while ((c = *cmd++) != '\0'
+ && (int) (cp - expcmd) < (int) (sizeof expcmd - 3)) {
+ if (c >= 040 && c < 0177) {
+ *cp++ = c;
+ } else if (c & 0200) {
+ *cp++ = 'M';
+ *cp++ = '-';
+ *cp++ = c & ~0200;
+ } else {
+ *cp++ = '^';
+ *cp++ = c ^ 0100;
+ }
}
+ *cp = '\0';
+ if (!prefix_seen || !iflags.cmdassist
+ || !help_dir(0, "Invalid direction key!"))
+ Norep("Unknown command '%s'.", expcmd);
}
- *cp = '\0';
- if (!prefix_seen || !iflags.cmdassist
- || !help_dir(0, "Invalid direction key!"))
- Norep("Unknown command '%s'.", expcmd);
-}
-/* didn't move */
-context.move = FALSE;
-multi = 0;
-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;
{
register int dd;
for (dd = 0; dd < 8; dd++)
if (x == xdir[dd] && y == ydir[dd])
return dd;
-
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;
register int dd;
{
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;
{
register const char *dp = index(Cmd.dirchars, sym);
u.dy = ydir[dp - Cmd.dirchars];
u.dz = zdir[dp - Cmd.dirchars];
#if 0 /* now handled elsewhere */
- if (u.dx && u.dy && NODIAG(u.umonnum)) {
- u.dx = u.dy = 0;
- return 0;
- }
+ if (u.dx && u.dy && NODIAG(u.umonnum)) {
+ u.dx = u.dy = 0;
+ return 0;
+ }
#endif
return !u.dz;
}
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
redraw_cmd(c)
char c;
{
- return (c == C('r') || (Cmd.num_pad && c == C('l')));
+ return (boolean) (c == C('r') || (Cmd.num_pad && c == C('l')));
}
/*
if (mod == CLICK_1) {
cmd[0] = Cmd.dirchars[dir];
} else {
- cmd[0] =
- (Cmd.num_pad ? M(Cmd.dirchars[dir])
- : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
+ cmd[0] = (Cmd.num_pad
+ ? M(Cmd.dirchars[dir])
+ : (Cmd.dirchars[dir] - 'a' + 'A')); /* run command */
}
return cmd;
clear_nhwindow(WIN_MESSAGE);
if (prezero)
in_line[0] = '\033';
- return (in_line);
+ return in_line;
}
#ifdef HANGUPHANDLING
readchar_queue = click_to_cmd(x, y, mod);
sym = *readchar_queue++;
}
- return ((char) sym);
+ return (char) sym;
}
STATIC_PTR int
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
return (struct obj *) 0;
}
-/* Recursively search obj for an object made of specified material and return
- * 1st found */
+/* Recursively search obj for an object made of specified material.
+ * Return first found.
+ */
struct obj *
o_material(obj, material)
struct obj *obj;
STATIC_OVL boolean
check_map_spot(x, y, oclass, material)
int x, y;
-register char oclass;
+char oclass;
unsigned material;
{
- register int glyph;
+ int glyph;
register struct obj *otmp;
register struct monst *mtmp;
if (glyph_is_object(glyph)) {
/* there's some object shown here */
if (oclass == ALL_CLASSES) {
- return (
- (boolean)(!(level.objects[x][y] || /* stale if nothing here */
- ((mtmp = m_at(x, y)) != 0 && (mtmp->minvent)))));
+ return (boolean) !(level.objects[x][y] /* stale if nothing here */
+ || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent));
} else {
if (material
&& objects[glyph_to_obj(glyph)].oc_material == material) {
- /* the object shown here is of interest because material
- * matches */
+ /* object shown here is of interest because material matches */
for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
if (o_material(otmp, GOLD))
return FALSE;
return TRUE;
}
if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) {
- /* the object shown here is of interest because its class
- * matches */
+ /* obj shown here is of interest because its class matches */
for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
if (o_in(otmp, oclass))
return FALSE;
}
/*
- When doing detection, remove stale data from the map display (corpses
- rotted away, objects carried away by monsters, etc) so that it won't
- reappear after the detection has completed. Return true if noticeable
- change occurs.
+ * When doing detection, remove stale data from the map display (corpses
+ * rotted away, objects carried away by monsters, etc) so that it won't
+ * reappear after the detection has completed. Return true if noticeable
+ * change occurs.
*/
STATIC_OVL boolean
clear_stale_map(oclass, material)
-register char oclass;
+char oclass;
unsigned material;
{
register int zx, zy;
- register boolean change_made = FALSE;
+ boolean change_made = FALSE;
for (zx = 1; zx < COLNO; zx++)
for (zy = 0; zy < ROWNO; zy++)
Strcpy(buf, "You feel materially poor.");
strange_feeling(sobj, buf);
}
- return (1);
+ return 1;
}
/* only under me - no separate display required */
if (stale)
docrt();
You("notice some gold between your %s.", makeplural(body_part(FOOT)));
- return (0);
+ return 0;
outgoldmap:
cls();
under_water(2);
if (u.uburied)
under_ground(2);
- return (0);
+ return 0;
}
-/* returns 1 if nothing was detected */
-/* returns 0 if something was detected */
+/* returns 1 if nothing was detected */
+/* returns 0 if something was detected */
int
food_detect(sobj)
register struct obj *sobj;
? " then starts to tingle"
: "");
if (sobj->blessed && !u.uedibility) {
- boolean savebeginner =
- flags.beginner; /* prevent non-delivery of */
- flags.beginner = FALSE; /* message */
+ boolean savebeginner = flags.beginner;
+
+ flags.beginner = FALSE; /* prevent non-delivery of message */
strange_feeling(sobj, buf);
flags.beginner = savebeginner;
u.uedibility = 1;
if (u.uburied)
under_ground(2);
}
- return (0);
+ return 0;
}
/*
* Used for scrolls, potions, spells, and crystal balls. Returns:
*
- * 1 - nothing was detected
- * 0 - something was detected
+ * 1 - nothing was detected
+ * 0 - something was detected
*/
int
object_detect(detector, class)
iflags.save_uinwater = u.uinwater, iflags.save_uburied = u.uburied;
u.uinwater = u.uburied = 0;
/*
- * Map all buried objects first.
+ * Map all buried objects first.
*/
for (obj = level.buriedobjlist; obj; obj = obj->nobj)
if (!class || (otmp = o_in(obj, class))) {
return result;
}
-/* the detections are pulled out so they can */
-/* also be used in the crystal ball routine */
-/* returns 1 if nothing was detected */
-/* returns 0 if something was detected */
+/* the detections are pulled out so they can
+ * also be used in the crystal ball routine
+ * returns 1 if nothing was detected
+ * returns 0 if something was detected
+ */
int
trap_detect(sobj)
register struct obj *sobj;
Sprintf(buf, "Your %s stop itching.", makeplural(body_part(TOE)));
strange_feeling(sobj, buf);
- return (1);
+ return 1;
}
/* traps exist, but only under me - no separate display required */
Your("%s itch.", makeplural(body_part(TOE)));
- return (0);
+ return 0;
outtrapmap:
cls();
under_water(2);
if (u.uburied)
under_ground(2);
- return (0);
+ return 0;
}
const char *
int num = 0;
if (u.uswallow)
- return (0);
+ return 0;
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;
pline("%s opens its mouth!", Monnam(u.ustuck));
}
expels(u.ustuck, u.ustuck->data, TRUE);
- return (-1);
+ return -1;
}
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() */
if (!aflag)
pline("What are you looking for? The exit?");
} else {
- int fund =
- (uwep && uwep->oartifact && spec_ability(uwep, SPFX_SEARCH))
- ? uwep->spe
- : 0;
+ int fund = (uwep && uwep->oartifact
+ && spec_ability(uwep, SPFX_SEARCH)) ? uwep->spe : 0;
+
if (ublindf && ublindf->otyp == LENSES && !Blind)
fund += 2; /* JDS: lenses help searching */
if (fund > 5)
for (y = u.uy - 1; y < u.uy + 2; y++) {
if (!isok(x, y))
continue;
- if (x != u.ux || y != u.uy) {
- if (Blind && !aflag)
- feel_location(x, y);
- if (levl[x][y].typ == SDOOR) {
- if (rnl(7 - fund))
- continue;
- cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */
- exercise(A_WIS, TRUE);
- nomul(0);
- feel_location(x, y); /* make sure it shows up */
- You("find a hidden door.");
- } else if (levl[x][y].typ == SCORR) {
- if (rnl(7 - fund))
- continue;
- levl[x][y].typ = CORR;
- unblock_point(x, y); /* vision */
- exercise(A_WIS, TRUE);
- nomul(0);
- feel_location(x, y); /* make sure it shows up */
- You("find a hidden passage.");
- } else {
- /* Be careful not to find anything in an SCORR or
- * SDOOR */
- if ((mtmp = m_at(x, y)) && !aflag) {
- if (mtmp->m_ap_type) {
- seemimic(mtmp);
- find:
- exercise(A_WIS, TRUE);
- if (!canspotmon(mtmp)) {
- 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 (x == u.ux && y == u.uy)
+ continue;
+
+ if (Blind && !aflag)
+ feel_location(x, y);
+ if (levl[x][y].typ == SDOOR) {
+ if (rnl(7 - fund))
+ continue;
+ cvt_sdoor_to_door(&levl[x][y]); /* .typ = DOOR */
+ exercise(A_WIS, TRUE);
+ nomul(0);
+ feel_location(x, y); /* make sure it shows up */
+ You("find a hidden door.");
+ } else if (levl[x][y].typ == SCORR) {
+ if (rnl(7 - fund))
+ continue;
+ levl[x][y].typ = CORR;
+ unblock_point(x, y); /* vision */
+ exercise(A_WIS, TRUE);
+ nomul(0);
+ feel_location(x, y); /* make sure it shows up */
+ You("find a hidden passage.");
+ } else {
+ /* Be careful not to find anything in an SCORR or SDOOR */
+ if ((mtmp = m_at(x, y)) != 0 && !aflag) {
+ if (mtmp->m_ap_type) {
+ seemimic(mtmp);
+ find:
+ exercise(A_WIS, TRUE);
if (!canspotmon(mtmp)) {
- if (mtmp->mundetected
- && (is_hider(mtmp->data)
- || mtmp->data->mlet == S_EEL))
- mtmp->mundetected = 0;
- newsym(x, y);
- goto find;
- }
+ 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;
}
-
- /* see if an invisible monster has moved--if Blind,
- * feel_location() already did it
- */
- if (!aflag && !mtmp && !Blind
- && glyph_is_invisible(levl[x][y].glyph)) {
- unmap_object(x, y);
+ if (!canspotmon(mtmp)) {
+ if (mtmp->mundetected
+ && (is_hider(mtmp->data)
+ || mtmp->data->mlet == S_EEL))
+ mtmp->mundetected = 0;
newsym(x, y);
+ goto find;
}
+ }
- if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) {
- nomul(0);
+ /* see if an invisible monster has moved--if Blind,
+ * 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 (activate_statue_trap(trap, x, y, FALSE))
- exercise(A_WIS, TRUE);
- return (1);
- } else {
- find_trap(trap);
- }
+ if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) {
+ nomul(0);
+ if (trap->ttyp == STATUE_TRAP) {
+ if (activate_statue_trap(trap, x, y, FALSE))
+ exercise(A_WIS, TRUE);
+ return 1;
+ } else {
+ find_trap(trap);
}
}
}
}
}
- return (1);
+ return 1;
}
/* the 's' command -- explicit searching */
int
dosearch()
{
- return (dosearch0(0));
+ return dosearch0(0);
}
/* Pre-map the sokoban levels */
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
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) {
levl[x][y].seenv = SVALL;
glyph = back_to_glyph(x, y);
levl[x][y].seenv = seenv;
} else {
- levl_glyph = level.flags.hero_memory ? levl[x][y].glyph
- : seenv ? back_to_glyph(x, y) : default_glyph;
+ levl_glyph = level.flags.hero_memory
+ ? levl[x][y].glyph
+ : seenv
+ ? back_to_glyph(x, y)
+ : default_glyph;
/* glyph_at() returns the displayed glyph, which might
be a monster. levl[][].glyph contains the remembered
glyph, which will never be a monster (unless it is
}
show_glyph(x, y, glyph);
}
+
/* [TODO: highlight hero's location somehow] */
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);
if (full) {
Strcpy(buf, "underlying terrain");
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
if (!ispick && !is_axe(otmp))
return DIGTYP_UNDIGGABLE;
- return (ispick && sobj_at(STATUE, x, y)
- ? DIGTYP_STATUE
- : ispick && sobj_at(BOULDER, x, y)
- ? DIGTYP_BOULDER
- : closed_door(x, y)
- ? DIGTYP_DOOR
- : IS_TREE(levl[x][y].typ)
- ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE)
- : ispick && IS_ROCK(levl[x][y].typ)
- && (!level.flags.arboreal
- || IS_WALL(levl[x][y].typ))
- ? DIGTYP_ROCK
- : DIGTYP_UNDIGGABLE);
+ return ((ispick && sobj_at(STATUE, x, y))
+ ? DIGTYP_STATUE
+ : (ispick && sobj_at(BOULDER, x, y))
+ ? DIGTYP_BOULDER
+ : closed_door(x, y)
+ ? DIGTYP_DOOR
+ : IS_TREE(levl[x][y].typ)
+ ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE)
+ : (ispick && IS_ROCK(levl[x][y].typ)
+ && (!level.flags.arboreal
+ || IS_WALL(levl[x][y].typ)))
+ ? DIGTYP_ROCK
+ : DIGTYP_UNDIGGABLE);
}
boolean
/* MRKR: use_pick_axe() is split in two to allow autodig to bypass */
/* the "In what direction do you want to dig?" query. */
/* use_pick_axe2() uses the existing u.dx, u.dy and u.dz */
-
int
use_pick_axe2(obj)
struct obj *obj;
return FALSE;
if (!isok(cc->x, cc->y))
return FALSE;
- if (msg)
- *msg = '\0';
+ *msg = '\0';
room = &levl[cc->x][cc->y];
ltyp = room->typ;
/* "set of iron bars" */
Strcpy(msg, "The bars go much deeper than your pit.");
#if 0
- } else if (is_lava(cc->x,cc->y)) {
- } else if (is_ice(cc->x,cc->y)) {
- } else if (is_pool(cc->x,cc->y)) {
+ } else if (is_lava(cc->x, cc->y)) {
+ } else if (is_ice(cc->x, cc->y)) {
+ } else if (is_pool(cc->x, cc->y)) {
} else if (IS_GRAVE(ltyp)) {
#endif
} else if (IS_SINK(ltyp)) {
Strcpy(msg, "A tangled mass of plumbing remains below the sink.");
return FALSE;
- } else if ((cc->x == xupladder && cc->y == yupladder) || /* "ladder up" */
- (cc->x == xdnladder
- && cc->y == ydnladder)) { /* "ladder down" */
+ } else if ((cc->x == xupladder && cc->y == yupladder) /* ladder up */
+ || (cc->x == xdnladder && cc->y == ydnladder)) { /* " down */
Strcpy(msg, "The ladder is unaffected.");
return FALSE;
} else {
const char *supporting = (const char *) 0;
+
if (IS_FOUNTAIN(ltyp))
supporting = "fountain";
else if (IS_THRONE(ltyp))
&& !sstairs.up))
/* "staircase down" */
supporting = "stairs";
- else if ((ltyp == DRAWBRIDGE_DOWN) || /* "lowered drawbridge" */
- (ltyp == DBWALL)) /* "raised drawbridge" */
+ else if (ltyp == DRAWBRIDGE_DOWN /* "lowered drawbridge" */
+ || ltyp == DBWALL) /* "raised drawbridge" */
supporting = "drawbridge";
+
if (supporting) {
Sprintf(msg, "The %s%ssupporting structures remain intact.",
supporting ? s_suffix(supporting) : "",
{
xchar check_x, check_y;
struct obj *otmp, *otmp2;
+
if (u.utraptype == TT_BURIEDBALL)
for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
otmp2 = otmp->nobj;
}
}
-/* move objects from fobj/nexthere lists to buriedobjlist, keeping position */
-/* information */
+/* move objects from fobj/nexthere lists to buriedobjlist, keeping position
+ information */
struct obj *
bury_an_obj(otmp, dealloced)
struct obj *otmp;
for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
otmp2 = otmp->nobj;
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();
- else {
+ } else {
obj_extract_self(otmp);
if (otmp->timed)
(void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));