-/* NetHack 3.6 dig.c $NHDT-Date: 1445301118 2015/10/20 00:31:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.97 $ */
+/* NetHack 3.6 dig.c $NHDT-Date: 1446191874 2015/10/30 07:57:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.98 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
register xchar x, y;
if (levl[u.ux][u.uy].typ == ROOM && levl[u.ux][u.uy].waslit)
- return (TRUE);
+ return TRUE;
for (x = u.ux - 2; x < u.ux + 3; x++)
for (y = u.uy - 1; y < u.uy + 2; y++)
if (isok(x, y) && levl[x][y].waslit)
- return (TRUE);
- return (FALSE);
+ return TRUE;
+ return FALSE;
}
/* Change level topology. Messes with vision tables and ignores things like
if (waslit)
lev->waslit = (rockit ? FALSE : TRUE);
lev->horizontal = FALSE;
- viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE)
- : /* short-circuit vision recalc */
- COULD_SEE;
+ /* short-circuit vision recalc */
+ viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
lev->typ = (rockit ? STONE : ROOM);
if (dist >= 3)
impossible("mkcavepos called with dist %d", dist);
pline_The("ladder resists your effort.");
} else if (verbose)
pline_The("stairs are too hard to %s.", verb);
- return (FALSE);
+ return FALSE;
} else if (IS_THRONE(levl[x][y].typ) && madeby != BY_OBJECT) {
if (verbose)
pline_The("throne is too hard to break apart.");
- return (FALSE);
+ return FALSE;
} else if (IS_ALTAR(levl[x][y].typ)
&& (madeby != BY_OBJECT || Is_astralevel(&u.uz)
|| Is_sanctum(&u.uz))) {
if (verbose)
pline_The("altar is too hard to break apart.");
- return (FALSE);
+ return FALSE;
} else if (Is_airlevel(&u.uz)) {
if (verbose)
You("cannot %s thin air.", verb);
- return (FALSE);
+ return FALSE;
} else if (Is_waterlevel(&u.uz)) {
if (verbose)
pline_The("water splashes and subsides.");
- return (FALSE);
+ return FALSE;
} else if ((IS_ROCK(levl[x][y].typ) && levl[x][y].typ != SDOOR
&& (levl[x][y].wall_info & W_NONDIGGABLE) != 0)
|| (ttmp
|| (!Can_dig_down(&u.uz) && !levl[x][y].candig)))) {
if (verbose)
pline_The("%s here is too hard to %s.", surface(x, y), verb);
- return (FALSE);
+ return FALSE;
} else if (sobj_at(BOULDER, x, y)) {
if (verbose)
There("isn't enough room to %s here.", verb);
- return (FALSE);
+ return FALSE;
} else if (madeby == BY_OBJECT
/* the block against existing traps is mainly to
prevent broken wands from turning holes into pits */
/* digging by player handles pools separately */
return FALSE;
}
- return (TRUE);
+ return TRUE;
}
STATIC_OVL int
|| !on_level(&context.digging.level, &u.uz)
|| ((context.digging.down ? (dpx != u.ux || dpy != u.uy)
: (distu(dpx, dpy) > 2))))
- return (0);
+ return 0;
if (context.digging.down) {
if (!dig_check(BY_YOU, TRUE, u.ux, u.uy))
- return (0);
+ return 0;
} else { /* !context.digging.down */
if (IS_TREE(lev->typ) && !may_dig(dpx, dpy)
&& dig_typ(uwep, dpx, dpy) == DIGTYP_TREE) {
pline("This tree seems to be petrified.");
- return (0);
+ return 0;
}
if (IS_ROCK(lev->typ) && !may_dig(dpx, dpy)
&& dig_typ(uwep, dpx, dpy) == DIGTYP_ROCK) {
pline("This %s is too hard to %s.",
is_db_wall(dpx, dpy) ? "drawbridge" : "wall", verb);
- return (0);
+ return 0;
}
}
if (Fumbling && !rn2(3)) {
Your("swing misses its mark.");
break;
}
- return (0);
+ return 0;
}
context.digging.effort +=
(void) dighole(FALSE, FALSE, (coord *) 0);
(void) memset((genericptr_t) &context.digging, 0,
sizeof context.digging);
- return (0); /* done with digging */
+ return 0; /* done with digging */
}
if (context.digging.effort <= 50
|| (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT
|| ttmp->ttyp == SPIKED_PIT))) {
- return (1);
+ return 1;
} else if (ttmp && (ttmp->ttyp == LANDMINE
|| (ttmp->ttyp == BEAR_TRAP && !u.utrap))) {
/* digging onto a set object trap triggers it;
context.digging.level.dnum = 0;
context.digging.level.dlevel = -1;
}
- return (0);
+ return 0;
}
if (context.digging.effort > 100) {
if (!(lev->doormask & D_TRAPPED))
lev->doormask = D_BROKEN;
} else
- return (0); /* statue or boulder got taken */
+ return 0; /* statue or boulder got taken */
if (!does_block(dpx, dpy, &levl[dpx][dpy]))
unblock_point(dpx, dpy); /* vision: can see through */
context.digging.quiet = FALSE;
context.digging.level.dnum = 0;
context.digging.level.dlevel = -1;
- return (0);
+ return 0;
} else { /* not enough effort has been spent yet */
static const char *const d_target[6] = { "", "rock", "statue",
"boulder", "door", "tree" };
if (*in_rooms(dpx, dpy, SHOPBASE)) {
pline("This %s seems too hard to %s.",
IS_DOOR(lev->typ) ? "door" : "wall", verb);
- return (0);
+ return 0;
}
} else if (dig_target == DIGTYP_UNDIGGABLE
|| (dig_target == DIGTYP_ROCK && !IS_ROCK(lev->typ)))
- return (0); /* statue or boulder got taken */
+ return 0; /* statue or boulder got taken */
if (!did_dig_msg) {
You("hit the %s with all your might.", d_target[dig_target]);
did_dig_msg = TRUE;
}
}
- return (1);
+ return 1;
}
/* When will hole be finished? Very rough indication used by shopkeeper. */
holetime()
{
if (occupation != dig || !*u.ushops)
- return (-1);
+ return -1;
return ((250 - context.digging.effort) / 20);
}
*dsp = 0;
Sprintf(qbuf, "In what direction do you want to %s? [%s]", verb, dirsyms);
if (!getdir(qbuf))
- return (res);
+ return res;
- return (use_pick_axe2(obj));
+ return use_pick_axe2(obj);
}
/* MRKR: use_pick_axe() is split in two to allow autodig to bypass */
const char *verbing = ispick ? "digging" : "chopping";
if (u.uswallow && attack(u.ustuck)) {
- ; /* return(1) */
+ ; /* return 1 */
} else if (Underwater) {
pline("Turbulence torpedoes your %s attempts.", verbing);
} else if (u.dz < 0) {
Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp]));
losehp(Maybe_Half_Phys(dam), buf, KILLED_BY);
context.botl = 1;
- return (1);
+ return 1;
} else if (u.dz == 0) {
if (Stunned || (Confusion && !rn2(5)))
confdir();
ry = u.uy + u.dy;
if (!isok(rx, ry)) {
pline("Clash!");
- return (1);
+ return 1;
}
lev = &levl[rx][ry];
if (MON_AT(rx, ry) && attack(m_at(rx, ry)))
- return (1);
+ return 1;
dig_target = dig_typ(obj, rx, ry);
if (dig_target == DIGTYP_UNDIGGABLE) {
/* ACCESSIBLE or POOL */
did_dig_msg = FALSE;
set_occupation(dig, verbing, 0);
}
- return (1);
+ return 1;
}
/*
/* "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_GRAVE(ltyp)) {
+ } 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.");
struct trap *trap;
schar filltyp;
{
- int idx;
if (trap && (filltyp != ROOM)
&& (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
struct trap t;
+ int idx;
+
t = *trap;
levl[trap->tx][trap->ty].typ = filltyp;
liquid_flow(trap->tx, trap->ty, filltyp, trap,
if (t.conjoined & (1 << idx)) {
int x, y;
struct trap *t2;
+
x = t.tx + xdir[idx];
y = t.ty + ydir[idx];
t2 = t_at(x, y);
#if 0
- /* cannot do this back-check; liquid_flow()
- * called deltrap() which cleaned up the
- * conjoined fields on both pits.
- */
-
- if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8))))
+ /* cannot do this back-check; liquid_flow()
+ * called deltrap() which cleaned up the
+ * conjoined fields on both pits.
+ */
+ if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8))))
#endif
/* recursion */
pit_flow(t2, filltyp);
if (ball) {
obj_extract_self(ball);
#if 0
- /* rusting buried metallic objects is not implemented yet */
- if (ball->timed)
- (void) stop_timer(RUST_METAL, obj_to_any(ball));
+ /* rusting buried metallic objects is not implemented yet */
+ if (ball->timed)
+ (void) stop_timer(RUST_METAL, obj_to_any(ball));
#endif
punish(ball); /* use ball as flag for unearthed buried ball */
u.utrap = 0;
if (ball) {
obj_extract_self(ball);
#if 0
- /* rusting buried metallic objects is not implemented yet */
- if (ball->timed)
- (void) stop_timer(RUST_METAL, obj_to_any(ball));
+ /* rusting buried metallic objects is not implemented yet */
+ if (ball->timed)
+ (void) stop_timer(RUST_METAL, obj_to_any(ball));
#endif
place_object(ball, cc.x, cc.y);
stackobj(ball);
* completely different.
*/
if (otmp == uchain || obj_resists(otmp, 0, 0))
- return (otmp2);
+ return otmp2;
if (otmp->otyp == LEASH && otmp->leashmon != 0)
o_unleash(otmp);
if (dealloced)
*dealloced = TRUE;
obfree(otmp, (struct obj *) 0);
- return (otmp2);
+ return otmp2;
}
/*
* Start a rot on organic material. Not corpses -- they
&& !obj_resists(otmp, 5, 95)) {
(void) start_timer((under_ice ? 0L : 250L) + (long) rnd(250),
TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp));
- }
#if 0
- /* rusting of buried metal not yet implemented */
- else if (is_rustprone(otmp)) {
- (void) start_timer((long)rnd(otmp->otyp == HEAVY_IRON_BALL ? 1500 : 250),
- TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
- }
+ /* rusting of buried metal not yet implemented */
+ } else if (is_rustprone(otmp)) {
+ (void) start_timer((long) rnd((otmp->otyp == HEAVY_IRON_BALL)
+ ? 1500
+ : 250),
+ TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
#endif
+ }
add_to_buried(otmp);
- return (otmp2);
+ return otmp2;
}
void
if (level.objects[x][y] != (struct obj *) 0)
debugpline2("bury_objs: at <%d,%d>", x, y);
for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
- otmp2 = bury_an_obj(otmp, NULL);
+ otmp2 = bury_an_obj(otmp, (boolean *) 0);
/* don't expect any engravings here, but just in case */
del_engr_at(x, y);
/* Everything which can be held in a container can also be
buried, so bury_an_obj's use of obj_extract_self insures
that Has_contents(obj) will eventually become false. */
- (void) bury_an_obj(obj->cobj, NULL);
+ (void) bury_an_obj(obj->cobj, (boolean *) 0);
}
obj_extract_self(obj);
obfree(obj, (struct obj *) 0);
void
rot_corpse(arg, timeout)
anything *arg;
-long timeout; /* unused */
+long timeout;
{
xchar x = 0, y = 0;
struct obj *obj = arg->a_obj;
{
debugpline0("bury_you");
if (!Levitation && !Flying) {
- if (u.uswallow)
- You_feel("a sensation like falling into a trap!");
- else
- pline_The("%s opens beneath you and you fall in!",
+ if (u.uswallow)
+ You_feel("a sensation like falling into a trap!");
+ else
+ pline_The("%s opens beneath you and you fall in!",
surface(u.ux, u.uy));
- u.uburied = TRUE;
- if (!Strangled && !Breathless)
+ u.uburied = TRUE;
+ if (!Strangled && !Breathless)
Strangled = 6;
- under_ground(1);
+ under_ground(1);
}
}
-/* NetHack 3.6 dokick.c $NHDT-Date: 1445301122 2015/10/20 00:32:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.101 $ */
+/* NetHack 3.6 dokick.c $NHDT-Date: 1446191875 2015/10/30 07:57:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.102 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
mon = 0; /* don't kick after all */
context.forcefight = save_forcefight;
}
- return (boolean)(mon != 0);
+ return (boolean) (mon != 0);
}
STATIC_OVL void
if (Fumbling && !rn2(3)) {
Your("clumsy kick missed.");
- return (1);
+ return 1;
}
if (!uarmf && kickedobj->otyp == CORPSE
}
}
- /* range < 2 means the object will not move. */
- /* maybe dexterity should also figure here. */
+ /* range < 2 means the object will not move. */
+ /* maybe dexterity should also figure here. */
range = (int) ((ACURRSTR) / 2 - kickedobj->owt / 40);
if (martial())
breakchestlock(kickedobj, FALSE);
if (otrp)
(void) chest_trap(kickedobj, LEG, FALSE);
- return (1);
+ return 1;
}
} else {
if (!rn2(3) || (martial() && !rn2(2))) {
kickedobj->lknown = 1;
if (otrp)
(void) chest_trap(kickedobj, LEG, FALSE);
- return (1);
+ return 1;
}
}
if (range < 2)
- return (1);
+ return 1;
/* else let it fall through to the next cases... */
}
&& kickedobj->ocarry == mon)
return 1; /* alert shk caught it */
notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
- if (isgold ? ghitm(mon, kickedobj) : /* caught? */
- thitmonst(mon, kickedobj)) /* hit && used up? */
- return (1);
+ if (isgold ? ghitm(mon, kickedobj) /* caught? */
+ : thitmonst(mon, kickedobj)) /* hit && used up? */
+ return 1;
}
/* the object might have fallen down a hole;
place_object(kickedobj, bhitpos.x, bhitpos.y);
stackobj(kickedobj);
newsym(kickedobj->ox, kickedobj->oy);
- return (1);
+ return 1;
}
/* cause of death if kicking kills kicker */
}
if (!getdir((char *) 0))
- return (0);
+ return 0;
if (!u.dx && !u.dy)
- return (0);
+ return 0;
x = u.ux + u.dx;
y = u.uy + u.dy;
Your("feeble kick has no effect.");
break;
}
- return (1);
+ return 1;
} else if (u.utrap && u.utraptype == TT_PIT) {
/* must be Passes_walls */
You("kick at the side of the pit.");
&& !IS_DOOR(levl[xx][yy].typ)
&& (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) {
You("have nothing to brace yourself against.");
- return (0);
+ return 0;
}
}
range = 1;
hurtle(-u.dx, -u.dy, range, TRUE);
}
- return (1);
+ return 1;
}
if (glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
if (kick_object(x, y)) {
if (Is_airlevel(&u.uz))
hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
- return (1);
+ return 1;
}
goto ouch;
}
if (maploc->doormask == D_ISOPEN
|| maploc->doormask == D_NODOOR)
unblock_point(x, y); /* vision */
- return (1);
+ return 1;
} else
goto ouch;
}
else
newsym(x, y);
unblock_point(x, y); /* vision */
- return (1);
+ return 1;
} else
goto ouch;
}
newsym(x, y);
}
exercise(A_DEX, TRUE);
- return (1);
+ return 1;
} else if (Luck > 0 && !rn2(3) && !maploc->looted) {
(void) mkgold((long) rn1(201, 300), x, y);
i = Luck + 1;
}
/* prevent endless milking */
maploc->looted = T_LOOTED;
- return (1);
+ return 1;
} else if (!rn2(4)) {
if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
fall_through(FALSE);
- return (1);
+ return 1;
} else
goto ouch;
}
goto ouch;
altar_wrath(x, y);
exercise(A_DEX, TRUE);
- return (1);
+ return 1;
}
if (IS_FOUNTAIN(maploc->typ)) {
if (Levitation)
/* could cause short-lived fumbling here */
}
exercise(A_DEX, TRUE);
- return (1);
+ return 1;
}
if (IS_GRAVE(maploc->typ)) {
if (Levitation)
exercise(A_WIS, TRUE); /* discovered a new food source! */
newsym(x, y);
maploc->looted |= TREE_LOOTED;
- return (1);
+ return 1;
} else if (!(maploc->looted & TREE_SWARM)) {
int cnt = rnl(4) + 2;
int made = 0;
else
You("smell stale honey.");
maploc->looted |= TREE_SWARM;
- return (1);
+ return 1;
}
goto ouch;
}
else
pline("Klunk!");
exercise(A_DEX, TRUE);
- return (1);
+ return 1;
} else if (!(maploc->looted & S_LPUDDING) && !rn2(3)
&& !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) {
if (Blind)
exercise(A_DEX, TRUE);
newsym(x, y);
maploc->looted |= S_LPUDDING;
- return (1);
+ return 1;
} else if (!(maploc->looted & S_LDWASHER) && !rn2(3)
&& !(mvitals[washerndx].mvflags & G_GONE)) {
/* can't resist... */
newsym(x, y);
maploc->looted |= S_LDWASHER;
exercise(A_DEX, TRUE);
- return (1);
+ return 1;
} else if (!rn2(3)) {
pline("Flupp! %s.",
(Blind ? "You hear a sloshing sound"
exercise(A_WIS, TRUE); /* a discovery! */
maploc->looted |= S_LRING;
}
- return (1);
+ return 1;
}
goto ouch;
}
losehp(Maybe_Half_Phys(dmg), kickstr(buf), KILLED_BY);
if (Is_airlevel(&u.uz) || Levitation)
hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
- return (1);
+ return 1;
}
goto dumb;
}
}
}
}
- return (1);
+ return 1;
}
STATIC_OVL void
long n = 0L;
if (!otmp)
- return (FALSE);
+ return FALSE;
if ((toloc = down_gate(x, y)) == MIGR_NOWHERE)
- return (FALSE);
+ return FALSE;
drop_to(&cc, toloc);
if (!cc.y)
- return (FALSE);
+ return FALSE;
/* objects other than attached iron ball always fall down ladder,
but have a chance of staying otherwise */
if (nodrop) {
if (impact)
impact_drop(otmp, x, y, 0);
- return (FALSE);
+ return FALSE;
}
if (unpaid || shop_floor_obj) {
impact_drop(otmp, x, y, 0);
newsym(x, y);
}
- return (TRUE);
+ return TRUE;
}
void
-/* NetHack 3.6 light.c $NHDT-Date: 1432512770 2015/05/25 00:12:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
-/* Copyright (c) Dean Luick, 1994 */
-/* NetHack may be freely redistributed. See license for details. */
+/* NetHack 3.6 light.c $NHDT-Date: 1446191876 2015/10/30 07:57:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
+/* Copyright (c) Dean Luick, 1994 */
+/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "lev.h" /* for checking save modes */
light_sources_sanity_check()
{
light_source *ls;
+ struct monst *mtmp;
+ struct obj *otmp;
unsigned int auint;
for (ls = light_base; ls; ls = ls->next) {
if (!ls->id.a_monst)
panic("insane light source: no id!");
if (ls->type == LS_OBJECT) {
- struct obj *otmp = (struct obj *) ls->id.a_obj;
+ otmp = (struct obj *) ls->id.a_obj;
auint = otmp->o_id;
if (find_oid(auint) != otmp)
panic("insane light source: can't find obj #%u!", auint);
} else if (ls->type == LS_MONSTER) {
- struct monst *mtmp = (struct monst *) ls->id.a_monst;
+ mtmp = (struct monst *) ls->id.a_monst;
auint = mtmp->m_id;
if (find_mid(auint, FM_EVERYWHERE) != mtmp)
panic("insane light source: can't find mon #%u!", auint);
struct monst *mtmp;
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
- if (ls->flags & LSF_NEEDS_FIXUP)
+ if (ls->flags & LSF_NEEDS_FIXUP) {
bwrite(fd, (genericptr_t) ls, sizeof(light_source));
- else {
+ } else {
/* replace object pointer with id for write, then put back */
arg_save = ls->id;
if (ls->type == LS_OBJECT) {
boolean
any_light_source()
{
- return light_base != (light_source *) 0;
+ return (boolean) (light_base != (light_source *) 0);
}
/*
for (ls = light_base; ls; ls = ls->next)
/*
- Is this position check valid??? Can I assume that the positions
- will always be correct because the objects would have been
- updated with the last vision update? [Is that recent enough???]
- */
+ * Is this position check valid??? Can I assume that the positions
+ * will always be correct because the objects would have been
+ * updated with the last vision update? [Is that recent enough???]
+ */
if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
obj = ls->id.a_obj;
if (obj_is_burning(obj)) {
/* The only way to snuff Sunsword is to unwield it. Darkness
* scrolls won't affect it. (If we got here because it was
* dropped or thrown inside a monster, this won't matter
- * anyway
- * because it will go out when dropped.)
+ * anyway because it will go out when dropped.)
*/
if (artifact_light(obj))
continue;
obj_is_burning(obj)
struct obj *obj;
{
- return (obj->lamplit && (obj->otyp == MAGIC_LAMP || ignitable(obj)
- || artifact_light(obj)));
+ return (boolean) (obj->lamplit && (obj->otyp == MAGIC_LAMP
+ || ignitable(obj)
+ || artifact_light(obj)));
}
/* copy the light source(s) attached to src, and attach it/them to dest */
if (obj->otyp == CANDELABRUM_OF_INVOCATION) {
/*
- * The special candelabrum emits more light than the
- * corresponding number of candles would.
- * 1..3 candles, range 2 (minimum range);
- * 4..6 candles, range 3 (normal lamp range);
- * 7 candles, range 4 (bright).
+ * The special candelabrum emits more light than the
+ * corresponding number of candles would.
+ * 1..3 candles, range 2 (minimum range);
+ * 4..6 candles, range 3 (normal lamp range);
+ * 7 candles, range 4 (bright).
*/
radius = (obj->spe < 4) ? 2 : (obj->spe < 7) ? 3 : 4;
} else if (Is_candle(obj)) {
/*
- * Range is incremented by powers of 7 so that it will take
- * wizard mode quantities of candles to get more light than
- * from a lamp, without imposing an arbitrary limit.
- * 1..6 candles, range 2;
- * 7..48 candles, range 3;
- * 49..342 candles, range 4; &c.
+ * Range is incremented by powers of 7 so that it will take
+ * wizard mode quantities of candles to get more light than
+ * from a lamp, without imposing an arbitrary limit.
+ * 1..6 candles, range 2;
+ * 7..48 candles, range 3;
+ * 49..342 candles, range 4; &c.
*/
long n = obj->quan;
Sprintf(buf, " %2d,%2d %2d 0x%04x %s %s", ls->x, ls->y,
ls->range, ls->flags,
(ls->type == LS_OBJECT
- ? "obj"
- : ls->type == LS_MONSTER
- ? (mon_is_local(ls->id.a_monst)
- ? "mon"
- : (ls->id.a_monst == &youmonst) ? "you"
- : "<m>")
- : /* migrating monster */
- "???"),
+ ? "obj"
+ : ls->type == LS_MONSTER
+ ? (mon_is_local(ls->id.a_monst)
+ ? "mon"
+ : (ls->id.a_monst == &youmonst)
+ ? "you"
+ /* migrating monster */
+ : "<m>")
+ : "???"),
fmt_ptr(ls->id.a_void));
putstr(win, 0, buf);
}
-/* NetHack 3.6 mklev.c $NHDT-Date: 1431192767 2015/05/09 17:32:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.41 $ */
+/* NetHack 3.6 mklev.c $NHDT-Date: 1446191876 2015/10/30 07:57:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL boolean FDECL(place_niche, (struct mkroom *, int *, int *, int *));
STATIC_DCL void FDECL(makeniche, (int));
STATIC_DCL void NDECL(make_niches);
-
-STATIC_PTR int FDECL(CFDECLSPEC do_comp,
- (const genericptr, const genericptr));
-
+STATIC_PTR int FDECL(CFDECLSPEC do_comp, (const genericptr,
+ const genericptr));
STATIC_DCL void FDECL(dosdoor, (XCHAR_P, XCHAR_P, struct mkroom *, int));
STATIC_DCL void FDECL(join, (int, int, BOOLEAN_P));
-STATIC_DCL void FDECL(do_room_or_subroom,
- (struct mkroom *, int, int, int, int, BOOLEAN_P,
- SCHAR_P, BOOLEAN_P, BOOLEAN_P));
+STATIC_DCL void FDECL(do_room_or_subroom, (struct mkroom *, int, int,
+ int, int, BOOLEAN_P,
+ SCHAR_P, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL void NDECL(makerooms);
-STATIC_DCL void FDECL(finddpos,
- (coord *, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P));
+STATIC_DCL void FDECL(finddpos, (coord *, XCHAR_P, XCHAR_P,
+ XCHAR_P, XCHAR_P));
STATIC_DCL void FDECL(mkinvpos, (XCHAR_P, XCHAR_P, int));
STATIC_DCL void FDECL(mk_knox_portal, (XCHAR_P, XCHAR_P));
x = (const struct mkroom *) vx;
y = (const struct mkroom *) vy;
if (x->lx < y->lx)
- return (-1);
+ return -1;
return (x->lx > y->lx);
#endif /* LINT */
}
void
add_room(lowx, lowy, hix, hiy, lit, rtype, special)
-register int lowx, lowy, hix, hiy;
+int lowx, lowy, hix, hiy;
boolean lit;
schar rtype;
boolean special;
void
add_subroom(proom, lowx, lowy, hix, hiy, lit, rtype, special)
struct mkroom *proom;
-register int lowx, lowy, hix, hiy;
+int lowx, lowy, hix, hiy;
boolean lit;
schar rtype;
boolean special;
STATIC_OVL void
dosdoor(x, y, aroom, type)
register xchar x, y;
-register struct mkroom *aroom;
-register int type;
+struct mkroom *aroom;
+int type;
{
- boolean shdoor = ((*in_rooms(x, y, SHOPBASE)) ? TRUE : FALSE);
+ boolean shdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE;
if (!IS_WALL(levl[x][y].typ)) /* avoid SDOORs on already made doors */
type = DOOR;
if (levl[x][y].doormask != D_ISOPEN && !shdoor
&& level_difficulty() >= 5 && !rn2(25))
levl[x][y].doormask |= D_TRAPPED;
- } else
+ } else {
#ifdef STUPID
if (shdoor)
- levl[x][y].doormask = D_ISOPEN;
- else
- levl[x][y].doormask = D_NODOOR;
+ levl[x][y].doormask = D_ISOPEN;
+ else
+ levl[x][y].doormask = D_NODOOR;
#else
levl[x][y].doormask = (shdoor ? D_ISOPEN : D_NODOOR);
#endif
+ }
/* also done in roguecorr(); doing it here first prevents
making mimics in place of trapped doors on rogue level */
}
*xx = dd.x;
*yy = dd.y;
- return ((boolean)(
- (isok(*xx, *yy + *dy) && levl[*xx][*yy + *dy].typ == STONE)
- && (isok(*xx, *yy - *dy) && !IS_POOL(levl[*xx][*yy - *dy].typ)
- && !IS_FURNITURE(levl[*xx][*yy - *dy].typ))));
+ return (boolean) ((isok(*xx, *yy + *dy)
+ && levl[*xx][*yy + *dy].typ == STONE)
+ && (isok(*xx, *yy - *dy)
+ && !IS_POOL(levl[*xx][*yy - *dy].typ)
+ && !IS_FURNITURE(levl[*xx][*yy - *dy].typ)));
}
/* there should be one of these per trap, in the same order as trap.h */
int trap_type;
{
register struct mkroom *aroom;
- register struct rm *rm;
- register int vct = 8;
+ struct rm *rm;
+ int vct = 8;
int dy, xx, yy;
- register struct trap *ttmp;
+ struct trap *ttmp;
- if (doorindex < DOORMAX)
+ if (doorindex < DOORMAX) {
while (vct--) {
aroom = &rooms[rn2(nroom)];
if (aroom->rtype != OROOM)
}
return;
}
+ }
}
STATIC_OVL void
make_niches()
{
- register int ct = rnd((nroom >> 1) + 1), dep = depth(&u.uz);
-
+ int ct = rnd((nroom >> 1) + 1), dep = depth(&u.uz);
boolean ltptr = (!level.flags.noteleport && dep > 15),
vamp = (dep > 5 && dep < 25);
STATIC_OVL void
clear_level_structures()
{
- static struct rm zerorm = { cmap_to_glyph(S_stone), 0, 0, 0, 0, 0, 0, 0,
- 0, 0 };
+ static struct rm zerorm = { cmap_to_glyph(S_stone),
+ 0, 0, 0, 0, 0, 0, 0, 0, 0 };
register int x, y;
register struct rm *lev;
lev = &levl[x][0];
for (y = 0; y < ROWNO; y++) {
*lev++ = zerorm;
-#ifdef MICROPORT_BUG
+ /*
+ * These used to be '#if MICROPORT_BUG',
+ * with use of memset(0) for '#if !MICROPORT_BUG' below,
+ * but memset is not appropriate for initializing pointers,
+ * so do these level.objects[][] and level.monsters[][]
+ * initializations unconditionally.
+ */
level.objects[x][y] = (struct obj *) 0;
level.monsters[x][y] = (struct monst *) 0;
-#endif
}
}
-#ifndef MICROPORT_BUG
- (void) memset((genericptr_t) level.objects, 0, sizeof(level.objects));
- (void) memset((genericptr_t) level.monsters, 0, sizeof(level.monsters));
-#endif
level.objlist = (struct obj *) 0;
level.buriedobjlist = (struct obj *) 0;
level.monlist = (struct monst *) 0;
}
/*
- * Place deposits of minerals (gold and misc gems) in the stone
- * surrounding the rooms on the map.
- * Also place kelp in water.
+ * Place deposits of minerals (gold and misc gems) in the stone
+ * surrounding the rooms on the map.
+ * Also place kelp in water.
* mineralize(-1, -1, -1, -1, FALSE); => "default" behaviour
*/
void
void
#ifdef SPECIALIZATION
-topologize(croom, do_ordinary) register struct mkroom *croom;
+topologize(croom, do_ordinary)
+struct mkroom *croom;
boolean do_ordinary;
#else
-topologize(croom) register struct mkroom *croom;
+topologize(croom)
+struct mkroom *croom;
#endif
{
register int x, y, roomno = (int) ((croom - rooms) + ROOMOFFSET);
- register int lowx = croom->lx, lowy = croom->ly;
- register int hix = croom->hx, hiy = croom->hy;
+ int lowx = croom->lx, lowy = croom->ly;
+ int hix = croom->hx, hiy = croom->hy;
#ifdef SPECIALIZATION
- register schar rtype = croom->rtype;
+ schar rtype = croom->rtype;
#endif
- register int subindex, nsubrooms = croom->nsubrooms;
+ int subindex, nsubrooms = croom->nsubrooms;
/* skip the room if already done; i.e. a shop handled out of order */
/* also skip if this is non-rectangular (it _must_ be done already) */
/* subrooms */
for (subindex = 0; subindex < nsubrooms; subindex++)
#ifdef SPECIALIZATION
- topologize(croom->sbrooms[subindex], (rtype != OROOM));
+ topologize(croom->sbrooms[subindex], (boolean) (rtype != OROOM));
#else
topologize(croom->sbrooms[subindex]);
#endif
/* see whether it is allowable to create a door at [x,y] */
int
okdoor(x, y)
-register xchar x, y;
+xchar x, y;
{
- register boolean near_door = bydoor(x, y);
+ boolean near_door = bydoor(x, y);
return ((levl[x][y].typ == HWALL || levl[x][y].typ == VWALL)
&& doorindex < DOORMAX && !near_door);
void
dodoor(x, y, aroom)
-register int x, y;
-register struct mkroom *aroom;
+int x, y;
+struct mkroom *aroom;
{
if (doorindex >= DOORMAX) {
impossible("DOORMAX exceeded?");
occupied(x, y)
register xchar x, y;
{
- return ((boolean)(t_at(x, y) || IS_FURNITURE(levl[x][y].typ)
+ return (boolean) (t_at(x, y) || IS_FURNITURE(levl[x][y].typ)
|| is_lava(x, y) || is_pool(x, y)
- || invocation_pos(x, y)));
+ || invocation_pos(x, y));
}
/* make a trap somewhere (in croom if mazeflag = 0 && !tm) */
/* if tm != null, make trap at that location */
void
mktrap(num, mazeflag, croom, tm)
-register int num, mazeflag;
-register struct mkroom *croom;
+int num, mazeflag;
+struct mkroom *croom;
coord *tm;
{
register int kind;
levl[x][y].ladder = up ? LA_UP : LA_DOWN;
}
-STATIC_OVL
-void
+STATIC_OVL void
mkfount(mazeflag, croom)
-register int mazeflag;
-register struct mkroom *croom;
+int mazeflag;
+struct mkroom *croom;
{
coord m;
register int tryct = 0;
STATIC_OVL void
mksink(croom)
-register struct mkroom *croom;
+struct mkroom *croom;
{
coord m;
register int tryct = 0;
STATIC_OVL void
mkaltar(croom)
-register struct mkroom *croom;
+struct mkroom *croom;
{
coord m;
register int tryct = 0;
/* maze levels have slightly different constraints from normal levels */
#define x_maze_min 2
#define y_maze_min 2
+
/*
* Major level transmutation: add a set of stairs (to the Sanctum) after
* an earthquake that leaves behind a a new topology, centered at inv_pos.
lev->lit = TRUE;
lev->waslit = TRUE;
lev->horizontal = FALSE;
- viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE)
- : /* short-circuit vision recalc */
- COULD_SEE;
+ /* short-circuit vision recalc */
+ viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
switch (dist) {
case 1: /* fire traps */
-/* NetHack 3.6 objnam.c $NHDT-Date: 1445556878 2015/10/22 23:34:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.149 $ */
+/* NetHack 3.6 objnam.c $NHDT-Date: 1446191877 2015/10/30 07:57:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.150 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
boolean
obj_is_pname(obj)
-register struct obj *obj;
+struct obj *obj;
{
if (!obj->oartifact || !has_oname(obj))
return FALSE;
*/
char *
distant_name(obj, func)
-register struct obj *obj;
+struct obj *obj;
char *FDECL((*func), (OBJ_P));
{
char *str;
}
if (Is_pudding(obj)) {
Sprintf(buf, "%s%s",
- obj->owt < 100
- ? "small "
- : obj->owt > 500 ? "very large "
- : obj->owt > 300 ? "large " : "",
+ (obj->owt < 100)
+ ? "small "
+ : (obj->owt > 500)
+ ? "very large "
+ : (obj->owt > 300)
+ ? "large "
+ : "",
actualn);
break;
}
if (typ == STATUE && omndx != NON_PM)
Sprintf(buf, "%s%s of %s%s",
(Role_if(PM_ARCHEOLOGIST) && (obj->spe & STATUE_HISTORIC))
- ? "historic "
- : "",
+ ? "historic "
+ : "",
actualn,
type_is_pname(&mons[omndx])
- ? ""
- : the_unique_pm(&mons[omndx])
- ? "the "
- : index(vowels, *mons[omndx].mname) ? "an "
- : "a ",
+ ? ""
+ : the_unique_pm(&mons[omndx])
+ ? "the "
+ : index(vowels, *mons[omndx].mname)
+ ? "an "
+ : "a ",
mons[omndx].mname);
else
Strcpy(buf, actualn);
break;
case GEM_CLASS: {
const char *rock = (ocl->oc_material == MINERAL) ? "stone" : "gem";
+
if (!dknown) {
Strcpy(buf, rock);
} else if (!nn) {
if (obj->otyp == T_SHIRT && program_state.gameover) {
char tmpbuf[BUFSZ];
+
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf));
}
if (m_shot.n > 1 && m_shot.o == obj->otyp) {
/* copy xname's result so that we can reuse its return buffer */
Strcpy(tmpbuf, onm);
+ /* play it safe even though there's no risk of overflowing onm[] */
+ tmpbuf[BUFSZ - sizeof "the Nth "] = '\0';
/* "the Nth arrow"; value will eventually be passed to an() or
The(), both of which correctly handle this "the " prefix */
Sprintf(onm, "the %d%s %s", m_shot.i, ordin(m_shot.i), tmpbuf);
}
-
return onm;
}
/* used for naming "the unique_item" instead of "a unique_item" */
boolean
the_unique_obj(obj)
-register struct obj *obj;
+struct obj *obj;
{
boolean known = (obj->known || iflags.override_ID);
+
if (!obj->dknown && !iflags.override_ID)
return FALSE;
else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known)
}
if (rknown && obj->oerodeproof)
Strcat(prefix, iscrys
- ? "fixed "
- : is_rustprone(obj)
- ? "rustproof "
- : is_corrodeable(obj) ? "corrodeproof "
- : /* "stainless"? */
- is_flammable(obj) ? "fireproof " : "");
+ ? "fixed "
+ : is_rustprone(obj)
+ ? "rustproof "
+ : is_corrodeable(obj)
+ ? "corrodeproof " /* "stainless"? */
+ : is_flammable(obj)
+ ? "fireproof "
+ : "");
}
static char *
boolean known, cknown, bknown, lknown;
int omndx = obj->corpsenm;
char prefix[PREFIX];
- char tmpbuf[PREFIX + 1];
- /* when we have to add something at the start of prefix instead of the
- * end (Strcat is used on the end)
- */
+ char tmpbuf[PREFIX + 1]; /* for when we have to add something at
+ the start of prefix instead of the
+ end (Strcat is used on the end) */
register char *bp = xname(obj);
if (iflags.override_ID) {
ispoisoned = TRUE;
}
- if (obj->quan != 1L)
+ if (obj->quan != 1L) {
Sprintf(prefix, "%ld ", obj->quan);
- else if (obj->otyp == CORPSE)
+ } else if (obj->otyp == CORPSE) {
/* skip article prefix for corpses [else corpse_xname()
would have to be taught how to strip it off again] */
*prefix = '\0';
- else if (obj_is_pname(obj) || the_unique_obj(obj)) {
+ } else if (obj_is_pname(obj) || the_unique_obj(obj)) {
if (!strncmpi(bp, "the ", 4))
bp += 4;
Strcpy(prefix, "the ");
- } else
+ } else {
Strcpy(prefix, "a ");
+ }
/* "empty" goes at the beginning, but item count goes at the end */
if (cknown
} else if (obj->otyp == EGG) {
#if 0 /* corpses don't tell if they're stale either */
if (known && stale_egg(obj))
- Strcat(prefix, "stale ");
+ Strcat(prefix, "stale ");
#endif
if (omndx >= LOW_PM
&& (known || (mvitals[omndx].mvflags & MV_KNOWS_EGG))) {
Strcat(bp, " (at the ready)");
break;
}
-
/* Small things and ammo not for a bow */
case RING_CLASS:
case AMULET_CLASS:
if (!iflags.suppress_price && is_unpaid(obj)) {
long quotedprice = unpaid_cost(obj, TRUE);
- Sprintf(eos(bp), " (%s, %ld %s)", obj->unpaid ? "unpaid" : "contents",
+ Sprintf(eos(bp), " (%s, %ld %s)",
+ obj->unpaid ? "unpaid" : "contents",
quotedprice, currency(quotedprice));
} else if (with_price) {
long price = get_cost_of_shop_item(obj);
char *
short_oname(obj, func, altfunc, lenlimit)
struct obj *obj;
-char *FDECL((*func), (OBJ_P)), /* main formatting routine */
- *FDECL((*altfunc), (OBJ_P)); /* alternate for shortest result */
+char *FDECL((*func), (OBJ_P)), /* main formatting routine */
+ *FDECL((*altfunc), (OBJ_P)); /* alternate for shortest result */
unsigned lenlimit;
{
struct obj save_obj;
An(str)
const char *str;
{
- register char *tmp = an(str);
+ char *tmp = an(str);
+
*tmp = highc(*tmp);
return tmp;
}
int l;
/* some objects have capitalized adjectives in their names */
- if (((tmp = rindex(str, ' ')) || (tmp = rindex(str, '-')))
- && (tmp[1] < 'A' || tmp[1] > 'Z'))
+ if (((tmp = rindex(str, ' ')) != 0 || (tmp = rindex(str, '-')) != 0)
+ && (tmp[1] < 'A' || tmp[1] > 'Z')) {
insert_the = TRUE;
- else if (tmp && index(str, ' ') < tmp) { /* has spaces */
+ } else if (tmp && index(str, ' ') < tmp) { /* has spaces */
/* it needs an article if the name contains "of" */
tmp = strstri(str, " of ");
named = strstri(str, " named ");
The(str)
const char *str;
{
- register char *tmp = the(str);
+ char *tmp = the(str);
+
*tmp = highc(*tmp);
return tmp;
}
/* returns "count cxname(otmp)" or just cxname(otmp) if count == 1 */
char *
aobjnam(otmp, verb)
-register struct obj *otmp;
-register const char *verb;
+struct obj *otmp;
+const char *verb;
{
- register char *bp = cxname(otmp);
char prefix[PREFIX];
+ char *bp = cxname(otmp);
if (otmp->quan != 1L) {
Sprintf(prefix, "%ld ", otmp->quan);
bp = strprepend(bp, prefix);
}
-
if (verb) {
Strcat(bp, " ");
Strcat(bp, otense(otmp, verb));
s = strncat(outbuf, s, space_left);
}
-
return s;
}
/* like aobjnam, but prepend "The", not count, and use xname */
char *
Tobjnam(otmp, verb)
-register struct obj *otmp;
-register const char *verb;
+struct obj *otmp;
+const char *verb;
{
char *bp = The(xname(otmp));
/* capitalized variant of doname() */
char *
Doname2(obj)
-register struct obj *obj;
+struct obj *obj;
{
- register char *s = doname(obj);
+ char *s = doname(obj);
*s = highc(*s);
return s;
/* return form of the verb (input plural) if xname(otmp) were the subject */
char *
otense(otmp, verb)
-register struct obj *otmp;
-register const char *verb;
+struct obj *otmp;
+const char *verb;
{
char *buf;
if (p >= bp + 3 && lowc(p[-3]) == 'i') { /* "ies" */
if (!BSTRCMPI(bp, p - 7, "cookies")
|| !BSTRCMPI(bp, p - 4, "pies")
- || !BSTRCMPI(bp, p - 5, "mbies") || /* zombie */
- !BSTRCMPI(bp, p - 5, "yries")) /* valkyrie */
+ || !BSTRCMPI(bp, p - 5, "mbies") /* zombie */
+ || !BSTRCMPI(bp, p - 5, "yries")) /* valkyrie */
goto mins;
Strcasecpy(p - 3, "y"); /* ies -> y */
goto bottom;
goto bottom;
}
/* note: nurses, axes but boxes, wumpuses */
- if (!BSTRCMPI(bp, p - 4, "eses") || !BSTRCMPI(bp, p - 4, "oxes")
- || /* boxes, foxes */
- !BSTRCMPI(bp, p - 4, "nxes") || /* lynxes */
- !BSTRCMPI(bp, p - 4, "ches") || !BSTRCMPI(bp, p - 4, "uses")
- || /* lotuses */
- !BSTRCMPI(bp, p - 4, "sses") || /* priestesses */
- !BSTRCMPI(bp, p - 5, "atoes") || /* tomatoes */
- !BSTRCMPI(bp, p - 7, "dingoes")
+ if (!BSTRCMPI(bp, p - 4, "eses")
+ || !BSTRCMPI(bp, p - 4, "oxes") /* boxes, foxes */
+ || !BSTRCMPI(bp, p - 4, "nxes") /* lynxes */
+ || !BSTRCMPI(bp, p - 4, "ches")
+ || !BSTRCMPI(bp, p - 4, "uses") /* lotuses */
+ || !BSTRCMPI(bp, p - 4, "sses") /* priestesses */
+ || !BSTRCMPI(bp, p - 5, "atoes") /* tomatoes */
+ || !BSTRCMPI(bp, p - 7, "dingoes")
|| !BSTRCMPI(bp, p - 7, "Aleaxes")) {
*(p - 2) = '\0'; /* drop es */
goto bottom;
/* ends in 's' but not 'es' */
} else if (!BSTRCMPI(bp, p - 2, "us")) { /* lotus, fungus... */
- if (BSTRCMPI(bp, p - 6, "tengus") && /* but not these... */
- BSTRCMPI(bp, p - 7, "hezrous"))
+ if (BSTRCMPI(bp, p - 6, "tengus") /* but not these... */
+ && BSTRCMPI(bp, p - 7, "hezrous"))
goto bottom;
- } else if (!BSTRCMPI(bp, p - 2, "ss") || !BSTRCMPI(bp, p - 5, " lens")
+ } else if (!BSTRCMPI(bp, p - 2, "ss")
+ || !BSTRCMPI(bp, p - 5, " lens")
|| (p - 4 == bp && !strcmpi(p - 4, "lens"))) {
goto bottom;
}
return fuzzymatch(buf, o_str, " -", TRUE);
}
} else if (strstri(o_str, "ability")) {
- /* when presented with "foo of bar", make singular() used to
+ /* when presented with "foo of bar", makesingular() used to
singularize both foo & bar, but now only does so for foo */
/* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */
if ((p = strstri(u_str, "abilities")) != 0
otmp->spe = ishistoric ? STATUE_HISTORIC : 0;
break;
case SCALE_MAIL:
- /* Dragon mail - depends on the order of objects */
- /* & dragons. */
+ /* Dragon mail - depends on the order of objects & dragons. */
if (mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON)
otmp->otyp = GRAY_DRAGON_SCALE_MAIL + mntmp - PM_GRAY_DRAGON;
break;
struct obj *helmet;
{
/*
- * There is some wiggle room here; the result has been chosen
- * for consistency with the "protected by hard helmet" messages
- * given for various bonks on the head: headgear that provides
- * such protection is a "helm", that which doesn't is a "hat".
+ * There is some wiggle room here; the result has been chosen
+ * for consistency with the "protected by hard helmet" messages
+ * given for various bonks on the head: headgear that provides
+ * such protection is a "helm", that which doesn't is a "hat".
*
- * elven leather helm / leather hat -> hat
- * dwarvish iron helm / hard hat -> helm
- * The rest are completely straightforward:
- * fedora, cornuthaum, dunce cap -> hat
- * all other types of helmets -> helm
+ * elven leather helm / leather hat -> hat
+ * dwarvish iron helm / hard hat -> helm
+ * The rest are completely straightforward:
+ * fedora, cornuthaum, dunce cap -> hat
+ * all other types of helmets -> helm
*/
return (helmet && !is_metallic(helmet)) ? "hat" : "helm";
}
-/* NetHack 3.6 quest.c $NHDT-Date: 1432512771 2015/05/25 00:12:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
-/* Copyright 1991, M. Stephenson */
+/* NetHack 3.6 quest.c $NHDT-Date: 1446191878 2015/10/30 07:57:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.20 $ */
+/* Copyright 1991, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
boolean
ok_to_quest()
{
- return ((boolean)((Qstat(got_quest) || Qstat(got_thanks)))
- && (is_pure(FALSE) > 0));
+ return (boolean) ((Qstat(got_quest) || Qstat(got_thanks))
+ && is_pure(FALSE) > 0);
}
STATIC_OVL boolean
not_capable()
{
- return ((boolean)(u.ulevel < MIN_QUEST_LEVEL));
+ return (boolean) (u.ulevel < MIN_QUEST_LEVEL);
}
STATIC_OVL int
br = dungeon_branch("The Quest");
dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1;
- portal_flag = u.uevent.qexpelled ? 0 : /* returned via artifact? */
- !seal ? 1 : -1;
+ portal_flag = u.uevent.qexpelled ? 0 /* returned via artifact? */
+ : !seal ? 1 : -1;
schedule_goto(dest, FALSE, FALSE, portal_flag, (char *) 0, (char *) 0);
if (seal) { /* remove the portal to the quest - sealing it off */
int reexpelled = u.uevent.qexpelled;
STATIC_OVL void
chat_with_leader()
{
- /* Rule 0: Cheater checks. */
+ /* Rule 0: Cheater checks. */
if (u.uhave.questart && !Qstat(met_nemesis))
Qstat(cheater) = TRUE;
- /* It is possible for you to get the amulet without completing
- * the quest. If so, try to induce the player to quest.
+ /* It is possible for you to get the amulet without completing
+ * the quest. If so, try to induce the player to quest.
*/
if (Qstat(got_thanks)) {
- /* Rule 1: You've gone back with/without the amulet. */
+ /* Rule 1: You've gone back with/without the amulet. */
if (u.uhave.amulet)
finish_quest((struct obj *) 0);
- /* Rule 2: You've gone back before going for the amulet. */
+ /* Rule 2: You've gone back before going for the amulet. */
else
qt_pager(QT_POSTHANKS);
- }
- /* Rule 3: You've got the artifact and are back to return it. */
- else if (u.uhave.questart) {
+ /* Rule 3: You've got the artifact and are back to return it. */
+ } else if (u.uhave.questart) {
struct obj *otmp;
for (otmp = invent; otmp; otmp = otmp->nobj)
finish_quest(otmp);
- /* Rule 4: You haven't got the artifact yet. */
+ /* Rule 4: You haven't got the artifact yet. */
} else if (Qstat(got_quest)) {
qt_pager(rn1(10, QT_ENCOURAGE));
- /* Rule 5: You aren't yet acceptable - or are you? */
+ /* Rule 5: You aren't yet acceptable - or are you? */
} else {
if (!Qstat(met_leader)) {
qt_pager(QT_FIRSTLEADER);
Qstat(not_ready) = 0;
} else
qt_pager(QT_NEXTLEADER);
+
/* the quest leader might have passed through the portal into
the regular dungeon; none of the remaining make sense there */
if (!on_level(&u.uz, &qstart_level))
void
leader_speaks(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
/* maybe you attacked leader? */
if (!mtmp->mpeaceful) {
STATIC_OVL void
chat_with_nemesis()
{
- /* The nemesis will do most of the talking, but... */
+ /* The nemesis will do most of the talking, but... */
qt_pager(rn1(10, QT_DISCOURAGE));
if (!Qstat(met_nemesis))
Qstat(met_nemesis++);
STATIC_OVL void
chat_with_guardian()
{
- /* These guys/gals really don't have much to say... */
+ /* These guys/gals really don't have much to say... */
if (u.uhave.questart && Qstat(killed_nemesis))
qt_pager(rn1(5, QT_GUARDTALK2));
else
STATIC_OVL void
prisoner_speaks(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
if (mtmp->data == &mons[PM_PRISONER]
&& (mtmp->mstrategy & STRAT_WAITMASK)) {
void
quest_talk(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
if (mtmp->m_id == Qstat(leader_m_id)) {
leader_speaks(mtmp);
struct monst *mtmp;
{
if (mtmp->data->msound == MS_NEMESIS)
- Qstat(in_battle) =
- (mtmp->mcanmove && !mtmp->msleeping && monnear(mtmp, u.ux, u.uy));
+ Qstat(in_battle) = (mtmp->mcanmove && !mtmp->msleeping
+ && monnear(mtmp, u.ux, u.uy));
}
/*quest.c*/
-/* NetHack 3.6 spell.c $NHDT-Date: 1445906865 2015/10/27 00:47:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
-/* Copyright (c) M. Stephenson 1988 */
+/* NetHack 3.6 spell.c $NHDT-Date: 1446191879 2015/10/30 07:57:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.67 $ */
+/* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
*
* Reasoning:
* spelbase, spelheal:
- * Arc are aware of magic through historical research
- * Bar abhor magic (Conan finds it "interferes with his animal instincts")
- * Cav are ignorant to magic
- * Hea are very aware of healing magic through medical research
- * Kni are moderately aware of healing from Paladin training
- * Mon use magic to attack and defend in lieu of weapons and armor
- * Pri are very aware of healing magic through theological research
- * Ran avoid magic, preferring to fight unseen and unheard
- * Rog are moderately aware of magic through trickery
- * Sam have limited magical awareness, preferring meditation to conjuring
- * Tou are aware of magic from all the great films they have seen
- * Val have limited magical awareness, preferring fighting
- * Wiz are trained mages
+ * Arc are aware of magic through historical research
+ * Bar abhor magic (Conan finds it "interferes with his animal instincts")
+ * Cav are ignorant to magic
+ * Hea are very aware of healing magic through medical research
+ * Kni are moderately aware of healing from Paladin training
+ * Mon use magic to attack and defend in lieu of weapons and armor
+ * Pri are very aware of healing magic through theological research
+ * Ran avoid magic, preferring to fight unseen and unheard
+ * Rog are moderately aware of magic through trickery
+ * Sam have limited magical awareness, preferring meditation to conjuring
+ * Tou are aware of magic from all the great films they have seen
+ * Val have limited magical awareness, preferring fighting
+ * Wiz are trained mages
*
- * The arms penalty is lessened for trained fighters Bar, Kni, Ran,
- * Sam, Val -
- * the penalty is its metal interference, not encumbrance.
- * The `spelspec' is a single spell which is fundamentally easier
- * for that role to cast.
+ * The arms penalty is lessened for trained fighters Bar, Kni, Ran,
+ * Sam, Val -- the penalty is its metal interference, not encumbrance.
+ * The `spelspec' is a single spell which is fundamentally easier
+ * for that role to cast.
*
* spelspec, spelsbon:
- * Arc map masters (SPE_MAGIC_MAPPING)
- * Bar fugue/berserker (SPE_HASTE_SELF)
- * Cav born to dig (SPE_DIG)
- * Hea to heal (SPE_CURE_SICKNESS)
- * Kni to turn back evil (SPE_TURN_UNDEAD)
- * Mon to preserve their abilities (SPE_RESTORE_ABILITY)
- * Pri to bless (SPE_REMOVE_CURSE)
- * Ran to hide (SPE_INVISIBILITY)
- * Rog to find loot (SPE_DETECT_TREASURE)
- * Sam to be At One (SPE_CLAIRVOYANCE)
- * Tou to smile (SPE_CHARM_MONSTER)
- * Val control the cold (SPE_CONE_OF_COLD)
- * Wiz all really, but SPE_MAGIC_MISSILE is their party trick
+ * Arc map masters (SPE_MAGIC_MAPPING)
+ * Bar fugue/berserker (SPE_HASTE_SELF)
+ * Cav born to dig (SPE_DIG)
+ * Hea to heal (SPE_CURE_SICKNESS)
+ * Kni to turn back evil (SPE_TURN_UNDEAD)
+ * Mon to preserve their abilities (SPE_RESTORE_ABILITY)
+ * Pri to bless (SPE_REMOVE_CURSE)
+ * Ran to hide (SPE_INVISIBILITY)
+ * Rog to find loot (SPE_DETECT_TREASURE)
+ * Sam to be At One (SPE_CLAIRVOYANCE)
+ * Tou to smile (SPE_CHARM_MONSTER)
+ * Val control the cold (SPE_CONE_OF_COLD)
+ * Wiz all really, but SPE_MAGIC_MISSILE is their party trick
*
- * See percent_success() below for more comments.
+ * See percent_success() below for more comments.
*
* uarmbon, uarmsbon, uarmhbon, uarmgbon, uarmfbon:
- * Fighters find body armour & shield a little less limiting.
- * Headgear, Gauntlets and Footwear are not role-specific (but
- * still have an effect, except helm of brilliance, which is designed
- * to permit magic-use).
+ * Fighters find body armour & shield a little less limiting.
+ * Headgear, Gauntlets and Footwear are not role-specific (but
+ * still have an effect, except helm of brilliance, which is designed
+ * to permit magic-use).
*/
#define uarmhbon 4 /* Metal helmets interfere with the mind */
/* The more u.uspellprot you already have, the less you get,
* and the better your natural ac, the less you get.
*
- * LEVEL AC SPELLPROT from successive SPE_PROTECTION casts
+ * LEVEL AC SPELLPROT from successive SPE_PROTECTION casts
* 1 10 0, 1, 2, 3, 4
* 1 0 0, 1, 2, 3
* 1 -10 0, 1, 2
case SPE_DRAIN_LIFE:
case SPE_STONE_TO_FLESH:
if (!(objects[pseudo->otyp].oc_dir == NODIR)) {
- if (atme)
+ if (atme) {
u.dx = u.dy = u.dz = 0;
- else if (!getdir((char *) 0)) {
+ } else if (!getdir((char *) 0)) {
/* getdir cancelled, re-use previous direction */
+ /*
+ * FIXME: reusing previous direction only makes sense
+ * if there is an actual previous direction. When there
+ * isn't one, the spell gets cast at self which is rarely
+ * what the player intended. Unfortunately, the way
+ * spelleffects() is organized means that aborting with
+ * "nevermind" is not an option.
+ */
pline_The("magical energy is released!");
}
if (!u.dx && !u.dy && !u.dz) {
if ((damage = zapyourself(pseudo, TRUE)) != 0) {
char buf[BUFSZ];
+
Sprintf(buf, "zapped %sself with a spell", uhim());
if (physical_damage)
damage = Maybe_Half_Phys(damage);
/* lose access to spell [i] */
spellknow(i) = 0;
#if 0
- /* also forget its book */
- forget_single_object(spellid(i));
+ /* also forget its book */
+ forget_single_object(spellid(i));
#endif
/* and abuse wisdom */
exercise(A_WIS, FALSE);
* pairs of them becomes very tedious once the list reaches two pages.
*
* Possible extensions:
- * provide means for player to control ordering of skill classes;
- * provide means to supply value N such that first N entries stick
- * while rest of list is being sorted;
- * make chosen sort order be persistent such that when new spells
- * are learned, they get inserted into sorted order rather than be
- * appended to the end of the list?
+ * provide means for player to control ordering of skill classes;
+ * provide means to supply value N such that first N entries stick
+ * while rest of list is being sorted;
+ * make chosen sort order be persistent such that when new spells
+ * are learned, they get inserted into sorted order rather than be
+ * appended to the end of the list?
*/
static const char *spl_sortchoices[] = {
"by casting letter",
/*
* gather up all of the possible parameters except spell name
* in advance, even though some might not be needed:
- * indx? = spl_orderindx[] index into spl_book[];
- * otyp? = spl_book[] index into objects[];
- * levl? = spell level;
- * skil? = skill group aka spell class;
+ * indx. = spl_orderindx[] index into spl_book[];
+ * otyp. = spl_book[] index into objects[];
+ * levl. = spell level;
+ * skil. = skill group aka spell class.
*/
int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2,
otyp1 = spl_book[indx1].sp_id, otyp2 = spl_book[indx2].sp_id,
if (!spl_orderindx) {
/* we haven't done any sorting yet; list is in casting order */
- if (spl_sortmode == SORTBY_LETTER || /* default */
- spl_sortmode == SORTRETAINORDER)
+ if (spl_sortmode == SORTBY_LETTER /* default */
+ || spl_sortmode == SORTRETAINORDER)
return;
/* allocate enough for full spellbook rather than just N spells */
spl_orderindx = (int *) alloc(MAXSPELL * sizeof(int));
if (spellid(0) == NO_SPELL) {
You("don't know any spells right now.");
} else {
- while (
- dospellmenu("Currently known spells", SPELLMENU_VIEW, &splnum)) {
+ while (dospellmenu("Currently known spells",
+ SPELLMENU_VIEW, &splnum)) {
if (splnum == SPELLMENU_SORT) {
if (spellsortmenu())
sortspells();