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
+49 -48
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -29,12 +29,12 @@ rm_waslit()
register xchar x, y; register xchar x, y;
if (levl[u.ux][u.uy].typ == ROOM && levl[u.ux][u.uy].waslit) 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 (x = u.ux - 2; x < u.ux + 3; x++)
for (y = u.uy - 1; y < u.uy + 2; y++) for (y = u.uy - 1; y < u.uy + 2; y++)
if (isok(x, y) && levl[x][y].waslit) if (isok(x, y) && levl[x][y].waslit)
return (TRUE); return TRUE;
return (FALSE); return FALSE;
} }
/* Change level topology. Messes with vision tables and ignores things like /* Change level topology. Messes with vision tables and ignores things like
@@ -76,9 +76,8 @@ boolean waslit, rockit;
if (waslit) if (waslit)
lev->waslit = (rockit ? FALSE : TRUE); lev->waslit = (rockit ? FALSE : TRUE);
lev->horizontal = FALSE; lev->horizontal = FALSE;
viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) /* short-circuit vision recalc */
: /* short-circuit vision recalc */ viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
COULD_SEE;
lev->typ = (rockit ? STONE : ROOM); lev->typ = (rockit ? STONE : ROOM);
if (dist >= 3) if (dist >= 3)
impossible("mkcavepos called with dist %d", dist); impossible("mkcavepos called with dist %d", dist);
@@ -196,25 +195,25 @@ int x, y;
pline_The("ladder resists your effort."); pline_The("ladder resists your effort.");
} else if (verbose) } else if (verbose)
pline_The("stairs are too hard to %s.", verb); pline_The("stairs are too hard to %s.", verb);
return (FALSE); return FALSE;
} else if (IS_THRONE(levl[x][y].typ) && madeby != BY_OBJECT) { } else if (IS_THRONE(levl[x][y].typ) && madeby != BY_OBJECT) {
if (verbose) if (verbose)
pline_The("throne is too hard to break apart."); pline_The("throne is too hard to break apart.");
return (FALSE); return FALSE;
} else if (IS_ALTAR(levl[x][y].typ) } else if (IS_ALTAR(levl[x][y].typ)
&& (madeby != BY_OBJECT || Is_astralevel(&u.uz) && (madeby != BY_OBJECT || Is_astralevel(&u.uz)
|| Is_sanctum(&u.uz))) { || Is_sanctum(&u.uz))) {
if (verbose) if (verbose)
pline_The("altar is too hard to break apart."); pline_The("altar is too hard to break apart.");
return (FALSE); return FALSE;
} else if (Is_airlevel(&u.uz)) { } else if (Is_airlevel(&u.uz)) {
if (verbose) if (verbose)
You("cannot %s thin air.", verb); You("cannot %s thin air.", verb);
return (FALSE); return FALSE;
} else if (Is_waterlevel(&u.uz)) { } else if (Is_waterlevel(&u.uz)) {
if (verbose) if (verbose)
pline_The("water splashes and subsides."); pline_The("water splashes and subsides.");
return (FALSE); return FALSE;
} else if ((IS_ROCK(levl[x][y].typ) && levl[x][y].typ != SDOOR } else if ((IS_ROCK(levl[x][y].typ) && levl[x][y].typ != SDOOR
&& (levl[x][y].wall_info & W_NONDIGGABLE) != 0) && (levl[x][y].wall_info & W_NONDIGGABLE) != 0)
|| (ttmp || (ttmp
@@ -223,11 +222,11 @@ int x, y;
|| (!Can_dig_down(&u.uz) && !levl[x][y].candig)))) { || (!Can_dig_down(&u.uz) && !levl[x][y].candig)))) {
if (verbose) if (verbose)
pline_The("%s here is too hard to %s.", surface(x, y), verb); pline_The("%s here is too hard to %s.", surface(x, y), verb);
return (FALSE); return FALSE;
} else if (sobj_at(BOULDER, x, y)) { } else if (sobj_at(BOULDER, x, y)) {
if (verbose) if (verbose)
There("isn't enough room to %s here.", verb); There("isn't enough room to %s here.", verb);
return (FALSE); return FALSE;
} else if (madeby == BY_OBJECT } else if (madeby == BY_OBJECT
/* the block against existing traps is mainly to /* the block against existing traps is mainly to
prevent broken wands from turning holes into pits */ prevent broken wands from turning holes into pits */
@@ -235,7 +234,7 @@ int x, y;
/* digging by player handles pools separately */ /* digging by player handles pools separately */
return FALSE; return FALSE;
} }
return (TRUE); return TRUE;
} }
STATIC_OVL int STATIC_OVL int
@@ -253,22 +252,22 @@ dig(VOID_ARGS)
|| !on_level(&context.digging.level, &u.uz) || !on_level(&context.digging.level, &u.uz)
|| ((context.digging.down ? (dpx != u.ux || dpy != u.uy) || ((context.digging.down ? (dpx != u.ux || dpy != u.uy)
: (distu(dpx, dpy) > 2)))) : (distu(dpx, dpy) > 2))))
return (0); return 0;
if (context.digging.down) { if (context.digging.down) {
if (!dig_check(BY_YOU, TRUE, u.ux, u.uy)) if (!dig_check(BY_YOU, TRUE, u.ux, u.uy))
return (0); return 0;
} else { /* !context.digging.down */ } else { /* !context.digging.down */
if (IS_TREE(lev->typ) && !may_dig(dpx, dpy) if (IS_TREE(lev->typ) && !may_dig(dpx, dpy)
&& dig_typ(uwep, dpx, dpy) == DIGTYP_TREE) { && dig_typ(uwep, dpx, dpy) == DIGTYP_TREE) {
pline("This tree seems to be petrified."); pline("This tree seems to be petrified.");
return (0); return 0;
} }
if (IS_ROCK(lev->typ) && !may_dig(dpx, dpy) if (IS_ROCK(lev->typ) && !may_dig(dpx, dpy)
&& dig_typ(uwep, dpx, dpy) == DIGTYP_ROCK) { && dig_typ(uwep, dpx, dpy) == DIGTYP_ROCK) {
pline("This %s is too hard to %s.", pline("This %s is too hard to %s.",
is_db_wall(dpx, dpy) ? "drawbridge" : "wall", verb); is_db_wall(dpx, dpy) ? "drawbridge" : "wall", verb);
return (0); return 0;
} }
} }
if (Fumbling && !rn2(3)) { if (Fumbling && !rn2(3)) {
@@ -295,7 +294,7 @@ dig(VOID_ARGS)
Your("swing misses its mark."); Your("swing misses its mark.");
break; break;
} }
return (0); return 0;
} }
context.digging.effort += context.digging.effort +=
@@ -309,13 +308,13 @@ dig(VOID_ARGS)
(void) dighole(FALSE, FALSE, (coord *) 0); (void) dighole(FALSE, FALSE, (coord *) 0);
(void) memset((genericptr_t) &context.digging, 0, (void) memset((genericptr_t) &context.digging, 0,
sizeof context.digging); sizeof context.digging);
return (0); /* done with digging */ return 0; /* done with digging */
} }
if (context.digging.effort <= 50 if (context.digging.effort <= 50
|| (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT || (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT
|| ttmp->ttyp == SPIKED_PIT))) { || ttmp->ttyp == SPIKED_PIT))) {
return (1); return 1;
} else if (ttmp && (ttmp->ttyp == LANDMINE } else if (ttmp && (ttmp->ttyp == LANDMINE
|| (ttmp->ttyp == BEAR_TRAP && !u.utrap))) { || (ttmp->ttyp == BEAR_TRAP && !u.utrap))) {
/* digging onto a set object trap triggers it; /* digging onto a set object trap triggers it;
@@ -359,7 +358,7 @@ dig(VOID_ARGS)
context.digging.level.dnum = 0; context.digging.level.dnum = 0;
context.digging.level.dlevel = -1; context.digging.level.dlevel = -1;
} }
return (0); return 0;
} }
if (context.digging.effort > 100) { if (context.digging.effort > 100) {
@@ -434,7 +433,7 @@ dig(VOID_ARGS)
if (!(lev->doormask & D_TRAPPED)) if (!(lev->doormask & D_TRAPPED))
lev->doormask = D_BROKEN; lev->doormask = D_BROKEN;
} else } else
return (0); /* statue or boulder got taken */ return 0; /* statue or boulder got taken */
if (!does_block(dpx, dpy, &levl[dpx][dpy])) if (!does_block(dpx, dpy, &levl[dpx][dpy]))
unblock_point(dpx, dpy); /* vision: can see through */ unblock_point(dpx, dpy); /* vision: can see through */
@@ -472,7 +471,7 @@ dig(VOID_ARGS)
context.digging.quiet = FALSE; context.digging.quiet = FALSE;
context.digging.level.dnum = 0; context.digging.level.dnum = 0;
context.digging.level.dlevel = -1; context.digging.level.dlevel = -1;
return (0); return 0;
} else { /* not enough effort has been spent yet */ } else { /* not enough effort has been spent yet */
static const char *const d_target[6] = { "", "rock", "statue", static const char *const d_target[6] = { "", "rock", "statue",
"boulder", "door", "tree" }; "boulder", "door", "tree" };
@@ -482,18 +481,18 @@ dig(VOID_ARGS)
if (*in_rooms(dpx, dpy, SHOPBASE)) { if (*in_rooms(dpx, dpy, SHOPBASE)) {
pline("This %s seems too hard to %s.", pline("This %s seems too hard to %s.",
IS_DOOR(lev->typ) ? "door" : "wall", verb); IS_DOOR(lev->typ) ? "door" : "wall", verb);
return (0); return 0;
} }
} else if (dig_target == DIGTYP_UNDIGGABLE } else if (dig_target == DIGTYP_UNDIGGABLE
|| (dig_target == DIGTYP_ROCK && !IS_ROCK(lev->typ))) || (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) { if (!did_dig_msg) {
You("hit the %s with all your might.", d_target[dig_target]); You("hit the %s with all your might.", d_target[dig_target]);
did_dig_msg = TRUE; did_dig_msg = TRUE;
} }
} }
return (1); return 1;
} }
/* When will hole be finished? Very rough indication used by shopkeeper. */ /* When will hole be finished? Very rough indication used by shopkeeper. */
@@ -501,7 +500,7 @@ int
holetime() holetime()
{ {
if (occupation != dig || !*u.ushops) if (occupation != dig || !*u.ushops)
return (-1); return -1;
return ((250 - context.digging.effort) / 20); return ((250 - context.digging.effort) / 20);
} }
@@ -1006,9 +1005,9 @@ struct obj *obj;
*dsp = 0; *dsp = 0;
Sprintf(qbuf, "In what direction do you want to %s? [%s]", verb, dirsyms); Sprintf(qbuf, "In what direction do you want to %s? [%s]", verb, dirsyms);
if (!getdir(qbuf)) 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 */ /* 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"; const char *verbing = ispick ? "digging" : "chopping";
if (u.uswallow && attack(u.ustuck)) { if (u.uswallow && attack(u.ustuck)) {
; /* return(1) */ ; /* return 1 */
} else if (Underwater) { } else if (Underwater) {
pline("Turbulence torpedoes your %s attempts.", verbing); pline("Turbulence torpedoes your %s attempts.", verbing);
} else if (u.dz < 0) { } else if (u.dz < 0) {
@@ -1046,7 +1045,7 @@ struct obj *obj;
Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp])); Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp]));
losehp(Maybe_Half_Phys(dam), buf, KILLED_BY); losehp(Maybe_Half_Phys(dam), buf, KILLED_BY);
context.botl = 1; context.botl = 1;
return (1); return 1;
} else if (u.dz == 0) { } else if (u.dz == 0) {
if (Stunned || (Confusion && !rn2(5))) if (Stunned || (Confusion && !rn2(5)))
confdir(); confdir();
@@ -1054,11 +1053,11 @@ struct obj *obj;
ry = u.uy + u.dy; ry = u.uy + u.dy;
if (!isok(rx, ry)) { if (!isok(rx, ry)) {
pline("Clash!"); pline("Clash!");
return (1); return 1;
} }
lev = &levl[rx][ry]; lev = &levl[rx][ry];
if (MON_AT(rx, ry) && attack(m_at(rx, ry))) if (MON_AT(rx, ry) && attack(m_at(rx, ry)))
return (1); return 1;
dig_target = dig_typ(obj, rx, ry); dig_target = dig_typ(obj, rx, ry);
if (dig_target == DIGTYP_UNDIGGABLE) { if (dig_target == DIGTYP_UNDIGGABLE) {
/* ACCESSIBLE or POOL */ /* ACCESSIBLE or POOL */
@@ -1189,7 +1188,7 @@ struct obj *obj;
did_dig_msg = FALSE; did_dig_msg = FALSE;
set_occupation(dig, verbing, 0); set_occupation(dig, verbing, 0);
} }
return (1); return 1;
} }
/* /*
@@ -1679,10 +1678,11 @@ pit_flow(trap, filltyp)
struct trap *trap; struct trap *trap;
schar filltyp; schar filltyp;
{ {
int idx;
if (trap && (filltyp != ROOM) if (trap && (filltyp != ROOM)
&& (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) { && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
struct trap t; struct trap t;
int idx;
t = *trap; t = *trap;
levl[trap->tx][trap->ty].typ = filltyp; levl[trap->tx][trap->ty].typ = filltyp;
liquid_flow(trap->tx, trap->ty, filltyp, trap, liquid_flow(trap->tx, trap->ty, filltyp, trap,
@@ -1693,6 +1693,7 @@ schar filltyp;
if (t.conjoined & (1 << idx)) { if (t.conjoined & (1 << idx)) {
int x, y; int x, y;
struct trap *t2; struct trap *t2;
x = t.tx + xdir[idx]; x = t.tx + xdir[idx];
y = t.ty + ydir[idx]; y = t.ty + ydir[idx];
t2 = t_at(x, y); t2 = t_at(x, y);
@@ -1701,7 +1702,6 @@ schar filltyp;
* called deltrap() which cleaned up the * called deltrap() which cleaned up the
* conjoined fields on both pits. * conjoined fields on both pits.
*/ */
if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8)))) if (t2 && (t2->conjoined & (1 << ((idx + 4) % 8))))
#endif #endif
/* recursion */ /* recursion */
@@ -1823,7 +1823,7 @@ boolean *dealloced;
* completely different. * completely different.
*/ */
if (otmp == uchain || obj_resists(otmp, 0, 0)) if (otmp == uchain || obj_resists(otmp, 0, 0))
return (otmp2); return otmp2;
if (otmp->otyp == LEASH && otmp->leashmon != 0) if (otmp->otyp == LEASH && otmp->leashmon != 0)
o_unleash(otmp); o_unleash(otmp);
@@ -1839,7 +1839,7 @@ boolean *dealloced;
if (dealloced) if (dealloced)
*dealloced = TRUE; *dealloced = TRUE;
obfree(otmp, (struct obj *) 0); obfree(otmp, (struct obj *) 0);
return (otmp2); return otmp2;
} }
/* /*
* Start a rot on organic material. Not corpses -- they * Start a rot on organic material. Not corpses -- they
@@ -1851,16 +1851,17 @@ boolean *dealloced;
&& !obj_resists(otmp, 5, 95)) { && !obj_resists(otmp, 5, 95)) {
(void) start_timer((under_ice ? 0L : 250L) + (long) rnd(250), (void) start_timer((under_ice ? 0L : 250L) + (long) rnd(250),
TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp)); TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp));
}
#if 0 #if 0
/* rusting of buried metal not yet implemented */ /* rusting of buried metal not yet implemented */
else if (is_rustprone(otmp)) { } else if (is_rustprone(otmp)) {
(void) start_timer((long)rnd(otmp->otyp == HEAVY_IRON_BALL ? 1500 : 250), (void) start_timer((long) rnd((otmp->otyp == HEAVY_IRON_BALL)
? 1500
: 250),
TIMER_OBJECT, RUST_METAL, obj_to_any(otmp)); TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
}
#endif #endif
}
add_to_buried(otmp); add_to_buried(otmp);
return (otmp2); return otmp2;
} }
void void
@@ -1872,7 +1873,7 @@ int x, y;
if (level.objects[x][y] != (struct obj *) 0) if (level.objects[x][y] != (struct obj *) 0)
debugpline2("bury_objs: at <%d,%d>", x, y); debugpline2("bury_objs: at <%d,%d>", x, y);
for (otmp = level.objects[x][y]; otmp; otmp = otmp2) 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 */ /* don't expect any engravings here, but just in case */
del_engr_at(x, y); del_engr_at(x, y);
@@ -1933,7 +1934,7 @@ long timeout UNUSED;
/* Everything which can be held in a container can also be /* Everything which can be held in a container can also be
buried, so bury_an_obj's use of obj_extract_self insures buried, so bury_an_obj's use of obj_extract_self insures
that Has_contents(obj) will eventually become false. */ 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); obj_extract_self(obj);
obfree(obj, (struct obj *) 0); obfree(obj, (struct obj *) 0);
@@ -1945,7 +1946,7 @@ long timeout UNUSED;
void void
rot_corpse(arg, timeout) rot_corpse(arg, timeout)
anything *arg; anything *arg;
long timeout; /* unused */ long timeout;
{ {
xchar x = 0, y = 0; xchar x = 0, y = 0;
struct obj *obj = arg->a_obj; struct obj *obj = arg->a_obj;
+36 -36
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. */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -144,7 +144,7 @@ xchar x, y;
mon = 0; /* don't kick after all */ mon = 0; /* don't kick after all */
context.forcefight = save_forcefight; context.forcefight = save_forcefight;
} }
return (boolean)(mon != 0); return (boolean) (mon != 0);
} }
STATIC_OVL void STATIC_OVL void
@@ -507,7 +507,7 @@ xchar x, y;
if (Fumbling && !rn2(3)) { if (Fumbling && !rn2(3)) {
Your("clumsy kick missed."); Your("clumsy kick missed.");
return (1); return 1;
} }
if (!uarmf && kickedobj->otyp == CORPSE if (!uarmf && kickedobj->otyp == CORPSE
@@ -601,7 +601,7 @@ xchar x, y;
breakchestlock(kickedobj, FALSE); breakchestlock(kickedobj, FALSE);
if (otrp) if (otrp)
(void) chest_trap(kickedobj, LEG, FALSE); (void) chest_trap(kickedobj, LEG, FALSE);
return (1); return 1;
} }
} else { } else {
if (!rn2(3) || (martial() && !rn2(2))) { if (!rn2(3) || (martial() && !rn2(2))) {
@@ -609,11 +609,11 @@ xchar x, y;
kickedobj->lknown = 1; kickedobj->lknown = 1;
if (otrp) if (otrp)
(void) chest_trap(kickedobj, LEG, FALSE); (void) chest_trap(kickedobj, LEG, FALSE);
return (1); return 1;
} }
} }
if (range < 2) if (range < 2)
return (1); return 1;
/* else let it fall through to the next cases... */ /* else let it fall through to the next cases... */
} }
@@ -675,9 +675,9 @@ xchar x, y;
&& kickedobj->ocarry == mon) && kickedobj->ocarry == mon)
return 1; /* alert shk caught it */ return 1; /* alert shk caught it */
notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
if (isgold ? ghitm(mon, kickedobj) : /* caught? */ if (isgold ? ghitm(mon, kickedobj) /* caught? */
thitmonst(mon, kickedobj)) /* hit && used up? */ : thitmonst(mon, kickedobj)) /* hit && used up? */
return (1); return 1;
} }
/* the object might have fallen down a hole; /* the object might have fallen down a hole;
@@ -702,7 +702,7 @@ xchar x, y;
place_object(kickedobj, bhitpos.x, bhitpos.y); place_object(kickedobj, bhitpos.x, bhitpos.y);
stackobj(kickedobj); stackobj(kickedobj);
newsym(kickedobj->ox, kickedobj->oy); newsym(kickedobj->ox, kickedobj->oy);
return (1); return 1;
} }
/* cause of death if kicking kills kicker */ /* cause of death if kicking kills kicker */
@@ -816,9 +816,9 @@ dokick()
} }
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
if (!u.dx && !u.dy) if (!u.dx && !u.dy)
return (0); return 0;
x = u.ux + u.dx; x = u.ux + u.dx;
y = u.uy + u.dy; y = u.uy + u.dy;
@@ -843,7 +843,7 @@ dokick()
Your("feeble kick has no effect."); Your("feeble kick has no effect.");
break; break;
} }
return (1); return 1;
} else if (u.utrap && u.utraptype == TT_PIT) { } else if (u.utrap && u.utraptype == TT_PIT) {
/* must be Passes_walls */ /* must be Passes_walls */
You("kick at the side of the pit."); You("kick at the side of the pit.");
@@ -862,7 +862,7 @@ dokick()
&& !IS_DOOR(levl[xx][yy].typ) && !IS_DOOR(levl[xx][yy].typ)
&& (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) { && (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) {
You("have nothing to brace yourself against."); You("have nothing to brace yourself against.");
return (0); return 0;
} }
} }
@@ -934,7 +934,7 @@ dokick()
range = 1; range = 1;
hurtle(-u.dx, -u.dy, range, TRUE); hurtle(-u.dx, -u.dy, range, TRUE);
} }
return (1); return 1;
} }
if (glyph_is_invisible(levl[x][y].glyph)) { if (glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y); unmap_object(x, y);
@@ -951,7 +951,7 @@ dokick()
if (kick_object(x, y)) { if (kick_object(x, y)) {
if (Is_airlevel(&u.uz)) if (Is_airlevel(&u.uz))
hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */ hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
return (1); return 1;
} }
goto ouch; goto ouch;
} }
@@ -980,7 +980,7 @@ dokick()
if (maploc->doormask == D_ISOPEN if (maploc->doormask == D_ISOPEN
|| maploc->doormask == D_NODOOR) || maploc->doormask == D_NODOOR)
unblock_point(x, y); /* vision */ unblock_point(x, y); /* vision */
return (1); return 1;
} else } else
goto ouch; goto ouch;
} }
@@ -994,7 +994,7 @@ dokick()
else else
newsym(x, y); newsym(x, y);
unblock_point(x, y); /* vision */ unblock_point(x, y); /* vision */
return (1); return 1;
} else } else
goto ouch; goto ouch;
} }
@@ -1013,7 +1013,7 @@ dokick()
newsym(x, y); newsym(x, y);
} }
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
return (1); return 1;
} else if (Luck > 0 && !rn2(3) && !maploc->looted) { } else if (Luck > 0 && !rn2(3) && !maploc->looted) {
(void) mkgold((long) rn1(201, 300), x, y); (void) mkgold((long) rn1(201, 300), x, y);
i = Luck + 1; i = Luck + 1;
@@ -1031,11 +1031,11 @@ dokick()
} }
/* prevent endless milking */ /* prevent endless milking */
maploc->looted = T_LOOTED; maploc->looted = T_LOOTED;
return (1); return 1;
} else if (!rn2(4)) { } else if (!rn2(4)) {
if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) { if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
fall_through(FALSE); fall_through(FALSE);
return (1); return 1;
} else } else
goto ouch; goto ouch;
} }
@@ -1049,7 +1049,7 @@ dokick()
goto ouch; goto ouch;
altar_wrath(x, y); altar_wrath(x, y);
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
return (1); return 1;
} }
if (IS_FOUNTAIN(maploc->typ)) { if (IS_FOUNTAIN(maploc->typ)) {
if (Levitation) if (Levitation)
@@ -1064,7 +1064,7 @@ dokick()
/* could cause short-lived fumbling here */ /* could cause short-lived fumbling here */
} }
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
return (1); return 1;
} }
if (IS_GRAVE(maploc->typ)) { if (IS_GRAVE(maploc->typ)) {
if (Levitation) if (Levitation)
@@ -1121,7 +1121,7 @@ dokick()
exercise(A_WIS, TRUE); /* discovered a new food source! */ exercise(A_WIS, TRUE); /* discovered a new food source! */
newsym(x, y); newsym(x, y);
maploc->looted |= TREE_LOOTED; maploc->looted |= TREE_LOOTED;
return (1); return 1;
} else if (!(maploc->looted & TREE_SWARM)) { } else if (!(maploc->looted & TREE_SWARM)) {
int cnt = rnl(4) + 2; int cnt = rnl(4) + 2;
int made = 0; int made = 0;
@@ -1139,7 +1139,7 @@ dokick()
else else
You("smell stale honey."); You("smell stale honey.");
maploc->looted |= TREE_SWARM; maploc->looted |= TREE_SWARM;
return (1); return 1;
} }
goto ouch; goto ouch;
} }
@@ -1157,7 +1157,7 @@ dokick()
else else
pline("Klunk!"); pline("Klunk!");
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
return (1); return 1;
} else if (!(maploc->looted & S_LPUDDING) && !rn2(3) } else if (!(maploc->looted & S_LPUDDING) && !rn2(3)
&& !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { && !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) {
if (Blind) if (Blind)
@@ -1169,7 +1169,7 @@ dokick()
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
newsym(x, y); newsym(x, y);
maploc->looted |= S_LPUDDING; maploc->looted |= S_LPUDDING;
return (1); return 1;
} else if (!(maploc->looted & S_LDWASHER) && !rn2(3) } else if (!(maploc->looted & S_LDWASHER) && !rn2(3)
&& !(mvitals[washerndx].mvflags & G_GONE)) { && !(mvitals[washerndx].mvflags & G_GONE)) {
/* can't resist... */ /* can't resist... */
@@ -1178,7 +1178,7 @@ dokick()
newsym(x, y); newsym(x, y);
maploc->looted |= S_LDWASHER; maploc->looted |= S_LDWASHER;
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
return (1); return 1;
} else if (!rn2(3)) { } else if (!rn2(3)) {
pline("Flupp! %s.", pline("Flupp! %s.",
(Blind ? "You hear a sloshing sound" (Blind ? "You hear a sloshing sound"
@@ -1192,7 +1192,7 @@ dokick()
exercise(A_WIS, TRUE); /* a discovery! */ exercise(A_WIS, TRUE); /* a discovery! */
maploc->looted |= S_LRING; maploc->looted |= S_LRING;
} }
return (1); return 1;
} }
goto ouch; goto ouch;
} }
@@ -1220,7 +1220,7 @@ dokick()
losehp(Maybe_Half_Phys(dmg), kickstr(buf), KILLED_BY); losehp(Maybe_Half_Phys(dmg), kickstr(buf), KILLED_BY);
if (Is_airlevel(&u.uz) || Levitation) if (Is_airlevel(&u.uz) || Levitation)
hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */ hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
return (1); return 1;
} }
goto dumb; goto dumb;
} }
@@ -1310,7 +1310,7 @@ dokick()
} }
} }
} }
return (1); return 1;
} }
STATIC_OVL void STATIC_OVL void
@@ -1489,12 +1489,12 @@ boolean shop_floor_obj;
long n = 0L; long n = 0L;
if (!otmp) if (!otmp)
return (FALSE); return FALSE;
if ((toloc = down_gate(x, y)) == MIGR_NOWHERE) if ((toloc = down_gate(x, y)) == MIGR_NOWHERE)
return (FALSE); return FALSE;
drop_to(&cc, toloc); drop_to(&cc, toloc);
if (!cc.y) if (!cc.y)
return (FALSE); return FALSE;
/* objects other than attached iron ball always fall down ladder, /* objects other than attached iron ball always fall down ladder,
but have a chance of staying otherwise */ but have a chance of staying otherwise */
@@ -1526,7 +1526,7 @@ boolean shop_floor_obj;
if (nodrop) { if (nodrop) {
if (impact) if (impact)
impact_drop(otmp, x, y, 0); impact_drop(otmp, x, y, 0);
return (FALSE); return FALSE;
} }
if (unpaid || shop_floor_obj) { if (unpaid || shop_floor_obj) {
@@ -1593,7 +1593,7 @@ boolean shop_floor_obj;
impact_drop(otmp, x, y, 0); impact_drop(otmp, x, y, 0);
newsym(x, y); newsym(x, y);
} }
return (TRUE); return TRUE;
} }
void void
+18 -15
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 light.c $NHDT-Date: 1432512770 2015/05/25 00:12:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */ /* 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 */ /* Copyright (c) Dean Luick, 1994 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -387,18 +387,20 @@ void
light_sources_sanity_check() light_sources_sanity_check()
{ {
light_source *ls; light_source *ls;
struct monst *mtmp;
struct obj *otmp;
unsigned int auint; unsigned int auint;
for (ls = light_base; ls; ls = ls->next) { for (ls = light_base; ls; ls = ls->next) {
if (!ls->id.a_monst) if (!ls->id.a_monst)
panic("insane light source: no id!"); panic("insane light source: no id!");
if (ls->type == LS_OBJECT) { 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; auint = otmp->o_id;
if (find_oid(auint) != otmp) if (find_oid(auint) != otmp)
panic("insane light source: can't find obj #%u!", auint); panic("insane light source: can't find obj #%u!", auint);
} else if (ls->type == LS_MONSTER) { } 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; auint = mtmp->m_id;
if (find_mid(auint, FM_EVERYWHERE) != mtmp) if (find_mid(auint, FM_EVERYWHERE) != mtmp)
panic("insane light source: can't find mon #%u!", auint); panic("insane light source: can't find mon #%u!", auint);
@@ -419,9 +421,9 @@ light_source *ls;
struct monst *mtmp; struct monst *mtmp;
if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) { 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)); bwrite(fd, (genericptr_t) ls, sizeof(light_source));
else { } else {
/* replace object pointer with id for write, then put back */ /* replace object pointer with id for write, then put back */
arg_save = ls->id; arg_save = ls->id;
if (ls->type == LS_OBJECT) { if (ls->type == LS_OBJECT) {
@@ -467,7 +469,7 @@ struct obj *src, *dest;
boolean boolean
any_light_source() any_light_source()
{ {
return light_base != (light_source *) 0; return (boolean) (light_base != (light_source *) 0);
} }
/* /*
@@ -483,9 +485,9 @@ int x, y;
for (ls = light_base; ls; ls = ls->next) for (ls = light_base; ls; ls = ls->next)
/* /*
Is this position check valid??? Can I assume that the positions * Is this position check valid??? Can I assume that the positions
will always be correct because the objects would have been * will always be correct because the objects would have been
updated with the last vision update? [Is that recent enough???] * updated with the last vision update? [Is that recent enough???]
*/ */
if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) { if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
obj = ls->id.a_obj; obj = ls->id.a_obj;
@@ -493,8 +495,7 @@ int x, y;
/* The only way to snuff Sunsword is to unwield it. Darkness /* The only way to snuff Sunsword is to unwield it. Darkness
* scrolls won't affect it. (If we got here because it was * scrolls won't affect it. (If we got here because it was
* dropped or thrown inside a monster, this won't matter * dropped or thrown inside a monster, this won't matter
* anyway * anyway because it will go out when dropped.)
* because it will go out when dropped.)
*/ */
if (artifact_light(obj)) if (artifact_light(obj))
continue; continue;
@@ -523,7 +524,8 @@ boolean
obj_is_burning(obj) obj_is_burning(obj)
struct obj *obj; struct obj *obj;
{ {
return (obj->lamplit && (obj->otyp == MAGIC_LAMP || ignitable(obj) return (boolean) (obj->lamplit && (obj->otyp == MAGIC_LAMP
|| ignitable(obj)
|| artifact_light(obj))); || artifact_light(obj)));
} }
@@ -701,10 +703,11 @@ wiz_light_sources()
: ls->type == LS_MONSTER : ls->type == LS_MONSTER
? (mon_is_local(ls->id.a_monst) ? (mon_is_local(ls->id.a_monst)
? "mon" ? "mon"
: (ls->id.a_monst == &youmonst) ? "you" : (ls->id.a_monst == &youmonst)
? "you"
/* migrating monster */
: "<m>") : "<m>")
: /* migrating monster */ : "???"),
"???"),
fmt_ptr(ls->id.a_void)); fmt_ptr(ls->id.a_void));
putstr(win, 0, buf); putstr(win, 0, buf);
} }
+60 -58
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -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 boolean FDECL(place_niche, (struct mkroom *, int *, int *, int *));
STATIC_DCL void FDECL(makeniche, (int)); STATIC_DCL void FDECL(makeniche, (int));
STATIC_DCL void NDECL(make_niches); STATIC_DCL void NDECL(make_niches);
STATIC_PTR int FDECL(CFDECLSPEC do_comp, (const genericptr,
STATIC_PTR int FDECL(CFDECLSPEC do_comp, const genericptr));
(const genericptr, const genericptr));
STATIC_DCL void FDECL(dosdoor, (XCHAR_P, XCHAR_P, struct mkroom *, int)); 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(join, (int, int, BOOLEAN_P));
STATIC_DCL void FDECL(do_room_or_subroom, STATIC_DCL void FDECL(do_room_or_subroom, (struct mkroom *, int, int,
(struct mkroom *, int, int, int, int, BOOLEAN_P, int, int, BOOLEAN_P,
SCHAR_P, BOOLEAN_P, BOOLEAN_P)); SCHAR_P, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL void NDECL(makerooms); STATIC_DCL void NDECL(makerooms);
STATIC_DCL void FDECL(finddpos, STATIC_DCL void FDECL(finddpos, (coord *, XCHAR_P, XCHAR_P,
(coord *, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P)); XCHAR_P, XCHAR_P));
STATIC_DCL void FDECL(mkinvpos, (XCHAR_P, XCHAR_P, int)); STATIC_DCL void FDECL(mkinvpos, (XCHAR_P, XCHAR_P, int));
STATIC_DCL void FDECL(mk_knox_portal, (XCHAR_P, XCHAR_P)); STATIC_DCL void FDECL(mk_knox_portal, (XCHAR_P, XCHAR_P));
@@ -62,7 +60,7 @@ const genericptr vy;
x = (const struct mkroom *) vx; x = (const struct mkroom *) vx;
y = (const struct mkroom *) vy; y = (const struct mkroom *) vy;
if (x->lx < y->lx) if (x->lx < y->lx)
return (-1); return -1;
return (x->lx > y->lx); return (x->lx > y->lx);
#endif /* LINT */ #endif /* LINT */
} }
@@ -186,7 +184,7 @@ boolean is_room;
void void
add_room(lowx, lowy, hix, hiy, lit, rtype, special) add_room(lowx, lowy, hix, hiy, lit, rtype, special)
register int lowx, lowy, hix, hiy; int lowx, lowy, hix, hiy;
boolean lit; boolean lit;
schar rtype; schar rtype;
boolean special; boolean special;
@@ -204,7 +202,7 @@ boolean special;
void void
add_subroom(proom, lowx, lowy, hix, hiy, lit, rtype, special) add_subroom(proom, lowx, lowy, hix, hiy, lit, rtype, special)
struct mkroom *proom; struct mkroom *proom;
register int lowx, lowy, hix, hiy; int lowx, lowy, hix, hiy;
boolean lit; boolean lit;
schar rtype; schar rtype;
boolean special; boolean special;
@@ -384,10 +382,10 @@ register struct mkroom *aroom;
STATIC_OVL void STATIC_OVL void
dosdoor(x, y, aroom, type) dosdoor(x, y, aroom, type)
register xchar x, y; register xchar x, y;
register struct mkroom *aroom; struct mkroom *aroom;
register int type; 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 */ if (!IS_WALL(levl[x][y].typ)) /* avoid SDOORs on already made doors */
type = DOOR; type = DOOR;
@@ -404,7 +402,7 @@ register int type;
if (levl[x][y].doormask != D_ISOPEN && !shdoor if (levl[x][y].doormask != D_ISOPEN && !shdoor
&& level_difficulty() >= 5 && !rn2(25)) && level_difficulty() >= 5 && !rn2(25))
levl[x][y].doormask |= D_TRAPPED; levl[x][y].doormask |= D_TRAPPED;
} else } else {
#ifdef STUPID #ifdef STUPID
if (shdoor) if (shdoor)
levl[x][y].doormask = D_ISOPEN; levl[x][y].doormask = D_ISOPEN;
@@ -413,6 +411,7 @@ register int type;
#else #else
levl[x][y].doormask = (shdoor ? D_ISOPEN : D_NODOOR); levl[x][y].doormask = (shdoor ? D_ISOPEN : D_NODOOR);
#endif #endif
}
/* also done in roguecorr(); doing it here first prevents /* also done in roguecorr(); doing it here first prevents
making mimics in place of trapped doors on rogue level */ making mimics in place of trapped doors on rogue level */
@@ -463,10 +462,11 @@ int *dy, *xx, *yy;
} }
*xx = dd.x; *xx = dd.x;
*yy = dd.y; *yy = dd.y;
return ((boolean)( return (boolean) ((isok(*xx, *yy + *dy)
(isok(*xx, *yy + *dy) && levl[*xx][*yy + *dy].typ == STONE) && levl[*xx][*yy + *dy].typ == STONE)
&& (isok(*xx, *yy - *dy) && !IS_POOL(levl[*xx][*yy - *dy].typ) && (isok(*xx, *yy - *dy)
&& !IS_FURNITURE(levl[*xx][*yy - *dy].typ)))); && !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 */ /* 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; int trap_type;
{ {
register struct mkroom *aroom; register struct mkroom *aroom;
register struct rm *rm; struct rm *rm;
register int vct = 8; int vct = 8;
int dy, xx, yy; int dy, xx, yy;
register struct trap *ttmp; struct trap *ttmp;
if (doorindex < DOORMAX) if (doorindex < DOORMAX) {
while (vct--) { while (vct--) {
aroom = &rooms[rn2(nroom)]; aroom = &rooms[rn2(nroom)];
if (aroom->rtype != OROOM) if (aroom->rtype != OROOM)
@@ -542,13 +542,13 @@ int trap_type;
} }
return; return;
} }
}
} }
STATIC_OVL void STATIC_OVL void
make_niches() 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), boolean ltptr = (!level.flags.noteleport && dep > 15),
vamp = (dep > 5 && dep < 25); vamp = (dep > 5 && dep < 25);
@@ -578,8 +578,8 @@ makevtele()
STATIC_OVL void STATIC_OVL void
clear_level_structures() clear_level_structures()
{ {
static struct rm zerorm = { cmap_to_glyph(S_stone), 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, 0, 0 };
register int x, y; register int x, y;
register struct rm *lev; register struct rm *lev;
@@ -587,16 +587,17 @@ clear_level_structures()
lev = &levl[x][0]; lev = &levl[x][0];
for (y = 0; y < ROWNO; y++) { for (y = 0; y < ROWNO; y++) {
*lev++ = zerorm; *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.objects[x][y] = (struct obj *) 0;
level.monsters[x][y] = (struct monst *) 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.objlist = (struct obj *) 0;
level.buriedobjlist = (struct obj *) 0; level.buriedobjlist = (struct obj *) 0;
level.monlist = (struct monst *) 0; level.monlist = (struct monst *) 0;
@@ -1014,19 +1015,21 @@ mklev()
void void
#ifdef SPECIALIZATION #ifdef SPECIALIZATION
topologize(croom, do_ordinary) register struct mkroom *croom; topologize(croom, do_ordinary)
struct mkroom *croom;
boolean do_ordinary; boolean do_ordinary;
#else #else
topologize(croom) register struct mkroom *croom; topologize(croom)
struct mkroom *croom;
#endif #endif
{ {
register int x, y, roomno = (int) ((croom - rooms) + ROOMOFFSET); register int x, y, roomno = (int) ((croom - rooms) + ROOMOFFSET);
register int lowx = croom->lx, lowy = croom->ly; int lowx = croom->lx, lowy = croom->ly;
register int hix = croom->hx, hiy = croom->hy; int hix = croom->hx, hiy = croom->hy;
#ifdef SPECIALIZATION #ifdef SPECIALIZATION
register schar rtype = croom->rtype; schar rtype = croom->rtype;
#endif #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 */ /* 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) */ /* also skip if this is non-rectangular (it _must_ be done already) */
@@ -1069,7 +1072,7 @@ topologize(croom) register struct mkroom *croom;
/* subrooms */ /* subrooms */
for (subindex = 0; subindex < nsubrooms; subindex++) for (subindex = 0; subindex < nsubrooms; subindex++)
#ifdef SPECIALIZATION #ifdef SPECIALIZATION
topologize(croom->sbrooms[subindex], (rtype != OROOM)); topologize(croom->sbrooms[subindex], (boolean) (rtype != OROOM));
#else #else
topologize(croom->sbrooms[subindex]); topologize(croom->sbrooms[subindex]);
#endif #endif
@@ -1213,9 +1216,9 @@ register xchar x, y;
/* see whether it is allowable to create a door at [x,y] */ /* see whether it is allowable to create a door at [x,y] */
int int
okdoor(x, y) 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) return ((levl[x][y].typ == HWALL || levl[x][y].typ == VWALL)
&& doorindex < DOORMAX && !near_door); && doorindex < DOORMAX && !near_door);
@@ -1223,8 +1226,8 @@ register xchar x, y;
void void
dodoor(x, y, aroom) dodoor(x, y, aroom)
register int x, y; int x, y;
register struct mkroom *aroom; struct mkroom *aroom;
{ {
if (doorindex >= DOORMAX) { if (doorindex >= DOORMAX) {
impossible("DOORMAX exceeded?"); impossible("DOORMAX exceeded?");
@@ -1238,17 +1241,17 @@ boolean
occupied(x, y) occupied(x, y)
register xchar 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) || 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) */ /* make a trap somewhere (in croom if mazeflag = 0 && !tm) */
/* if tm != null, make trap at that location */ /* if tm != null, make trap at that location */
void void
mktrap(num, mazeflag, croom, tm) mktrap(num, mazeflag, croom, tm)
register int num, mazeflag; int num, mazeflag;
register struct mkroom *croom; struct mkroom *croom;
coord *tm; coord *tm;
{ {
register int kind; register int kind;
@@ -1401,11 +1404,10 @@ struct mkroom *croom;
levl[x][y].ladder = up ? LA_UP : LA_DOWN; levl[x][y].ladder = up ? LA_UP : LA_DOWN;
} }
STATIC_OVL STATIC_OVL void
void
mkfount(mazeflag, croom) mkfount(mazeflag, croom)
register int mazeflag; int mazeflag;
register struct mkroom *croom; struct mkroom *croom;
{ {
coord m; coord m;
register int tryct = 0; register int tryct = 0;
@@ -1430,7 +1432,7 @@ register struct mkroom *croom;
STATIC_OVL void STATIC_OVL void
mksink(croom) mksink(croom)
register struct mkroom *croom; struct mkroom *croom;
{ {
coord m; coord m;
register int tryct = 0; register int tryct = 0;
@@ -1450,7 +1452,7 @@ register struct mkroom *croom;
STATIC_OVL void STATIC_OVL void
mkaltar(croom) mkaltar(croom)
register struct mkroom *croom; struct mkroom *croom;
{ {
coord m; coord m;
register int tryct = 0; register int tryct = 0;
@@ -1518,6 +1520,7 @@ struct mkroom *croom;
/* maze levels have slightly different constraints from normal levels */ /* maze levels have slightly different constraints from normal levels */
#define x_maze_min 2 #define x_maze_min 2
#define y_maze_min 2 #define y_maze_min 2
/* /*
* Major level transmutation: add a set of stairs (to the Sanctum) after * 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. * an earthquake that leaves behind a a new topology, centered at inv_pos.
@@ -1623,9 +1626,8 @@ int dist;
lev->lit = TRUE; lev->lit = TRUE;
lev->waslit = TRUE; lev->waslit = TRUE;
lev->horizontal = FALSE; lev->horizontal = FALSE;
viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) /* short-circuit vision recalc */
: /* short-circuit vision recalc */ viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
COULD_SEE;
switch (dist) { switch (dist) {
case 1: /* fire traps */ case 1: /* fire traps */
+64 -54
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -186,7 +186,7 @@ int otyp;
boolean boolean
obj_is_pname(obj) obj_is_pname(obj)
register struct obj *obj; struct obj *obj;
{ {
if (!obj->oartifact || !has_oname(obj)) if (!obj->oartifact || !has_oname(obj))
return FALSE; return FALSE;
@@ -206,7 +206,7 @@ register struct obj *obj;
*/ */
char * char *
distant_name(obj, func) distant_name(obj, func)
register struct obj *obj; struct obj *obj;
char *FDECL((*func), (OBJ_P)); char *FDECL((*func), (OBJ_P));
{ {
char *str; char *str;
@@ -395,10 +395,13 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
} }
if (Is_pudding(obj)) { if (Is_pudding(obj)) {
Sprintf(buf, "%s%s", Sprintf(buf, "%s%s",
obj->owt < 100 (obj->owt < 100)
? "small " ? "small "
: obj->owt > 500 ? "very large " : (obj->owt > 500)
: obj->owt > 300 ? "large " : "", ? "very large "
: (obj->owt > 300)
? "large "
: "",
actualn); actualn);
break; break;
} }
@@ -422,7 +425,8 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
? "" ? ""
: the_unique_pm(&mons[omndx]) : the_unique_pm(&mons[omndx])
? "the " ? "the "
: index(vowels, *mons[omndx].mname) ? "an " : index(vowels, *mons[omndx].mname)
? "an "
: "a ", : "a ",
mons[omndx].mname); mons[omndx].mname);
else else
@@ -518,6 +522,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
break; break;
case GEM_CLASS: { case GEM_CLASS: {
const char *rock = (ocl->oc_material == MINERAL) ? "stone" : "gem"; const char *rock = (ocl->oc_material == MINERAL) ? "stone" : "gem";
if (!dknown) { if (!dknown) {
Strcpy(buf, rock); Strcpy(buf, rock);
} else if (!nn) { } else if (!nn) {
@@ -540,6 +545,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
if (obj->otyp == T_SHIRT && program_state.gameover) { if (obj->otyp == T_SHIRT && program_state.gameover) {
char tmpbuf[BUFSZ]; char tmpbuf[BUFSZ];
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf)); 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) { if (m_shot.n > 1 && m_shot.o == obj->otyp) {
/* copy xname's result so that we can reuse its return buffer */ /* copy xname's result so that we can reuse its return buffer */
Strcpy(tmpbuf, onm); 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 Nth arrow"; value will eventually be passed to an() or
The(), both of which correctly handle this "the " prefix */ The(), both of which correctly handle this "the " prefix */
Sprintf(onm, "the %d%s %s", m_shot.i, ordin(m_shot.i), tmpbuf); Sprintf(onm, "the %d%s %s", m_shot.i, ordin(m_shot.i), tmpbuf);
} }
return onm; return onm;
} }
/* used for naming "the unique_item" instead of "a unique_item" */ /* used for naming "the unique_item" instead of "a unique_item" */
boolean boolean
the_unique_obj(obj) the_unique_obj(obj)
register struct obj *obj; struct obj *obj;
{ {
boolean known = (obj->known || iflags.override_ID); boolean known = (obj->known || iflags.override_ID);
if (!obj->dknown && !iflags.override_ID) if (!obj->dknown && !iflags.override_ID)
return FALSE; return FALSE;
else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known) else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known)
@@ -705,9 +713,11 @@ char *prefix;
? "fixed " ? "fixed "
: is_rustprone(obj) : is_rustprone(obj)
? "rustproof " ? "rustproof "
: is_corrodeable(obj) ? "corrodeproof " : is_corrodeable(obj)
: /* "stainless"? */ ? "corrodeproof " /* "stainless"? */
is_flammable(obj) ? "fireproof " : ""); : is_flammable(obj)
? "fireproof "
: "");
} }
static char * static char *
@@ -719,10 +729,9 @@ boolean with_price;
boolean known, cknown, bknown, lknown; boolean known, cknown, bknown, lknown;
int omndx = obj->corpsenm; int omndx = obj->corpsenm;
char prefix[PREFIX]; char prefix[PREFIX];
char tmpbuf[PREFIX + 1]; char tmpbuf[PREFIX + 1]; /* for when we have to add something at
/* when we have to add something at the start of prefix instead of the the start of prefix instead of the
* end (Strcat is used on the end) end (Strcat is used on the end) */
*/
register char *bp = xname(obj); register char *bp = xname(obj);
if (iflags.override_ID) { if (iflags.override_ID) {
@@ -745,18 +754,19 @@ boolean with_price;
ispoisoned = TRUE; ispoisoned = TRUE;
} }
if (obj->quan != 1L) if (obj->quan != 1L) {
Sprintf(prefix, "%ld ", obj->quan); Sprintf(prefix, "%ld ", obj->quan);
else if (obj->otyp == CORPSE) } else if (obj->otyp == CORPSE) {
/* skip article prefix for corpses [else corpse_xname() /* skip article prefix for corpses [else corpse_xname()
would have to be taught how to strip it off again] */ would have to be taught how to strip it off again] */
*prefix = '\0'; *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)) if (!strncmpi(bp, "the ", 4))
bp += 4; bp += 4;
Strcpy(prefix, "the "); Strcpy(prefix, "the ");
} else } else {
Strcpy(prefix, "a "); Strcpy(prefix, "a ");
}
/* "empty" goes at the beginning, but item count goes at the end */ /* "empty" goes at the beginning, but item count goes at the end */
if (cknown if (cknown
@@ -983,7 +993,6 @@ boolean with_price;
Strcat(bp, " (at the ready)"); Strcat(bp, " (at the ready)");
break; break;
} }
/* Small things and ammo not for a bow */ /* Small things and ammo not for a bow */
case RING_CLASS: case RING_CLASS:
case AMULET_CLASS: case AMULET_CLASS:
@@ -999,7 +1008,8 @@ boolean with_price;
if (!iflags.suppress_price && is_unpaid(obj)) { if (!iflags.suppress_price && is_unpaid(obj)) {
long quotedprice = unpaid_cost(obj, TRUE); 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)); quotedprice, currency(quotedprice));
} else if (with_price) { } else if (with_price) {
long price = get_cost_of_shop_item(obj); long price = get_cost_of_shop_item(obj);
@@ -1382,7 +1392,8 @@ char *
An(str) An(str)
const char *str; const char *str;
{ {
register char *tmp = an(str); char *tmp = an(str);
*tmp = highc(*tmp); *tmp = highc(*tmp);
return tmp; return tmp;
} }
@@ -1411,10 +1422,10 @@ const char *str;
int l; int l;
/* some objects have capitalized adjectives in their names */ /* some objects have capitalized adjectives in their names */
if (((tmp = rindex(str, ' ')) || (tmp = rindex(str, '-'))) if (((tmp = rindex(str, ' ')) != 0 || (tmp = rindex(str, '-')) != 0)
&& (tmp[1] < 'A' || tmp[1] > 'Z')) && (tmp[1] < 'A' || tmp[1] > 'Z')) {
insert_the = TRUE; 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" */ /* it needs an article if the name contains "of" */
tmp = strstri(str, " of "); tmp = strstri(str, " of ");
named = strstri(str, " named "); named = strstri(str, " named ");
@@ -1444,7 +1455,8 @@ char *
The(str) The(str)
const char *str; const char *str;
{ {
register char *tmp = the(str); char *tmp = the(str);
*tmp = highc(*tmp); *tmp = highc(*tmp);
return tmp; return tmp;
} }
@@ -1452,17 +1464,16 @@ const char *str;
/* returns "count cxname(otmp)" or just cxname(otmp) if count == 1 */ /* returns "count cxname(otmp)" or just cxname(otmp) if count == 1 */
char * char *
aobjnam(otmp, verb) aobjnam(otmp, verb)
register struct obj *otmp; struct obj *otmp;
register const char *verb; const char *verb;
{ {
register char *bp = cxname(otmp);
char prefix[PREFIX]; char prefix[PREFIX];
char *bp = cxname(otmp);
if (otmp->quan != 1L) { if (otmp->quan != 1L) {
Sprintf(prefix, "%ld ", otmp->quan); Sprintf(prefix, "%ld ", otmp->quan);
bp = strprepend(bp, prefix); bp = strprepend(bp, prefix);
} }
if (verb) { if (verb) {
Strcat(bp, " "); Strcat(bp, " ");
Strcat(bp, otense(otmp, verb)); Strcat(bp, otense(otmp, verb));
@@ -1487,7 +1498,6 @@ const char *verb;
s = strncat(outbuf, s, space_left); s = strncat(outbuf, s, space_left);
} }
return s; return s;
} }
@@ -1506,8 +1516,8 @@ const char *verb;
/* like aobjnam, but prepend "The", not count, and use xname */ /* like aobjnam, but prepend "The", not count, and use xname */
char * char *
Tobjnam(otmp, verb) Tobjnam(otmp, verb)
register struct obj *otmp; struct obj *otmp;
register const char *verb; const char *verb;
{ {
char *bp = The(xname(otmp)); char *bp = The(xname(otmp));
@@ -1521,9 +1531,9 @@ register const char *verb;
/* capitalized variant of doname() */ /* capitalized variant of doname() */
char * char *
Doname2(obj) Doname2(obj)
register struct obj *obj; struct obj *obj;
{ {
register char *s = doname(obj); char *s = doname(obj);
*s = highc(*s); *s = highc(*s);
return 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 */ /* return form of the verb (input plural) if xname(otmp) were the subject */
char * char *
otense(otmp, verb) otense(otmp, verb)
register struct obj *otmp; struct obj *otmp;
register const char *verb; const char *verb;
{ {
char *buf; char *buf;
@@ -2127,8 +2137,8 @@ const char *oldstr;
if (p >= bp + 3 && lowc(p[-3]) == 'i') { /* "ies" */ if (p >= bp + 3 && lowc(p[-3]) == 'i') { /* "ies" */
if (!BSTRCMPI(bp, p - 7, "cookies") if (!BSTRCMPI(bp, p - 7, "cookies")
|| !BSTRCMPI(bp, p - 4, "pies") || !BSTRCMPI(bp, p - 4, "pies")
|| !BSTRCMPI(bp, p - 5, "mbies") || /* zombie */ || !BSTRCMPI(bp, p - 5, "mbies") /* zombie */
!BSTRCMPI(bp, p - 5, "yries")) /* valkyrie */ || !BSTRCMPI(bp, p - 5, "yries")) /* valkyrie */
goto mins; goto mins;
Strcasecpy(p - 3, "y"); /* ies -> y */ Strcasecpy(p - 3, "y"); /* ies -> y */
goto bottom; goto bottom;
@@ -2144,14 +2154,14 @@ const char *oldstr;
goto bottom; goto bottom;
} }
/* note: nurses, axes but boxes, wumpuses */ /* note: nurses, axes but boxes, wumpuses */
if (!BSTRCMPI(bp, p - 4, "eses") || !BSTRCMPI(bp, p - 4, "oxes") if (!BSTRCMPI(bp, p - 4, "eses")
|| /* boxes, foxes */ || !BSTRCMPI(bp, p - 4, "oxes") /* boxes, foxes */
!BSTRCMPI(bp, p - 4, "nxes") || /* lynxes */ || !BSTRCMPI(bp, p - 4, "nxes") /* lynxes */
!BSTRCMPI(bp, p - 4, "ches") || !BSTRCMPI(bp, p - 4, "uses") || !BSTRCMPI(bp, p - 4, "ches")
|| /* lotuses */ || !BSTRCMPI(bp, p - 4, "uses") /* lotuses */
!BSTRCMPI(bp, p - 4, "sses") || /* priestesses */ || !BSTRCMPI(bp, p - 4, "sses") /* priestesses */
!BSTRCMPI(bp, p - 5, "atoes") || /* tomatoes */ || !BSTRCMPI(bp, p - 5, "atoes") /* tomatoes */
!BSTRCMPI(bp, p - 7, "dingoes") || !BSTRCMPI(bp, p - 7, "dingoes")
|| !BSTRCMPI(bp, p - 7, "Aleaxes")) { || !BSTRCMPI(bp, p - 7, "Aleaxes")) {
*(p - 2) = '\0'; /* drop es */ *(p - 2) = '\0'; /* drop es */
goto bottom; goto bottom;
@@ -2159,10 +2169,11 @@ const char *oldstr;
/* ends in 's' but not 'es' */ /* ends in 's' but not 'es' */
} else if (!BSTRCMPI(bp, p - 2, "us")) { /* lotus, fungus... */ } else if (!BSTRCMPI(bp, p - 2, "us")) { /* lotus, fungus... */
if (BSTRCMPI(bp, p - 6, "tengus") && /* but not these... */ if (BSTRCMPI(bp, p - 6, "tengus") /* but not these... */
BSTRCMPI(bp, p - 7, "hezrous")) && BSTRCMPI(bp, p - 7, "hezrous"))
goto bottom; 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"))) { || (p - 4 == bp && !strcmpi(p - 4, "lens"))) {
goto bottom; goto bottom;
} }
@@ -2273,7 +2284,7 @@ boolean retry_inverted; /* optional extra "of" handling */
return fuzzymatch(buf, o_str, " -", TRUE); return fuzzymatch(buf, o_str, " -", TRUE);
} }
} else if (strstri(o_str, "ability")) { } 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 */ singularize both foo & bar, but now only does so for foo */
/* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */ /* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */
if ((p = strstri(u_str, "abilities")) != 0 if ((p = strstri(u_str, "abilities")) != 0
@@ -3360,8 +3371,7 @@ typfnd:
otmp->spe = ishistoric ? STATUE_HISTORIC : 0; otmp->spe = ishistoric ? STATUE_HISTORIC : 0;
break; break;
case SCALE_MAIL: case SCALE_MAIL:
/* Dragon mail - depends on the order of objects */ /* Dragon mail - depends on the order of objects & dragons. */
/* & dragons. */
if (mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON) if (mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON)
otmp->otyp = GRAY_DRAGON_SCALE_MAIL + mntmp - PM_GRAY_DRAGON; otmp->otyp = GRAY_DRAGON_SCALE_MAIL + mntmp - PM_GRAY_DRAGON;
break; break;
+13 -13
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 quest.c $NHDT-Date: 1432512771 2015/05/25 00:12:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */ /* 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 */ /* Copyright 1991, M. Stephenson */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -119,14 +119,14 @@ struct obj *obj;
boolean boolean
ok_to_quest() ok_to_quest()
{ {
return ((boolean)((Qstat(got_quest) || Qstat(got_thanks))) return (boolean) ((Qstat(got_quest) || Qstat(got_thanks))
&& (is_pure(FALSE) > 0)); && is_pure(FALSE) > 0);
} }
STATIC_OVL boolean STATIC_OVL boolean
not_capable() not_capable()
{ {
return ((boolean)(u.ulevel < MIN_QUEST_LEVEL)); return (boolean) (u.ulevel < MIN_QUEST_LEVEL);
} }
STATIC_OVL int STATIC_OVL int
@@ -174,8 +174,8 @@ boolean seal;
br = dungeon_branch("The Quest"); br = dungeon_branch("The Quest");
dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1; dest = (br->end1.dnum == u.uz.dnum) ? &br->end2 : &br->end1;
portal_flag = u.uevent.qexpelled ? 0 : /* returned via artifact? */ portal_flag = u.uevent.qexpelled ? 0 /* returned via artifact? */
!seal ? 1 : -1; : !seal ? 1 : -1;
schedule_goto(dest, FALSE, FALSE, portal_flag, (char *) 0, (char *) 0); schedule_goto(dest, FALSE, FALSE, portal_flag, (char *) 0, (char *) 0);
if (seal) { /* remove the portal to the quest - sealing it off */ if (seal) { /* remove the portal to the quest - sealing it off */
int reexpelled = u.uevent.qexpelled; int reexpelled = u.uevent.qexpelled;
@@ -247,10 +247,9 @@ chat_with_leader()
/* Rule 2: You've gone back before going for the amulet. */ /* Rule 2: You've gone back before going for the amulet. */
else else
qt_pager(QT_POSTHANKS); qt_pager(QT_POSTHANKS);
}
/* Rule 3: You've got the artifact and are back to return it. */ /* Rule 3: You've got the artifact and are back to return it. */
else if (u.uhave.questart) { } else if (u.uhave.questart) {
struct obj *otmp; struct obj *otmp;
for (otmp = invent; otmp; otmp = otmp->nobj) for (otmp = invent; otmp; otmp = otmp->nobj)
@@ -271,6 +270,7 @@ chat_with_leader()
Qstat(not_ready) = 0; Qstat(not_ready) = 0;
} else } else
qt_pager(QT_NEXTLEADER); qt_pager(QT_NEXTLEADER);
/* the quest leader might have passed through the portal into /* the quest leader might have passed through the portal into
the regular dungeon; none of the remaining make sense there */ the regular dungeon; none of the remaining make sense there */
if (!on_level(&u.uz, &qstart_level)) if (!on_level(&u.uz, &qstart_level))
@@ -303,7 +303,7 @@ chat_with_leader()
void void
leader_speaks(mtmp) leader_speaks(mtmp)
register struct monst *mtmp; struct monst *mtmp;
{ {
/* maybe you attacked leader? */ /* maybe you attacked leader? */
if (!mtmp->mpeaceful) { if (!mtmp->mpeaceful) {
@@ -365,7 +365,7 @@ chat_with_guardian()
STATIC_OVL void STATIC_OVL void
prisoner_speaks(mtmp) prisoner_speaks(mtmp)
register struct monst *mtmp; struct monst *mtmp;
{ {
if (mtmp->data == &mons[PM_PRISONER] if (mtmp->data == &mons[PM_PRISONER]
&& (mtmp->mstrategy & STRAT_WAITMASK)) { && (mtmp->mstrategy & STRAT_WAITMASK)) {
@@ -407,7 +407,7 @@ register struct monst *mtmp;
void void
quest_talk(mtmp) quest_talk(mtmp)
register struct monst *mtmp; struct monst *mtmp;
{ {
if (mtmp->m_id == Qstat(leader_m_id)) { if (mtmp->m_id == Qstat(leader_m_id)) {
leader_speaks(mtmp); leader_speaks(mtmp);
@@ -430,8 +430,8 @@ quest_stat_check(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
if (mtmp->data->msound == MS_NEMESIS) if (mtmp->data->msound == MS_NEMESIS)
Qstat(in_battle) = Qstat(in_battle) = (mtmp->mcanmove && !mtmp->msleeping
(mtmp->mcanmove && !mtmp->msleeping && monnear(mtmp, u.ux, u.uy)); && monnear(mtmp, u.ux, u.uy));
} }
/*quest.c*/ /*quest.c*/
+21 -13
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 spell.c $NHDT-Date: 1445906865 2015/10/27 00:47:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ /* 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 */ /* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -63,8 +63,7 @@ STATIC_DCL const char *FDECL(spelltypemnemonic, (int));
* Wiz are trained mages * Wiz are trained mages
* *
* The arms penalty is lessened for trained fighters Bar, Kni, Ran, * The arms penalty is lessened for trained fighters Bar, Kni, Ran,
* Sam, Val - * Sam, Val -- the penalty is its metal interference, not encumbrance.
* the penalty is its metal interference, not encumbrance.
* The `spelspec' is a single spell which is fundamentally easier * The `spelspec' is a single spell which is fundamentally easier
* for that role to cast. * for that role to cast.
* *
@@ -1016,15 +1015,24 @@ boolean atme;
case SPE_DRAIN_LIFE: case SPE_DRAIN_LIFE:
case SPE_STONE_TO_FLESH: case SPE_STONE_TO_FLESH:
if (!(objects[pseudo->otyp].oc_dir == NODIR)) { if (!(objects[pseudo->otyp].oc_dir == NODIR)) {
if (atme) if (atme) {
u.dx = u.dy = u.dz = 0; u.dx = u.dy = u.dz = 0;
else if (!getdir((char *) 0)) { } else if (!getdir((char *) 0)) {
/* getdir cancelled, re-use previous direction */ /* 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!"); pline_The("magical energy is released!");
} }
if (!u.dx && !u.dy && !u.dz) { if (!u.dx && !u.dy && !u.dz) {
if ((damage = zapyourself(pseudo, TRUE)) != 0) { if ((damage = zapyourself(pseudo, TRUE)) != 0) {
char buf[BUFSZ]; char buf[BUFSZ];
Sprintf(buf, "zapped %sself with a spell", uhim()); Sprintf(buf, "zapped %sself with a spell", uhim());
if (physical_damage) if (physical_damage)
damage = Maybe_Half_Phys(damage); damage = Maybe_Half_Phys(damage);
@@ -1264,10 +1272,10 @@ const genericptr vptr2;
/* /*
* gather up all of the possible parameters except spell name * gather up all of the possible parameters except spell name
* in advance, even though some might not be needed: * in advance, even though some might not be needed:
* indx? = spl_orderindx[] index into spl_book[]; * indx. = spl_orderindx[] index into spl_book[];
* otyp? = spl_book[] index into objects[]; * otyp. = spl_book[] index into objects[];
* levl? = spell level; * levl. = spell level;
* skil? = skill group aka spell class; * skil. = skill group aka spell class.
*/ */
int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2, int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2,
otyp1 = spl_book[indx1].sp_id, otyp2 = spl_book[indx2].sp_id, otyp1 = spl_book[indx1].sp_id, otyp2 = spl_book[indx2].sp_id,
@@ -1334,8 +1342,8 @@ sortspells()
if (!spl_orderindx) { if (!spl_orderindx) {
/* we haven't done any sorting yet; list is in casting order */ /* we haven't done any sorting yet; list is in casting order */
if (spl_sortmode == SORTBY_LETTER || /* default */ if (spl_sortmode == SORTBY_LETTER /* default */
spl_sortmode == SORTRETAINORDER) || spl_sortmode == SORTRETAINORDER)
return; return;
/* allocate enough for full spellbook rather than just N spells */ /* allocate enough for full spellbook rather than just N spells */
spl_orderindx = (int *) alloc(MAXSPELL * sizeof(int)); spl_orderindx = (int *) alloc(MAXSPELL * sizeof(int));
@@ -1417,8 +1425,8 @@ dovspell()
if (spellid(0) == NO_SPELL) { if (spellid(0) == NO_SPELL) {
You("don't know any spells right now."); You("don't know any spells right now.");
} else { } else {
while ( while (dospellmenu("Currently known spells",
dospellmenu("Currently known spells", SPELLMENU_VIEW, &splnum)) { SPELLMENU_VIEW, &splnum)) {
if (splnum == SPELLMENU_SORT) { if (splnum == SPELLMENU_SORT) {
if (spellsortmenu()) if (spellsortmenu())
sortspells(); sortspells();