commit 84bec89d403a219ff75ae3fa97109de0cfb7941f

Author: PatR <rankin@nethack.org>
Date:   Fri Oct 30 00:50:52 2015 -0700

    more formatting

    Fix up the files containing '[?:] */' to get trailing trinary operator
    followed by end-of-line comment.  Tab replacement and removal of excess
    parentheses on return statements also done.
This commit is contained in:
PatR
2015-10-30 00:58:06 -07:00
parent 7b82fed49d
commit 8a5f340579
7 changed files with 391 additions and 367 deletions

145
src/dig.c
View File

@@ -1,4 +1,4 @@
/* 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. */
@@ -29,12 +29,12 @@ rm_waslit()
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
@@ -76,9 +76,8 @@ boolean waslit, rockit;
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);
@@ -196,25 +195,25 @@ int x, y;
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
@@ -223,11 +222,11 @@ int x, y;
|| (!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 */
@@ -235,7 +234,7 @@ int x, y;
/* digging by player handles pools separately */
return FALSE;
}
return (TRUE);
return TRUE;
}
STATIC_OVL int
@@ -253,22 +252,22 @@ dig(VOID_ARGS)
|| !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)) {
@@ -295,7 +294,7 @@ dig(VOID_ARGS)
Your("swing misses its mark.");
break;
}
return (0);
return 0;
}
context.digging.effort +=
@@ -309,13 +308,13 @@ dig(VOID_ARGS)
(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;
@@ -359,7 +358,7 @@ dig(VOID_ARGS)
context.digging.level.dnum = 0;
context.digging.level.dlevel = -1;
}
return (0);
return 0;
}
if (context.digging.effort > 100) {
@@ -434,7 +433,7 @@ dig(VOID_ARGS)
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 */
@@ -472,7 +471,7 @@ dig(VOID_ARGS)
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" };
@@ -482,18 +481,18 @@ dig(VOID_ARGS)
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. */
@@ -501,7 +500,7 @@ int
holetime()
{
if (occupation != dig || !*u.ushops)
return (-1);
return -1;
return ((250 - context.digging.effort) / 20);
}
@@ -1006,9 +1005,9 @@ struct obj *obj;
*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 */
@@ -1027,7 +1026,7 @@ struct obj *obj;
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) {
@@ -1046,7 +1045,7 @@ struct obj *obj;
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();
@@ -1054,11 +1053,11 @@ struct obj *obj;
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 */
@@ -1189,7 +1188,7 @@ struct obj *obj;
did_dig_msg = FALSE;
set_occupation(dig, verbing, 0);
}
return (1);
return 1;
}
/*
@@ -1627,10 +1626,10 @@ char *msg;
/* "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.");
@@ -1679,10 +1678,11 @@ pit_flow(trap, filltyp)
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,
@@ -1693,16 +1693,16 @@ schar filltyp;
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);
@@ -1757,9 +1757,9 @@ buried_ball_to_punishment()
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;
@@ -1780,9 +1780,9 @@ buried_ball_to_freedom()
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);
@@ -1823,7 +1823,7 @@ boolean *dealloced;
* completely different.
*/
if (otmp == uchain || obj_resists(otmp, 0, 0))
return (otmp2);
return otmp2;
if (otmp->otyp == LEASH && otmp->leashmon != 0)
o_unleash(otmp);
@@ -1839,7 +1839,7 @@ boolean *dealloced;
if (dealloced)
*dealloced = TRUE;
obfree(otmp, (struct obj *) 0);
return (otmp2);
return otmp2;
}
/*
* Start a rot on organic material. Not corpses -- they
@@ -1851,16 +1851,17 @@ boolean *dealloced;
&& !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
@@ -1872,7 +1873,7 @@ int x, y;
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);
@@ -1933,7 +1934,7 @@ long timeout UNUSED;
/* 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);
@@ -1945,7 +1946,7 @@ long timeout UNUSED;
void
rot_corpse(arg, timeout)
anything *arg;
long timeout; /* unused */
long timeout;
{
xchar x = 0, y = 0;
struct obj *obj = arg->a_obj;
@@ -2020,16 +2021,16 @@ bury_you()
{
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);
}
}

View File

@@ -1,4 +1,4 @@
/* 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. */
@@ -144,7 +144,7 @@ xchar x, y;
mon = 0; /* don't kick after all */
context.forcefight = save_forcefight;
}
return (boolean)(mon != 0);
return (boolean) (mon != 0);
}
STATIC_OVL void
@@ -507,7 +507,7 @@ xchar x, y;
if (Fumbling && !rn2(3)) {
Your("clumsy kick missed.");
return (1);
return 1;
}
if (!uarmf && kickedobj->otyp == CORPSE
@@ -525,8 +525,8 @@ xchar x, y;
}
}
/* 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())
@@ -601,7 +601,7 @@ xchar x, y;
breakchestlock(kickedobj, FALSE);
if (otrp)
(void) chest_trap(kickedobj, LEG, FALSE);
return (1);
return 1;
}
} else {
if (!rn2(3) || (martial() && !rn2(2))) {
@@ -609,11 +609,11 @@ xchar x, y;
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... */
}
@@ -675,9 +675,9 @@ xchar x, y;
&& 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;
@@ -702,7 +702,7 @@ xchar x, y;
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 */
@@ -816,9 +816,9 @@ dokick()
}
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;
@@ -843,7 +843,7 @@ dokick()
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.");
@@ -862,7 +862,7 @@ dokick()
&& !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;
}
}
@@ -934,7 +934,7 @@ dokick()
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);
@@ -951,7 +951,7 @@ dokick()
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;
}
@@ -980,7 +980,7 @@ dokick()
if (maploc->doormask == D_ISOPEN
|| maploc->doormask == D_NODOOR)
unblock_point(x, y); /* vision */
return (1);
return 1;
} else
goto ouch;
}
@@ -994,7 +994,7 @@ dokick()
else
newsym(x, y);
unblock_point(x, y); /* vision */
return (1);
return 1;
} else
goto ouch;
}
@@ -1013,7 +1013,7 @@ dokick()
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;
@@ -1031,11 +1031,11 @@ dokick()
}
/* 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;
}
@@ -1049,7 +1049,7 @@ dokick()
goto ouch;
altar_wrath(x, y);
exercise(A_DEX, TRUE);
return (1);
return 1;
}
if (IS_FOUNTAIN(maploc->typ)) {
if (Levitation)
@@ -1064,7 +1064,7 @@ dokick()
/* could cause short-lived fumbling here */
}
exercise(A_DEX, TRUE);
return (1);
return 1;
}
if (IS_GRAVE(maploc->typ)) {
if (Levitation)
@@ -1121,7 +1121,7 @@ dokick()
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;
@@ -1139,7 +1139,7 @@ dokick()
else
You("smell stale honey.");
maploc->looted |= TREE_SWARM;
return (1);
return 1;
}
goto ouch;
}
@@ -1157,7 +1157,7 @@ dokick()
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)
@@ -1169,7 +1169,7 @@ dokick()
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... */
@@ -1178,7 +1178,7 @@ dokick()
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"
@@ -1192,7 +1192,7 @@ dokick()
exercise(A_WIS, TRUE); /* a discovery! */
maploc->looted |= S_LRING;
}
return (1);
return 1;
}
goto ouch;
}
@@ -1220,7 +1220,7 @@ dokick()
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;
}
@@ -1310,7 +1310,7 @@ dokick()
}
}
}
return (1);
return 1;
}
STATIC_OVL void
@@ -1489,12 +1489,12 @@ boolean shop_floor_obj;
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 */
@@ -1526,7 +1526,7 @@ boolean shop_floor_obj;
if (nodrop) {
if (impact)
impact_drop(otmp, x, y, 0);
return (FALSE);
return FALSE;
}
if (unpaid || shop_floor_obj) {
@@ -1593,7 +1593,7 @@ boolean shop_floor_obj;
impact_drop(otmp, x, y, 0);
newsym(x, y);
}
return (TRUE);
return TRUE;
}
void

View File

@@ -1,6 +1,6 @@
/* 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 */
@@ -387,18 +387,20 @@ void
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);
@@ -419,9 +421,9 @@ light_source *ls;
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) {
@@ -467,7 +469,7 @@ struct obj *src, *dest;
boolean
any_light_source()
{
return light_base != (light_source *) 0;
return (boolean) (light_base != (light_source *) 0);
}
/*
@@ -483,18 +485,17 @@ int x, y;
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;
@@ -523,8 +524,9 @@ boolean
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 */
@@ -604,21 +606,21 @@ struct obj *obj;
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;
@@ -697,14 +699,15 @@ wiz_light_sources()
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);
}

View File

@@ -1,4 +1,4 @@
/* 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. */
@@ -21,18 +21,16 @@ STATIC_DCL struct mkroom *FDECL(pos_to_room, (XCHAR_P, XCHAR_P));
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));
@@ -62,7 +60,7 @@ const genericptr vy;
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 */
}
@@ -186,7 +184,7 @@ boolean is_room;
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;
@@ -204,7 +202,7 @@ 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;
@@ -384,10 +382,10 @@ register struct mkroom *aroom;
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;
@@ -404,15 +402,16 @@ register int type;
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 */
@@ -463,10 +462,11 @@ int *dy, *xx, *yy;
}
*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 */
@@ -484,12 +484,12 @@ makeniche(trap_type)
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)
@@ -542,13 +542,13 @@ int trap_type;
}
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);
@@ -578,8 +578,8 @@ makevtele()
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;
@@ -587,16 +587,17 @@ clear_level_structures()
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;
@@ -876,9 +877,9 @@ skip0:
}
/*
* 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
@@ -1014,19 +1015,21 @@ mklev()
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) */
@@ -1069,7 +1072,7 @@ topologize(croom) register struct mkroom *croom;
/* 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
@@ -1213,9 +1216,9 @@ register xchar x, y;
/* 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);
@@ -1223,8 +1226,8 @@ register xchar x, y;
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?");
@@ -1238,17 +1241,17 @@ boolean
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;
@@ -1401,11 +1404,10 @@ struct mkroom *croom;
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;
@@ -1430,7 +1432,7 @@ register struct mkroom *croom;
STATIC_OVL void
mksink(croom)
register struct mkroom *croom;
struct mkroom *croom;
{
coord m;
register int tryct = 0;
@@ -1450,7 +1452,7 @@ register struct mkroom *croom;
STATIC_OVL void
mkaltar(croom)
register struct mkroom *croom;
struct mkroom *croom;
{
coord m;
register int tryct = 0;
@@ -1518,6 +1520,7 @@ struct mkroom *croom;
/* 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.
@@ -1623,9 +1626,8 @@ int dist;
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 */

View File

@@ -1,4 +1,4 @@
/* 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. */
@@ -186,7 +186,7 @@ int otyp;
boolean
obj_is_pname(obj)
register struct obj *obj;
struct obj *obj;
{
if (!obj->oartifact || !has_oname(obj))
return FALSE;
@@ -206,7 +206,7 @@ register struct obj *obj;
*/
char *
distant_name(obj, func)
register struct obj *obj;
struct obj *obj;
char *FDECL((*func), (OBJ_P));
{
char *str;
@@ -395,10 +395,13 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
}
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;
}
@@ -415,15 +418,16 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
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);
@@ -518,6 +522,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
break;
case GEM_CLASS: {
const char *rock = (ocl->oc_material == MINERAL) ? "stone" : "gem";
if (!dknown) {
Strcpy(buf, rock);
} else if (!nn) {
@@ -540,6 +545,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
if (obj->otyp == T_SHIRT && program_state.gameover) {
char tmpbuf[BUFSZ];
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf));
}
@@ -615,20 +621,22 @@ struct obj *obj;
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)
@@ -702,12 +710,14 @@ char *prefix;
}
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 *
@@ -719,10 +729,9 @@ boolean with_price;
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) {
@@ -745,18 +754,19 @@ boolean with_price;
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
@@ -919,7 +929,7 @@ boolean with_price;
} 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))) {
@@ -983,7 +993,6 @@ boolean with_price;
Strcat(bp, " (at the ready)");
break;
}
/* Small things and ammo not for a bow */
case RING_CLASS:
case AMULET_CLASS:
@@ -999,7 +1008,8 @@ boolean with_price;
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);
@@ -1258,8 +1268,8 @@ struct obj *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;
@@ -1382,7 +1392,8 @@ char *
An(str)
const char *str;
{
register char *tmp = an(str);
char *tmp = an(str);
*tmp = highc(*tmp);
return tmp;
}
@@ -1411,10 +1422,10 @@ const char *str;
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 ");
@@ -1444,7 +1455,8 @@ char *
The(str)
const char *str;
{
register char *tmp = the(str);
char *tmp = the(str);
*tmp = highc(*tmp);
return tmp;
}
@@ -1452,17 +1464,16 @@ const char *str;
/* 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));
@@ -1487,7 +1498,6 @@ const char *verb;
s = strncat(outbuf, s, space_left);
}
return s;
}
@@ -1506,8 +1516,8 @@ const char *verb;
/* 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));
@@ -1521,9 +1531,9 @@ register const char *verb;
/* 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;
@@ -1664,8 +1674,8 @@ static const char wrpsym[] = { WAND_CLASS, RING_CLASS, POTION_CLASS,
/* 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;
@@ -2127,8 +2137,8 @@ const char *oldstr;
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;
@@ -2144,14 +2154,14 @@ const char *oldstr;
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;
@@ -2159,10 +2169,11 @@ const char *oldstr;
/* 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;
}
@@ -2273,7 +2284,7 @@ boolean retry_inverted; /* optional extra "of" handling */
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
@@ -3360,8 +3371,7 @@ typfnd:
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;
@@ -3558,16 +3568,16 @@ helm_simple_name(helmet)
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";
}

View File

@@ -1,5 +1,5 @@
/* 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"
@@ -119,14 +119,14 @@ struct obj *obj;
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
@@ -174,8 +174,8 @@ boolean seal;
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;
@@ -232,25 +232,24 @@ struct obj *obj; /* quest artifact; possibly null if carrying Amulet */
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)
@@ -259,11 +258,11 @@ chat_with_leader()
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);
@@ -271,6 +270,7 @@ chat_with_leader()
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))
@@ -303,7 +303,7 @@ chat_with_leader()
void
leader_speaks(mtmp)
register struct monst *mtmp;
struct monst *mtmp;
{
/* maybe you attacked leader? */
if (!mtmp->mpeaceful) {
@@ -325,7 +325,7 @@ register struct monst *mtmp;
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++);
@@ -356,7 +356,7 @@ nemesis_speaks()
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
@@ -365,7 +365,7 @@ chat_with_guardian()
STATIC_OVL void
prisoner_speaks(mtmp)
register struct monst *mtmp;
struct monst *mtmp;
{
if (mtmp->data == &mons[PM_PRISONER]
&& (mtmp->mstrategy & STRAT_WAITMASK)) {
@@ -407,7 +407,7 @@ register struct monst *mtmp;
void
quest_talk(mtmp)
register struct monst *mtmp;
struct monst *mtmp;
{
if (mtmp->m_id == Qstat(leader_m_id)) {
leader_speaks(mtmp);
@@ -430,8 +430,8 @@ quest_stat_check(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*/

View File

@@ -1,5 +1,5 @@
/* 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"
@@ -48,48 +48,47 @@ STATIC_DCL const char *FDECL(spelltypemnemonic, (int));
*
* 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 */
@@ -730,7 +729,7 @@ cast_protection()
/* 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
@@ -1016,15 +1015,24 @@ boolean atme;
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);
@@ -1208,8 +1216,8 @@ losespells()
/* 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);
@@ -1224,12 +1232,12 @@ losespells()
* 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",
@@ -1264,10 +1272,10 @@ const genericptr vptr2;
/*
* 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,
@@ -1334,8 +1342,8 @@ sortspells()
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));
@@ -1417,8 +1425,8 @@ dovspell()
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();