-/* NetHack 3.6 apply.c $NHDT-Date: 1446369459 2015/11/01 09:17:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.208 $ */
+/* NetHack 3.6 apply.c $NHDT-Date: 1446808436 2015/11/06 11:13:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.210 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
return TRUE;
}
-int jumping_is_magic;
+static int jumping_is_magic;
void
display_jump_positions(state)
tmp_at(DISP_BEAM, cmap_to_glyph(S_goodpos));
} else if (state == 1) {
int x, y, dx, dy;
+
for (dx = -4; dx <= 4; dx++)
for (dy = -4; dy <= 4; dy++) {
x = dx + (int) u.ux;
} else if (!magic && !Jumping) {
You_cant("jump very far.");
return 0;
- /* if steed is immobile, can't do physical jump but can do spell one
- */
+ /* if steed is immobile, can't do physical jump but can do spell one */
} else if (!magic && u.usteed && stucksteed(FALSE)) {
/* stucksteed gave "<steed> won't move" message */
return 0;
if (u.utrap)
switch (u.utraptype) {
case TT_BEARTRAP: {
- register long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
+ long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
+
You("rip yourself free of the bear trap! Ouch!");
losehp(Maybe_Half_Phys(rnd(10)), "jumping out of a bear trap",
KILLED_BY);
int min_range, max_range;
{
struct monst *mtmp;
- struct monst *selmon = NULL;
+ struct monst *selmon = (struct monst *) 0;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (mtmp && !DEADMONSTER(mtmp) && !mtmp->mtame
/* we want this before the explosion instead of at the very end */
pline("A wall of force smashes down around you!");
dmg = d(1 + obj->spe, 6); /* normally 2d12 */
- /*FALLTHRU*/
+ /*FALLTHRU*/
case WAN_CANCELLATION:
case WAN_POLYMORPH:
case WAN_TELEPORTATION:
-/* NetHack 3.6 ball.c $NHDT-Date: 1445301116 2015/10/20 00:31:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.27 $ */
+/* NetHack 3.6 ball.c $NHDT-Date: 1446808438 2015/11/06 11:13:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
* To make this work, we have to mess with the hero's mind. The rules for
* ball&chain are:
*
- * 1. If the hero can see them, fine.
- * 2. If the hero can't see either, it isn't seen.
- * 3. If either is felt it is seen.
- * 4. If either is felt and moved, it disappears.
+ * 1. If the hero can see them, fine.
+ * 2. If the hero can't see either, it isn't seen.
+ * 3. If either is felt it is seen.
+ * 4. If either is felt and moved, it disappears.
*
* If the hero can see, then when a move is done, the ball and chain are
* first picked up, the positions under them are corrected, then they
/*
* from you.h
- * int u.bglyph glyph under the ball
- * int u.cglyph glyph under the chain
- * int u.bc_felt mask for ball/chain being felt
- * #define BC_BALL 0x01 bit mask in u.bc_felt for ball
- * #define BC_CHAIN 0x02 bit mask in u.bc_felt for chain
- * int u.bc_order ball & chain order
+ * int u.bglyph glyph under the ball
+ * int u.cglyph glyph under the chain
+ * int u.bc_felt mask for ball/chain being felt
+ * #define BC_BALL 0x01 bit mask in u.bc_felt for ball
+ * #define BC_CHAIN 0x02 bit mask in u.bc_felt for chain
+ * int u.bc_order ball & chain order
*
* u.bc_felt is also manipulated in display.c and read.c, the others only
* in this file. None of these variables are valid unless the player is
&& !already_in_rock) {
if (allow_drag) {
/* Avoid pathological case *if* not teleporting:
- * 0 0_
+ * 0 0_
* _X move northeast -----> X@
* @
*/
&& dist2(x, y, tempx, tempy) == 1)
SKIP_TO_DRAG;
/* Avoid pathological case *if* not teleporting:
- * 0 0
+ * 0 0
* _X move east -----> X_
- * @ @
+ * @ @
*/
if (dist2(u.ux, u.uy, uball->ox, uball->oy) == 4
&& dist2(x, y, tempx, tempy) == 2)
xchar x, y;
{
if (Blind) {
- u.bc_order = bc_order(); /* get the order */
- /* pick up glyph */
+ /* get the order */
+ u.bc_order = bc_order();
+ /* pick up glyph */
u.bglyph = (u.bc_order) ? u.cglyph : levl[x][y].glyph;
}
uchar dragchance = 3;
/*
- * Assume that the ball falls forward if:
+ * Assume that the ball falls forward if:
*
- * a) the character is wielding it, or
- * b) the character has both hands available to hold it (i.e. is
- * not wielding any weapon), or
- * c) (perhaps) it falls forward out of his non-weapon hand
+ * a) the character is wielding it, or
+ * b) the character has both hands available to hold it (i.e. is
+ * not wielding any weapon), or
+ * c) (perhaps) it falls forward out of his non-weapon hand
*/
-
forward = carried(uball) && (uwep == uball || !uwep || !rn2(3));
if (carried(uball))
-/* NetHack 3.6 display.c $NHDT-Date: 1445301119 2015/10/20 00:31:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.76 $ */
+/* NetHack 3.6 display.c $NHDT-Date: 1446808439 2015/11/06 11:13:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
-/* and Dave Cohrs, 1990. */
+/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
/*
- * THE NEW DISPLAY CODE
+ * THE NEW DISPLAY CODE
*
* The old display code has been broken up into three parts: vision, display,
* and drawing. Vision decides what locations can and cannot be physically
*
* Display rules:
*
- * If the location is in sight, display in order:
- * visible (or sensed) monsters
- * visible objects
- * known traps
- * background
+ * If the location is in sight, display in order:
+ * visible (or sensed) monsters
+ * visible objects
+ * known traps
+ * background
*
- * If the location is out of sight, display in order:
- * sensed monsters (telepathy)
- * memory
+ * If the location is out of sight, display in order:
+ * sensed monsters (telepathy)
+ * memory
*
*
*
*
* Parts of the rm structure that are used:
*
- * typ - What is really there.
- * glyph - What the hero remembers. This will never be a monster.
- * Monsters "float" above this.
- * lit - True if the position is lit. An optimization for
- * lit/unlit rooms.
- * waslit - True if the position was *remembered* as lit.
- * seenv - A vector of bits representing the directions from which the
- * hero has seen this position. The vector's primary use is
- * determining how walls are seen. E.g. a wall sometimes looks
- * like stone on one side, but is seen as a wall from the
- *other.
- * Other uses are for unmapping detected objects and felt
- * locations, where we need to know if the hero has ever
- * seen the location.
- * flags - Additional information for the typ field. Different for
- * each typ.
- * horizontal - Indicates whether the wall or door is horizontal or
- * vertical.
+ * typ - What is really there.
+ * glyph - What the hero remembers. This will never be a monster.
+ * Monsters "float" above this.
+ * lit - True if the position is lit. An optimization for
+ * lit/unlit rooms.
+ * waslit - True if the position was *remembered* as lit.
+ * seenv - A vector of bits representing the directions from which the
+ * hero has seen this position. The vector's primary use is
+ * determining how walls are seen. E.g. a wall sometimes looks
+ * like stone on one side, but is seen as wall from the other.
+ * Other uses are for unmapping detected objects and felt
+ * locations, where we need to know if the hero has ever
+ * seen the location.
+ * flags - Additional information for the typ field. Different for
+ * each typ.
+ * horizontal - Indicates whether the wall or door is horizontal or
+ * vertical.
*/
#include "hack.h"
* The routines map_background(), map_object(), and map_trap() could just
* as easily be:
*
- * map_glyph(x,y,glyph,show)
+ * map_glyph(x,y,glyph,show)
*
* Which is called with the xx_to_glyph() in the call. Then I can get
* rid of 3 routines that don't do very much anyway. And then stop
display_monster(x, y, mon, sightflags, worm_tail)
register xchar x, y; /* display position */
register struct monst *mon; /* monster to display */
-int sightflags; /* 1 if the monster is physically seen */
-/* 2 if detected using Detect_monsters */
-register xchar worm_tail; /* mon is actually a worm tail */
+int sightflags; /* 1 if the monster is physically seen;
+ 2 if detected using Detect_monsters */
+xchar worm_tail; /* mon is actually a worm tail */
{
- register boolean mon_mimic = (mon->m_ap_type != M_AP_NOTHING);
- register int sensed =
- mon_mimic && (Protection_from_shape_changers || sensemon(mon));
+ boolean mon_mimic = (mon->m_ap_type != M_AP_NOTHING);
+ int sensed = (mon_mimic && (Protection_from_shape_changers
+ || sensemon(mon)));
/*
* We must do the mimic check first. If the mimic is mimicing something,
* and the location is in sight, we have to change the hero's memory
}
case M_AP_OBJECT: {
- struct obj obj; /* Make a fake object to send */
- /* to map_object(). */
+ /* Make a fake object to send to map_object(). */
+ struct obj obj;
+
obj = zeroobj;
obj.ox = x;
obj.oy = y;
if (Underwater && !Is_waterlevel(&u.uz) && !is_pool(x, y))
return;
- /* Set the seen vector as if the hero had seen it. It doesn't matter */
- /* if the hero is levitating or not. */
+ /* Set the seen vector as if the hero had seen it.
+ It doesn't matter if the hero is levitating or not. */
set_seenv(lev, u.ux, u.uy, x, y);
if (!can_reach_floor(FALSE)) {
*
* Check (and display) in order:
*
- * + Stone, walls, and closed doors.
- * + Boulders. [see a boulder before a doorway]
- * + Doors.
- * + Room/water positions
- * + Everything else (hallways!)
+ * + Stone, walls, and closed doors.
+ * + Boulders. [see a boulder before a doorway]
+ * + Doors.
+ * + Room/water positions
+ * + Everything else (hallways!)
*/
if (IS_ROCK(lev->typ)
|| (IS_DOOR(lev->typ)
if (lev->typ != ROOM && lev->seenv) {
map_background(x, y, 1);
} else {
- lev->glyph = (flags.dark_room && iflags.use_color && !Is_rogue_level(&u.uz))
+ lev->glyph = (flags.dark_room && iflags.use_color
+ && !Is_rogue_level(&u.uz))
? cmap_to_glyph(S_darkroom)
: (lev->waslit ? cmap_to_glyph(S_room)
: cmap_to_glyph(S_stone));
} else if ((lev->glyph >= cmap_to_glyph(S_stone)
&& lev->glyph < cmap_to_glyph(S_darkroom))
|| glyph_is_invisible(levl[x][y].glyph)) {
- lev->glyph = (flags.dark_room && iflags.use_color && !Is_rogue_level(&u.uz))
+ lev->glyph = (flags.dark_room && iflags.use_color
+ && !Is_rogue_level(&u.uz))
? cmap_to_glyph(S_darkroom)
: (lev->waslit ? cmap_to_glyph(S_room)
: cmap_to_glyph(S_stone));
/* We feel it (I think hallways are the only things left). */
map_background(x, y, 1);
/* Corridors are never felt as lit (unless remembered that way) */
- /* (lit_corridor only). */
+ /* (lit_corridor only). */
if (lev->typ == CORR && lev->glyph == cmap_to_glyph(S_litcorr)
&& !lev->waslit)
show_glyph(x, y, lev->glyph = cmap_to_glyph(S_corr));
/*
* Don't use templit here: E.g.
*
- * lev->waslit = !!(lev->lit || templit(x,y));
+ * lev->waslit = !!(lev->lit || templit(x,y));
*
* Otherwise we have the "light pool" problem, where non-permanently
* lit areas just out of sight stay remembered as lit. They should
display_monster(x, y, mon,
see_it ? PHYSICALLY_SEEN : DETECTED,
worm_tail);
- } else if (mon && mon_warning(mon) && !is_worm_tail(mon))
+ } else if (mon && mon_warning(mon) && !is_worm_tail(mon)) {
display_warning(mon);
- else if (glyph_is_invisible(levl[x][y].glyph))
+ } else if (glyph_is_invisible(levl[x][y].glyph)) {
map_invisible(x, y);
- else
- _map_location(x, y, 1); /* map the location */
+ } else
+ _map_location(x, y, 1); /* map the location */\
}
- }
/* Can't see the location. */
- else {
+ } else {
if (x == u.ux && y == u.uy) {
feel_location(u.ux, u.uy); /* forces an update */
if (canspotself())
display_self();
} else if ((mon = m_at(x, y))
- && ((see_it =
- (tp_sensemon(mon) || MATCH_WARN_OF_MON(mon)
- || (see_with_infrared(mon) && mon_visible(mon))))
+ && ((see_it = (tp_sensemon(mon) || MATCH_WARN_OF_MON(mon)
+ || (see_with_infrared(mon)
+ && mon_visible(mon))))
|| Detect_monsters)) {
/* Monsters are printed every time. */
/* This also gets rid of any invisibility glyph */
- display_monster(x, y, mon, see_it ? 0 : DETECTED, is_worm_tail(mon) ? TRUE : FALSE);
+ display_monster(x, y, mon, see_it ? 0 : DETECTED,
+ is_worm_tail(mon) ? TRUE : FALSE);
} else if ((mon = m_at(x, y)) && mon_warning(mon)
&& !is_worm_tail(mon)) {
display_warning(mon);
* If the location is remembered as being both dark (waslit is false)
* and lit (glyph is a lit room or lit corridor) then it was either:
*
- * (1) A dark location that the hero could see through night
- * vision.
+ * (1) A dark location that the hero could see through night
+ * vision.
*
- * (2) Darkened while out of the hero's sight. This can happen
- * when cursed scroll of light is read.
+ * (2) Darkened while out of the hero's sight. This can happen
+ * when cursed scroll of light is read.
*
* In either case, we have to manually correct the hero's memory to
* match waslit. Deciding when to change waslit is non-trivial.
*
* Note: If flags.lit_corridor is set, then corridors act like room
- * squares. That is, they light up if in night vision range.
- * If flags.lit_corridor is not set, then corridors will
- * remain dark unless lit by a light spell and may darken
- * again, as discussed above.
+ * squares. That is, they light up if in night vision range.
+ * If flags.lit_corridor is not set, then corridors will
+ * remain dark unless lit by a light spell and may darken
+ * again, as discussed above.
*
* These checks and changes must be here and not in back_to_glyph().
* They are dependent on the position being out of sight.
else if (Is_rogue_level(&u.uz)) {
if (lev->glyph == cmap_to_glyph(S_litcorr) && lev->typ == CORR)
show_glyph(x, y, lev->glyph = cmap_to_glyph(S_corr));
- else if (lev->glyph == cmap_to_glyph(S_room) && lev->typ == ROOM && !lev->waslit)
+ else if (lev->glyph == cmap_to_glyph(S_room) && lev->typ == ROOM
+ && !lev->waslit)
show_glyph(x, y, lev->glyph = cmap_to_glyph(S_stone));
else
goto show_mem;
* but explode() wants to delay].
*
* Call:
- * (DISP_BEAM, glyph) open, initialize glyph
- * (DISP_FLASH, glyph) open, initialize glyph
- * (DISP_ALWAYS, glyph) open, initialize glyph
- * (DISP_CHANGE, glyph) change glyph
- * (DISP_END, 0) close & clean up (second argument doesn't
- * matter)
- * (DISP_FREEMEM, 0) only used to prevent memory leak during
- * exit)
- * (x, y) display the glyph at the location
+ * (DISP_BEAM, glyph) open, initialize glyph
+ * (DISP_FLASH, glyph) open, initialize glyph
+ * (DISP_ALWAYS, glyph) open, initialize glyph
+ * (DISP_CHANGE, glyph) change glyph
+ * (DISP_END, 0) close & clean up (second argument doesn't
+ * matter)
+ * (DISP_FREEMEM, 0) only used to prevent memory leak during
+ * exit)
+ * (x, y) display the glyph at the location
*
* DISP_BEAM - Display the given glyph at each location, but do not erase
- * any until the close call.
+ * any until the close call.
* DISP_FLASH - Display the given glyph at each location, but erase the
- * previous location's glyph.
+ * previous location's glyph.
* DISP_ALWAYS- Like DISP_FLASH, but vision is not taken into account.
*/
if (mode == 1 || dela) {
cls();
dela = FALSE;
- }
+
/* delayed full update */
- else if (mode == 2) {
+ } else if (mode == 2) {
dela = TRUE;
return;
- }
+
/* limited update */
- else {
+ } else {
for (y = lasty - 1; y <= lasty + 1; y++)
for (x = lastx - 1; x <= lastx + 1; x++)
if (isok(x, y))
show_glyph(x, y, cmap_to_glyph(S_stone));
}
+
for (x = u.ux - 1; x <= u.ux + 1; x++)
for (y = u.uy - 1; y <= u.uy + 1; y++)
if (isok(x, y) && is_pool(x, y)) {
}
/*
- * under_ground()
+ * under_ground()
*
- * Very restricted display. You can only see yourself.
+ * Very restricted display. You can only see yourself.
*/
void
under_ground(mode)
if (mode == 1 || dela) {
cls();
dela = FALSE;
- }
+
/* delayed full update */
- else if (mode == 2) {
+ } else if (mode == 2) {
dela = TRUE;
return;
- }
+
/* limited update */
- else
+ } else {
newsym(u.ux, u.uy);
+ }
}
/* =========================================================================
/*
* Loop through all of the monsters and update them. Called when:
- * + going blind & telepathic
- * + regaining sight & telepathic
+ * + going blind & telepathic
+ * + regaining sight & telepathic
* + getting and losing infravision
- * + hallucinating
- * + doing a full screen redraw
- * + see invisible times out or a ring of see invisible is taken off
- * + when a potion of see invisible is quaffed or a ring of see
- * invisible is put on
- * + gaining telepathy when blind [givit() in eat.c, pleased() in pray.c]
- * + losing telepathy while blind [xkilled() in mon.c, attrcurse() in
- * sit.c]
+ * + hallucinating
+ * + doing a full screen redraw
+ * + see invisible times out or a ring of see invisible is taken off
+ * + when a potion of see invisible is quaffed or a ring of see
+ * invisible is put on
+ * + gaining telepathy when blind [givit() in eat.c, pleased() in pray.c]
+ * + losing telepathy while blind [xkilled() in mon.c, attrcurse() in
+ * sit.c]
*/
void
see_monsters()
/*
* Loop through all of the object *locations* and update them. Called when
- * + hallucinating.
+ * + hallucinating.
*/
void
see_objects()
int cursor_on_u;
{
/* Prevent infinite loops on errors:
- * flush_screen->print_glyph->impossible->pline->flush_screen
+ * flush_screen->print_glyph->impossible->pline->flush_screen
*/
static boolean flushing = 0;
static boolean delay_flushing = 0;
impossible("swallow_to_glyph: bad swallow location");
loc = S_sw_br;
}
- return ((int) (what_mon(mnum) << 3) | (loc - S_sw_tl))
- + GLYPH_SWALLOW_OFF;
+ return ((int) (what_mon(mnum) << 3) | (loc - S_sw_tl)) + GLYPH_SWALLOW_OFF;
}
/*
* type has four glyphs, one for each of the symbols below. The order of
* the zap symbols [0-3] as defined in rm.h are:
*
- * | S_vbeam ( 0, 1) or ( 0,-1)
- * - S_hbeam ( 1, 0) or (-1, 0)
- * \ S_lslant ( 1, 1) or (-1,-1)
- * / S_rslant (-1, 1) or ( 1,-1)
+ * | S_vbeam ( 0, 1) or ( 0,-1)
+ * - S_hbeam ( 1, 0) or (-1, 0)
+ * \ S_lslant ( 1, 1) or (-1,-1)
+ * / S_rslant (-1, 1) or ( 1,-1)
*/
int
zapdir_to_glyph(dx, dy, beam_type)
int x, y, a, b, c, dd;
{
pline("set_wall_state: %s @ (%d,%d) %s%s%s%s",
- type_to_name(levl[x][y].typ), x, y, a ? "1" : "", b ? "2" : "",
- c ? "3" : "", dd ? "4" : "");
+ type_to_name(levl[x][y].typ), x, y,
+ a ? "1" : "", b ? "2" : "", c ? "3" : "", dd ? "4" : "");
bad_count[levl[x][y].typ]++;
}
#endif /* WA_VERBOSE */
-/* NetHack 3.6 do_name.c $NHDT-Date: 1444617209 2015/10/12 02:33:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.75 $ */
+/* NetHack 3.6 do_name.c $NHDT-Date: 1446808440 2015/11/06 11:14:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* function for getpos() to highlight desired map locations.
* parameter value 0 = initialize, 1 = highlight, 2 = done
*/
-void (*getpos_hilitefunc)(int) = NULL;
+void FDECL((*getpos_hilitefunc), (int)) = (void FDECL((*), (int))) 0;
+
void
getpos_sethilite(f)
-void (*f)(int);
+void FDECL((*f), (int));
{
getpos_hilitefunc = f;
}
|| glyph_to_cmap(k) == S_darkroom
|| glyph_to_cmap(k) == S_corr
|| glyph_to_cmap(k) == S_litcorr)) {
- /* what the hero remembers to be at tx,ty
- */
+ /* what hero remembers to be at tx,ty */
k = glyph_at(tx, ty);
}
if (glyph_is_cmap(k)
{
if (has_oname(obj))
return ONAME(obj);
- else
- return "";
+ return "";
}
/* historical note: this returns a monster pointer because it used to
(void) mungspaces(buf);
if (!*buf) {
if (*str1) { /* had name, so possibly remove from disco[] */
- /* strip name first, for the update_inventory() call
- from undiscover_object() */
+ /* strip name first, for the update_inventory() call
+ from undiscover_object() */
*str1 = (char *) 0;
undiscover_object(obj->otyp);
}
return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] : (const char *) plname;
}
-/* Monster naming functions:
+/*
+ * Monster naming functions:
* x_monnam is the generic monster-naming function.
- * seen unseen detected named
- * mon_nam: the newt it the invisible orc Fido
- * noit_mon_nam:the newt (as if detected) the invisible orc Fido
- * l_monnam: newt it invisible orc dog called
- *fido
- * Monnam: The newt It The invisible orc Fido
- * noit_Monnam: The newt (as if detected) The invisible orc Fido
- * Adjmonnam: The poor newt It The poor invisible orc The poor Fido
- * Amonnam: A newt It An invisible orc Fido
- * a_monnam: a newt it an invisible orc Fido
- * m_monnam: newt xan orc Fido
- * y_monnam: your newt your xan your invisible orc Fido
+ * seen unseen detected named
+ * mon_nam: the newt it the invisible orc Fido
+ * noit_mon_nam:the newt (as if detected) the invisible orc Fido
+ * l_monnam: newt it invisible orc dog called Fido
+ * Monnam: The newt It The invisible orc Fido
+ * noit_Monnam: The newt (as if detected) The invisible orc Fido
+ * Adjmonnam: The poor newt It The poor invisible orc The poor Fido
+ * Amonnam: A newt It An invisible orc Fido
+ * a_monnam: a newt it an invisible orc Fido
+ * m_monnam: newt xan orc Fido
+ * y_monnam: your newt your xan your invisible orc Fido
*/
/* Bug: if the monster is a priest or shopkeeper, not every one of these
if (do_hallu) {
char rnamecode;
char *rname = rndmonnam(&rnamecode);
+
Strcat(buf, rname);
name_at_start = bogon_is_pname(rnamecode);
} else if (has_mname(mtmp)) {
}
} else if (is_mplayer(mdat) && !In_endgame(&u.uz)) {
char pbuf[BUFSZ];
+
Strcpy(pbuf, rank_of((int) mtmp->m_lev, monsndx(mdat),
(boolean) mtmp->female));
Strcat(buf, lcase(pbuf));
Strcpy(buf, buf2);
return buf;
case ARTICLE_A:
- return (an(buf));
+ return an(buf);
case ARTICLE_NONE:
default:
return buf;
char *
l_monnam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
- return (x_monnam(mtmp, ARTICLE_NONE, (char *) 0,
- (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, TRUE));
+ return x_monnam(mtmp, ARTICLE_NONE, (char *) 0,
+ (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, TRUE);
}
char *
mon_nam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
- return (x_monnam(mtmp, ARTICLE_THE, (char *) 0,
- (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE));
+ return x_monnam(mtmp, ARTICLE_THE, (char *) 0,
+ (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE);
}
/* print the name as if mon_nam() was called, but assume that the player
*/
char *
noit_mon_nam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
- return (x_monnam(mtmp, ARTICLE_THE, (char *) 0,
- (has_mname(mtmp)) ? (SUPPRESS_SADDLE | SUPPRESS_IT)
+ return x_monnam(mtmp, ARTICLE_THE, (char *) 0,
+ (has_mname(mtmp)) ? (SUPPRESS_SADDLE | SUPPRESS_IT)
: SUPPRESS_IT,
- FALSE));
+ FALSE);
}
char *
Monnam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
register char *bp = mon_nam(mtmp);
*bp = highc(*bp);
- return (bp);
+ return bp;
}
char *
noit_Monnam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
register char *bp = noit_mon_nam(mtmp);
*bp = highc(*bp);
- return (bp);
+ return bp;
}
/* monster's own name */
char *
Adjmonnam(mtmp, adj)
-register struct monst *mtmp;
-register const char *adj;
+struct monst *mtmp;
+const char *adj;
{
- register char *bp =
- x_monnam(mtmp, ARTICLE_THE, adj,
- (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE);
+ char *bp = x_monnam(mtmp, ARTICLE_THE, adj,
+ has_mname(mtmp) ? SUPPRESS_SADDLE : 0, FALSE);
*bp = highc(*bp);
- return (bp);
+ return bp;
}
char *
a_monnam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
return x_monnam(mtmp, ARTICLE_A, (char *) 0,
- (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE);
+ has_mname(mtmp) ? SUPPRESS_SADDLE : 0, FALSE);
}
char *
Amonnam(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
{
- register char *bp = a_monnam(mtmp);
+ char *bp = a_monnam(mtmp);
*bp = highc(*bp);
- return (bp);
+ return bp;
}
/* used for monster ID by the '/', ';', and 'C' commands to block remote
return mname;
}
-#define BOGUSMONSIZE 100 /* arbitrary */
/* return a random monster name, for hallucination */
char *
rndmonnam(code)
static char buf[BUFSZ];
char *mname;
int name;
+#define BOGUSMONSIZE 100 /* arbitrary */
if (code)
*code = '\0';
mname = strcpy(buf, mons[name].mname);
}
return mname;
-}
#undef BOGUSMONSIZE
+}
/* check bogusmon prefix to decide whether it's a personal name */
boolean
rndcolor()
{
int k = rn2(CLR_MAX);
+
return Hallucination ? hcolor((char *) 0)
- : (k == NO_COLOR) ? "colorless" : c_obj_colors[k];
+ : (k == NO_COLOR) ? "colorless"
+ : c_obj_colors[k];
}
/* Aliases for road-runner nemesis
-/* NetHack 3.6 dog.c $NHDT-Date: 1445301120 2015/10/20 00:32:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.51 $ */
+/* NetHack 3.6 dog.c $NHDT-Date: 1446808440 2015/11/06 11:14:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.52 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
pet_type()
{
if (urole.petnum != NON_PM)
- return (urole.petnum);
+ return urole.petnum;
else if (preferred_pet == 'c')
- return (PM_KITTEN);
+ return PM_KITTEN;
else if (preferred_pet == 'd')
- return (PM_LITTLE_DOG);
+ return PM_LITTLE_DOG;
else
- return (rn2(2) ? PM_KITTEN : PM_LITTLE_DOG);
+ return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG;
}
struct monst *
mtmp = christen_monst(mtmp, petname);
initedog(mtmp);
- return (mtmp);
+ return mtmp;
}
/* record `last move time' for all monsters prior to level save so that
if (pets_only) {
if (!mtmp->mtame)
continue; /* reject non-pets */
- /* don't block pets from accompanying hero's dungeon
- escape or ascension simply due to mundane trifles;
- unlike level change for steed, don't bother trying
- to achieve a normal trap escape first */
+ /* don't block pets from accompanying hero's dungeon
+ escape or ascension simply due to mundane trifles;
+ unlike level change for steed, don't bother trying
+ to achieve a normal trap escape first */
mtmp->mtrapped = 0;
mtmp->meating = 0;
mtmp->msleeping = 0;
boolean carni = carnivorous(mptr), herbi = herbivorous(mptr), starving;
if (is_quest_artifact(obj) || obj_resists(obj, 0, 95))
- return (obj->cursed ? TABU : APPORT);
+ return obj->cursed ? TABU : APPORT;
switch (obj->oclass) {
case FOOD_CLASS:
&& fptr != &mons[PM_LIZARD]
&& fptr != &mons[PM_LICHEN])
? DOGFOOD
- : (starving && !vegan(fptr)) ? ACCFOOD : POISON;
+ : (starving && !vegan(fptr))
+ ? ACCFOOD
+ : POISON;
if (obj->otyp == EGG)
return stale_egg(obj) ? CADAVER : starving ? ACCFOOD : POISON;
return TABU;
case MEAT_RING:
case MEAT_STICK:
case HUGE_CHUNK_OF_MEAT:
- return (carni ? DOGFOOD : MANFOOD);
+ return carni ? DOGFOOD : MANFOOD;
case EGG:
- return (carni ? CADAVER : MANFOOD);
+ return carni ? CADAVER : MANFOOD;
case CORPSE:
if ((peek_at_iced_corpse_age(obj) + 50L <= monstermoves
&& obj->corpsenm != PM_LIZARD && obj->corpsenm != PM_LICHEN
return POISON;
/* turning into slime is preferable to starvation */
else if (fptr == &mons[PM_GREEN_SLIME] && !slimeproof(mon->data))
- return (starving ? ACCFOOD : POISON);
+ return starving ? ACCFOOD : POISON;
else if (vegan(fptr))
- return (herbi ? CADAVER : MANFOOD);
+ return herbi ? CADAVER : MANFOOD;
/* most humanoids will avoid cannibalism unless starving;
arbitrary: elves won't eat other elves even then */
else if (humanoid(mptr) && same_race(mptr, fptr)
&& (!is_undead(mptr) && fptr->mlet != S_KOBOLD
&& fptr->mlet != S_ORC && fptr->mlet != S_OGRE))
- return ((starving && carni && !is_elf(mptr)) ? ACCFOOD
- : TABU);
+ return (starving && carni && !is_elf(mptr)) ? ACCFOOD : TABU;
else
- return (carni ? CADAVER : MANFOOD);
+ return carni ? CADAVER : MANFOOD;
case CLOVE_OF_GARLIC:
- return ((is_undead(mptr) || is_vampshifter(mon))
- ? TABU
- : ((herbi || starving) ? ACCFOOD : MANFOOD));
+ return (is_undead(mptr) || is_vampshifter(mon))
+ ? TABU
+ : (herbi || starving)
+ ? ACCFOOD
+ : MANFOOD;
case TIN:
- return (metallivorous(mptr) ? ACCFOOD : MANFOOD);
+ return metallivorous(mptr) ? ACCFOOD : MANFOOD;
case APPLE:
case CARROT:
- return (herbi ? DOGFOOD : starving ? ACCFOOD : MANFOOD);
+ return herbi ? DOGFOOD : starving ? ACCFOOD : MANFOOD;
case BANANA:
- return ((mptr->mlet == S_YETI)
- ? DOGFOOD
- : ((herbi || starving) ? ACCFOOD : MANFOOD));
+ return (mptr->mlet == S_YETI)
+ ? DOGFOOD
+ : (herbi || starving)
+ ? ACCFOOD
+ : MANFOOD;
default:
if (starving)
return ACCFOOD;
- return (obj->otyp > SLIME_MOLD ? (carni ? ACCFOOD : MANFOOD)
- : (herbi ? ACCFOOD : MANFOOD));
+ return (obj->otyp > SLIME_MOLD) ? (carni ? ACCFOOD : MANFOOD)
+ : (herbi ? ACCFOOD : MANFOOD);
}
default:
if (obj->otyp == AMULET_OF_STRANGULATION
|| obj->otyp == RIN_SLOW_DIGESTION)
return TABU;
if (mon_hates_silver(mon) && objects[obj->otyp].oc_material == SILVER)
- return (TABU);
+ return TABU;
if (mptr == &mons[PM_GELATINOUS_CUBE] && is_organic(obj))
- return (ACCFOOD);
+ return ACCFOOD;
if (metallivorous(mptr) && is_metallic(obj)
&& (is_rustprone(obj) || mptr != &mons[PM_RUST_MONSTER])) {
/* Non-rustproofed ferrous based metals are preferred. */
- return ((is_rustprone(obj) && !obj->oerodeproof) ? DOGFOOD
- : ACCFOOD);
+ return (is_rustprone(obj) && !obj->oerodeproof) ? DOGFOOD
+ : ACCFOOD;
}
- if (!obj->cursed && obj->oclass != BALL_CLASS
+ if (!obj->cursed
+ && obj->oclass != BALL_CLASS
&& obj->oclass != CHAIN_CLASS)
- return (APPORT);
- /* fall into next case */
+ return APPORT;
+ /*FALLTHRU*/
case ROCK_CLASS:
- return (UNDEF);
+ return UNDEF;
}
}
-/* NetHack 3.6 dokick.c $NHDT-Date: 1446191875 2015/10/30 07:57:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.102 $ */
+/* NetHack 3.6 dokick.c $NHDT-Date: 1446808441 2015/11/06 11:14:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
extern boolean notonhead; /* for long worms */
STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P));
-STATIC_DCL boolean
-FDECL(maybe_kick_monster, (struct monst *, XCHAR_P, XCHAR_P));
+STATIC_DCL boolean FDECL(maybe_kick_monster, (struct monst *,
+ XCHAR_P, XCHAR_P));
STATIC_DCL void FDECL(kick_monster, (struct monst *, XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(kick_object, (XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(really_kick_object, (XCHAR_P, XCHAR_P));
if (!noscatter)
(void) scatter(nx, ny, rnd(2), 0, otmp);
} else { /* random location */
- /* set dummy coordinates because there's no
- current position for rloco() to update */
+ /* set dummy coordinates because there's no
+ current position for rloco() to update */
otmp->ox = otmp->oy = 0;
if (rloco(otmp) && !nobreak && breaktest(otmp)) {
/* assume it broke before player arrived, no messages */
-/* NetHack 3.6 dungeon.c $NHDT-Date: 1445301123 2015/10/20 00:32:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
+/* NetHack 3.6 dungeon.c $NHDT-Date: 1446808442 2015/11/06 11:14:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
int n_brs; /* number of tmpbranch entries */
};
-int n_dgns; /* number of dungeons (also used */
- /* in mklev.c and do.c) */
-static branch *branches = (branch *) 0; /* dungeon branch list */
+int n_dgns; /* number of dungeons (also used in mklev.c and do.c) */
+static branch *branches = (branch *) 0; /* dungeon branch list */
+
+mapseen *mapseenchn = (struct mapseen *) 0; /*DUNGEON_OVERVIEW*/
struct lchoice {
int idx;
STATIC_DCL xchar FDECL(dname_to_dnum, (const char *));
STATIC_DCL int FDECL(find_branch, (const char *, struct proto_dungeon *));
STATIC_DCL xchar FDECL(parent_dnum, (const char *, struct proto_dungeon *));
-STATIC_DCL int FDECL(level_range,
- (XCHAR_P, int, int, int, struct proto_dungeon *, int *));
+STATIC_DCL int FDECL(level_range, (XCHAR_P, int, int, int,
+ struct proto_dungeon *, int *));
STATIC_DCL xchar FDECL(parent_dlevel, (const char *, struct proto_dungeon *));
STATIC_DCL int FDECL(correct_branch_type, (struct tmpbranch *));
STATIC_DCL branch *FDECL(add_branch, (int, int, struct proto_dungeon *));
STATIC_DCL void FDECL(add_level, (s_level *));
STATIC_DCL void FDECL(init_level, (int, int, struct proto_dungeon *));
-STATIC_DCL int FDECL(possible_places,
- (int, boolean *, struct proto_dungeon *));
+STATIC_DCL int FDECL(possible_places, (int, boolean *,
+ struct proto_dungeon *));
STATIC_DCL xchar FDECL(pick_level, (boolean *, int));
STATIC_DCL boolean FDECL(place_level, (int, struct proto_dungeon *));
STATIC_DCL boolean FDECL(unplaced_floater, (struct dungeon *));
STATIC_DCL void FDECL(tport_menu, (winid, char *, struct lchoice *, d_level *,
BOOLEAN_P));
STATIC_DCL const char *FDECL(br_string, (int));
-STATIC_DCL void FDECL(print_branch,
- (winid, int, int, int, BOOLEAN_P, struct lchoice *));
-
-mapseen *mapseenchn = (struct mapseen *) 0;
+STATIC_DCL void FDECL(print_branch, (winid, int, int, int, BOOLEAN_P,
+ struct lchoice *));
STATIC_DCL mapseen *FDECL(load_mapseen, (int));
STATIC_DCL void FDECL(save_mapseen, (int, mapseen *));
STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *));
STATIC_DCL void FDECL(print_mapseen, (winid, mapseen *, int, int, BOOLEAN_P));
STATIC_DCL boolean FDECL(interest_mapseen, (mapseen *));
-STATIC_DCL void FDECL(traverse_mapseenchn,
- (BOOLEAN_P, winid, int, int, int *));
+STATIC_DCL void FDECL(traverse_mapseenchn, (BOOLEAN_P, winid,
+ int, int, int *));
STATIC_DCL const char *FDECL(seen_string, (XCHAR_P, const char *));
STATIC_DCL const char *FDECL(br_string2, (branch *));
STATIC_DCL const char *FDECL(endgamelevelname, (char *, int));
*/
for (pdnum = 0; strcmp(pd->tmpdungeon[pdnum].name, s); pdnum++)
if ((i -= pd->tmpdungeon[pdnum].branches) < 0)
- return (pdnum);
+ return pdnum;
panic("parent_dnum: couldn't resolve branch.");
/*NOT REACHED*/
* or dungeon entrance can occupy.
*
* Note: This follows the acouple (instead of the rcouple) rules for a
- * negative random component (randc < 0). These rules are found
- * in dgn_comp.y. The acouple [absolute couple] section says that
- * a negative random component means from the (adjusted) base to the
- * end of the dungeon.
+ * negative random component (randc < 0). These rules are found
+ * in dgn_comp.y. The acouple [absolute couple] section says that
+ * a negative random component means from the (adjusted) base to the
+ * end of the dungeon.
*/
STATIC_OVL int
level_range(dgn, base, randc, chain, pd, adjusted_base)
{ X_GOAL, &nemesis_level },
{ "", (d_level *) 0 } };
-void init_dungeons() /* initialize the "dungeon" structs */
+/* initialize the "dungeon" structs */
+void
+init_dungeons()
{
dlb *dgn_file;
register int i, cl = 0, cb = 0;
/*
* Set the entry level for this dungeon. The pd.tmpdungeon entry
* value means:
- * < 0 from bottom (-1 == bottom level)
- * 0 default (top)
- * > 0 actual level (1 = top)
+ * < 0 from bottom (-1 == bottom level)
+ * 0 default (top)
+ * > 0 actual level (1 = top)
*
* Note that the entry_lev field in the dungeon structure is
* redundant. It is used only here and in print_dungeon().
* Calculate the depth of the top of the dungeon via
* its branch. First, the depth of the entry point:
*
- * depth of branch from "parent" dungeon
- * + -1 or 1 depending on a up or down stair or
- * 0 if portal
+ * depth of branch from "parent" dungeon
+ * + -1 or 1 depending on a up or down stair or
+ * 0 if portal
*
* Followed by the depth of the top of the dungeon:
*
- * - (entry depth - 1)
+ * - (entry depth - 1)
*
* We'll say that portals stay on the same depth.
*/
}
}
/*
- * I hate hardwiring these names. :-(
+ * I hate hardwiring these names. :-(
*/
quest_dnum = dname_to_dnum("The Quest");
sokoban_dnum = dname_to_dnum("Sokoban");
#endif
}
-xchar dunlev(lev) /* return the level number for lev in *this* dungeon */
+/* return the level number for lev in *this* dungeon */
+xchar
+dunlev(lev)
d_level *lev;
{
- return (lev->dlevel);
+ return lev->dlevel;
}
+/* return the lowest level number for *this* dungeon */
xchar
-dunlevs_in_dungeon(lev) /* return the lowest level number for *this* dungeon*/
+dunlevs_in_dungeon(lev)
d_level *lev;
{
- return (dungeons[lev->dnum].num_dunlevs);
+ return dungeons[lev->dnum].num_dunlevs;
}
+/* return the lowest level explored in the game*/
xchar
-deepest_lev_reached(noquest) /* return the lowest level explored in the game*/
+deepest_lev_reached(noquest)
boolean noquest;
{
/* this function is used for three purposes: to provide a factor
if (depth(&tmp) > ret)
ret = depth(&tmp);
}
- return ((xchar) ret);
+ return (xchar) ret;
}
/* return a bookkeeping level number for purpose of comparisons and
- * save/restore */
+ save/restore */
xchar
ledger_no(lev)
d_level *lev;
{
- return ((xchar)(lev->dlevel + dungeons[lev->dnum].ledger_start));
+ return (xchar) (lev->dlevel + dungeons[lev->dnum].ledger_start);
}
/*
xchar
maxledgerno()
{
- return (xchar)(dungeons[n_dgns - 1].ledger_start
- + dungeons[n_dgns - 1].num_dunlevs);
+ return (xchar) (dungeons[n_dgns - 1].ledger_start
+ + dungeons[n_dgns - 1].num_dunlevs);
}
/* return the dungeon that this ledgerno exists in */
ledger_to_dlev(ledgerno)
xchar ledgerno;
{
- return (xchar)(ledgerno - dungeons[ledger_to_dnum(ledgerno)].ledger_start);
+ return (xchar) (ledgerno
+ - dungeons[ledger_to_dnum(ledgerno)].ledger_start);
}
-/* returns the depth of a level, in floors below the surface */
-/* (note levels in different dungeons can have the same depth). */
+/* returns the depth of a level, in floors below the surface
+ (note levels in different dungeons can have the same depth) */
schar
depth(lev)
d_level *lev;
on_level(lev1, lev2)
d_level *lev1, *lev2;
{
- return (boolean) ((lev1->dnum == lev2->dnum)
- && (lev1->dlevel == lev2->dlevel));
+ return (boolean) (lev1->dnum == lev2->dnum
+ && lev1->dlevel == lev2->dlevel);
}
/* is this level referenced in the special level chain? */
for (levtmp = sp_levchn; levtmp; levtmp = levtmp->next)
if (on_level(lev, &levtmp->dlevel))
- return (levtmp);
+ return levtmp;
return (s_level *) 0;
}
u.ux0 = u.ux, u.uy0 = u.uy;
}
-void u_on_rndspot(upflag) /* place you on a random location */
+/* place you on a random location */
+void
+u_on_rndspot(upflag)
int upflag;
{
int up = (upflag & 1), was_in_W_tower = (upflag & 2);
(d_level *) 0);
}
-void u_on_sstairs(upflag) /* place you on the special staircase */
+/* place you on the special staircase */
+void
+u_on_sstairs(upflag)
int upflag;
{
if (sstairs.sx)
u_on_rndspot(upflag);
}
-void u_on_upstairs() /* place you on upstairs (or special equivalent) */
+/* place you on upstairs (or special equivalent) */
+void
+u_on_upstairs()
{
if (xupstair)
u_on_newpos(xupstair, yupstair);
u_on_sstairs(0); /* destination upstairs implies moving down */
}
-void u_on_dnstairs() /* place you on dnstairs (or special equivalent) */
+/* place you on dnstairs (or special equivalent) */
+void
+u_on_dnstairs()
{
if (xdnstair)
u_on_newpos(xdnstair, ydnstair);
On_stairs(x, y)
xchar x, y;
{
- return ((boolean)((x == xupstair && y == yupstair)
+ return (boolean) ((x == xupstair && y == yupstair)
|| (x == xdnstair && y == ydnstair)
|| (x == xdnladder && y == ydnladder)
|| (x == xupladder && y == yupladder)
- || (x == sstairs.sx && y == sstairs.sy)));
+ || (x == sstairs.sx && y == sstairs.sy));
}
boolean
Is_botlevel(lev)
d_level *lev;
{
- return ((boolean)(lev->dlevel == dungeons[lev->dnum].num_dunlevs));
+ return (boolean) (lev->dlevel == dungeons[lev->dnum].num_dunlevs);
}
boolean
Can_dig_down(lev)
d_level *lev;
{
- return ((boolean)(!level.flags.hardfloor && !Is_botlevel(lev)
- && !Invocation_lev(lev)));
+ return (boolean) (!level.flags.hardfloor
+ && !Is_botlevel(lev)
+ && !Invocation_lev(lev));
}
/*
Can_fall_thru(lev)
d_level *lev;
{
- return ((boolean)(Can_dig_down(lev) || Is_stronghold(lev)));
+ return (boolean) (Can_dig_down(lev) || Is_stronghold(lev));
}
/*
if (In_endgame(lev) || In_sokoban(lev)
|| (Is_wiz1_level(lev) && In_W_tower(x, y, lev)))
return FALSE;
- return (boolean)(lev->dlevel > 1
- || (dungeons[lev->dnum].entry_lev == 1
- && ledger_no(lev) != 1 && sstairs.sx && sstairs.up));
+ return (boolean) (lev->dlevel > 1
+ || (dungeons[lev->dnum].entry_lev == 1
+ && ledger_no(lev) != 1
+ && sstairs.sx && sstairs.up));
}
boolean
d_level *lev;
{
/* [what about level 1 of the quest?] */
- return (!Is_airlevel(lev) && !Is_waterlevel(lev));
+ return (boolean) (!Is_airlevel(lev) && !Is_waterlevel(lev));
}
/*
newlevel->dlevel = levnum;
}
-boolean In_quest(lev) /* are you in the quest dungeon? */
+/* are you in the quest dungeon? */
+boolean
+In_quest(lev)
d_level *lev;
{
- return ((boolean)(lev->dnum == quest_dnum));
+ return (boolean) (lev->dnum == quest_dnum);
}
-boolean In_mines(lev) /* are you in the mines dungeon? */
+/* are you in the mines dungeon? */
+boolean
+In_mines(lev)
d_level *lev;
{
- return ((boolean)(lev->dnum == mines_dnum));
+ return (boolean) (lev->dnum == mines_dnum);
}
/*
* Return the branch for the given dungeon.
*
* This function assumes:
- * + This is not called with "Dungeons of Doom".
- * + There is only _one_ branch to a given dungeon.
- * + Field end2 is the "child" dungeon.
+ * + This is not called with "Dungeons of Doom".
+ * + There is only _one_ branch to a given dungeon.
+ * + Field end2 is the "child" dungeon.
*/
branch *
dungeon_branch(s)
branch *br;
br = dungeon_branch(s);
- return ((boolean)(on_level(&u.uz, &br->end1) ? TRUE : FALSE));
+ return on_level(&u.uz, &br->end1) ? TRUE : FALSE;
}
-boolean In_V_tower(lev) /* is `lev' part of Vlad's tower? */
+/* is `lev' part of Vlad's tower? */
+boolean
+In_V_tower(lev)
d_level *lev;
{
- return ((boolean)(lev->dnum == tower_dnum));
+ return (boolean) (lev->dnum == tower_dnum);
}
+/* is `lev' a level containing the Wizard's tower? */
boolean
-On_W_tower_level(lev) /* is `lev' a level containing the Wizard's tower? */
+On_W_tower_level(lev)
d_level *lev;
{
- return (boolean)(Is_wiz1_level(lev) || Is_wiz2_level(lev)
- || Is_wiz3_level(lev));
+ return (boolean) (Is_wiz1_level(lev)
+ || Is_wiz2_level(lev)
+ || Is_wiz3_level(lev));
}
-boolean In_W_tower(x, y,
- lev) /* is <x,y> of `lev' inside the Wizard's tower? */
+/* is <x,y> of `lev' inside the Wizard's tower? */
+boolean
+In_W_tower(x, y, lev)
int x, y;
d_level *lev;
{
/*
* Both of the exclusion regions for arriving via level teleport
* (from above or below) define the tower's boundary.
- * assert( updest.nIJ == dndest.nIJ for I={l|h},J={x|y} );
+ * assert( updest.nIJ == dndest.nIJ for I={l|h},J={x|y} );
*/
if (dndest.nlx > 0)
return (boolean) within_bounded_area(x, y, dndest.nlx, dndest.nly,
return FALSE;
}
-boolean In_hell(lev) /* are you in one of the Hell levels? */
+/* are you in one of the Hell levels? */
+boolean
+In_hell(lev)
d_level *lev;
{
- return ((boolean)(dungeons[lev->dnum].flags.hellish));
+ return (boolean) (dungeons[lev->dnum].flags.hellish);
}
-void find_hell(lev) /* sets *lev to be the gateway to Gehennom... */
+/* sets *lev to be the gateway to Gehennom... */
+void
+find_hell(lev)
d_level *lev;
{
lev->dnum = valley_level.dnum;
lev->dlevel = 1;
}
-void goto_hell(at_stairs, falling) /* go directly to hell... */
+/* go directly to hell... */
+void
+goto_hell(at_stairs, falling)
boolean at_stairs, falling;
{
d_level lev;
goto_level(&lev, at_stairs, falling, FALSE);
}
-void assign_level(dest, src) /* equivalent to dest = source */
+/* equivalent to dest = source */
+void
+assign_level(dest, src)
d_level *dest, *src;
{
dest->dnum = src->dnum;
dest->dlevel = src->dlevel;
}
-void assign_rnd_level(dest, src, range) /* dest = src + rn1(range) */
+/* dest = src + rn1(range) */
+void
+assign_rnd_level(dest, src, range)
d_level *dest, *src;
int range;
{
if (lev && lev->flags.align)
if (rn2(100) < pct)
- return (lev->flags.align);
+ return lev->flags.align;
if (dungeons[u.uz.dnum].flags.align)
if (rn2(100) < pct)
- return (dungeons[u.uz.dnum].flags.align);
+ return dungeons[u.uz.dnum].flags.align;
al = rn2(3) - 1;
- return (Align2amask(al));
+ return Align2amask(al);
}
boolean
Invocation_lev(lev)
d_level *lev;
{
- return (
- (boolean)(In_hell(lev)
- && lev->dlevel == (dungeons[lev->dnum].num_dunlevs - 1)));
+ return (boolean) (In_hell(lev)
+ && lev->dlevel == dungeons[lev->dnum].num_dunlevs - 1);
}
/* use instead of depth() wherever a degree of difficulty is made
#define INTEREST(feat) \
((feat).nfount || (feat).nsink || (feat).nthrone || (feat).naltar \
|| (feat).ngrave || (feat).ntree || (feat).nshop || (feat).ntemple)
-/*
-|| ((feat).water) || \
-((feat).ice) || \
-((feat).lava)
-*/
+ /* || (feat).water || (feat).ice || (feat).lava */
/* returns true if this level has something interesting to print out */
STATIC_OVL boolean
have annotations or not, so that #overview doesn't become extremely
sparse once the rest of the dungeon has been flagged as unreachable */
if (In_endgame(&u.uz))
- return In_endgame(&mptr->lev);
+ return (boolean) In_endgame(&mptr->lev);
/* level is of interest if it has non-zero feature count or known bones
or user annotation or known connection to another dungeon branch
or is the furthest level reached in its branch */
- return (INTEREST(mptr->feat) || (mptr->final_resting_place
- && (mptr->flags.knownbones || wizard))
- || mptr->custom || mptr->br
- || mptr->lev.dlevel == dungeons[mptr->lev.dnum].dunlev_ureached);
+ return (boolean) (INTEREST(mptr->feat)
+ || (mptr->final_resting_place
+ && (mptr->flags.knownbones || wizard))
+ || mptr->custom || mptr->br
+ || (mptr->lev.dlevel
+ == dungeons[mptr->lev.dnum].dunlev_ureached));
}
/* recalculate mapseen for the current level */
switch (lastseentyp[x][y]) {
#if 0
- case ICE:
- count = mptr->feat.ice + 1;
- if (count <= 3) mptr->feat.ice = count;
- break;
- case POOL:
- case MOAT:
- case WATER:
- count = mptr->feat.water + 1;
- if (count <= 3) mptr->feat.water = count;
- break;
- case LAVAPOOL:
- count = mptr->feat.lava + 1;
- if (count <= 3) mptr->feat.lava = count;
- break;
+ case ICE:
+ count = mptr->feat.ice + 1;
+ if (count <= 3)
+ mptr->feat.ice = count;
+ break;
+ case POOL:
+ case MOAT:
+ case WATER:
+ count = mptr->feat.water + 1;
+ if (count <= 3)
+ mptr->feat.water = count;
+ break;
+ case LAVAPOOL:
+ count = mptr->feat.lava + 1;
+ if (count <= 3)
+ mptr->feat.lava = count;
+ break;
#endif
case TREE:
count = mptr->feat.ntree + 1;
if (count <= 3)
mptr->feat.naltar = count;
break;
- /* An automatic annotation is added to the Castle and
- * to Fort Ludios once their structure's main entrance
- * has been seen (in person or via magic mapping).
+ /* An automatic annotation is added to the Castle and
+ * to Fort Ludios once their structure's main entrance
+ * has been seen (in person or via magic mapping).
* DOOR: possibly a lowered drawbridge's open portcullis;
* DBWALL: a raised drawbridge's "closed door";
* DRAWBRIDGE_DOWN: the span provided by lowered bridge,
- * with moat or other terrain hidden underneath;
+ * with moat or other terrain hidden underneath;
* DRAWBRIDGE_UP: moat in front of a raised drawbridge,
- * not recognizable as a bridge location unless/until
- * the adjacent DBWALL has been seen.
+ * not recognizable as a bridge location unless/until
+ * the adjacent DBWALL has been seen.
*/
case DOOR:
if (is_drawbridge_wall(x, y) < 0)
case BR_NO_END1:
return "Connection";
case BR_NO_END2:
- return (br->end1_up) ? "One way stairs up" : "One way stairs down";
+ return br->end1_up ? "One way stairs up" : "One way stairs down";
case BR_STAIR:
- return (br->end1_up) ? "Stairs up" : "Stairs down";
+ return br->end1_up ? "Stairs up" : "Stairs down";
}
return "(unknown)";
buf[0] = 0;
i = 0; /* interest counter */
- /* List interests in an order vaguely corresponding to
- * how important they are.
- */
+ /* List interests in an order vaguely corresponding to
+ * how important they are.
+ */
if (mptr->feat.nshop > 0) {
if (mptr->feat.nshop > 1)
ADDNTOBUF("shop", mptr->feat.nshop);
ADDNTOBUF("grave", mptr->feat.ngrave);
ADDNTOBUF("tree", mptr->feat.ntree);
#if 0
- ADDTOBUF("water", mptr->feat.water);
- ADDTOBUF("lava", mptr->feat.lava);
- ADDTOBUF("ice", mptr->feat.ice);
+ ADDTOBUF("water", mptr->feat.water);
+ ADDTOBUF("lava", mptr->feat.lava);
+ ADDTOBUF("ice", mptr->feat.ice);
#endif
/* capitalize afterwards */
i = strlen(PREFIX);
-/* NetHack 3.6 eat.c $NHDT-Date: 1446189655 2015/10/30 07:20:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.150 $ */
+/* NetHack 3.6 eat.c $NHDT-Date: 1446808443 2015/11/06 11:14:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.151 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* caller handles Int and memory loss */
} else { /* mhitm */
- /*
- * monster mind flayer is eating another monster's brain
- */
+ /*
+ * monster mind flayer is eating another monster's brain
+ */
if (mindless(pd)) {
if (visflag)
pline("%s doesn't notice.", Monnam(mdef));
case PM_KITTEN:
case PM_HOUSECAT:
case PM_LARGE_CAT:
+ /* cannibals are allowed to eat domestic animals without penalty */
if (!CANNIBAL_ALLOWED()) {
You_feel("that eating the %s was a bad idea.", mons[pm].mname);
HAggravate_monster |= FROMOUTSIDE;
HSee_invisible |= FROMOUTSIDE;
}
newsym(u.ux, u.uy);
- /* fall into next case */
+ /*FALLTHRU*/
case PM_YELLOW_LIGHT:
- /* fall into next case */
case PM_GIANT_BAT:
make_stunned((HStun & TIMEOUT) + 30L, FALSE);
- /* fall into next case */
+ /*FALLTHRU*/
case PM_BAT:
make_stunned((HStun & TIMEOUT) + 30L, FALSE);
break;
case PM_GIANT_MIMIC:
tmp += 10;
- /* fall into next case */
+ /*FALLTHRU*/
case PM_LARGE_MIMIC:
tmp += 20;
- /* fall into next case */
+ /*FALLTHRU*/
case PM_SMALL_MIMIC:
tmp += 20;
if (youmonst.data->mlet != S_MIMIC && !Unchanging) {
dismount_steed(DISMOUNT_FELL);
nomul(-tmp);
multi_reason = "pretending to be a pile of gold";
- Sprintf(
- buf,
- Hallucination
- ? "You suddenly dread being peeled and mimic %s again!"
- : "You now prefer mimicking %s again.",
- an(Upolyd ? youmonst.data->mname : urace.noun));
+ Sprintf(buf,
+ Hallucination
+ ? "You suddenly dread being peeled and mimic %s again!"
+ : "You now prefer mimicking %s again.",
+ an(Upolyd ? youmonst.data->mname : urace.noun));
eatmbuf = dupstr(buf);
nomovemsg = eatmbuf;
afternmv = eatmdone;
if (mnum != PM_ACID_BLOB && !stoneable && rotted > 5L) {
boolean cannibal = maybe_cannibal(mnum, FALSE);
+
pline("Ulch - that %s was tainted%s!",
mons[mnum].mlet == S_FUNGUS
? "fungoid vegetation"
You("peck the eyeball with delight.");
} else {
/* [is this right? omnivores end up always disliking the taste] */
- boolean yummy =
- (vegan(&mons[mnum])
- ? (!carnivorous(youmonst.data) && herbivorous(youmonst.data))
- : (carnivorous(youmonst.data)
- && !herbivorous(youmonst.data)));
-
- pline("%s%s %s!", type_is_pname(&mons[mnum])
- ? ""
- : the_unique_pm(&mons[mnum]) ? "The " : "This ",
+ boolean yummy = vegan(&mons[mnum])
+ ? (!carnivorous(youmonst.data)
+ && herbivorous(youmonst.data))
+ : (carnivorous(youmonst.data)
+ && !herbivorous(youmonst.data));
+
+ pline("%s%s %s!",
+ type_is_pname(&mons[mnum])
+ ? "" : the_unique_pm(&mons[mnum]) ? "The " : "This ",
food_xname(otmp, FALSE),
Hallucination
? (yummy ? ((u.umonnum == PM_TIGER) ? "is gr-r-reat"
makeknown(typ);
}
break;
- }
- break;
+ } /* inner switch */
+ break; /* default case of outer switch */
+
case RIN_ADORNMENT:
accessory_has_effect(otmp);
if (adjattrib(A_CHA, otmp->spe, -1))
case RIN_PROTECTION:
accessory_has_effect(otmp);
HProtection |= FROMOUTSIDE;
- u.ublessed =
- bounded_increase(u.ublessed, otmp->spe, RIN_PROTECTION);
+ u.ublessed = bounded_increase(u.ublessed, otmp->spe,
+ RIN_PROTECTION);
context.botl = 1;
break;
case RIN_FREE_ACTION:
/* no message--this gives no permanent effect */
choke(otmp);
break;
- case AMULET_OF_RESTFUL_SLEEP: /* another bad idea! */
- {
+ case AMULET_OF_RESTFUL_SLEEP: { /* another bad idea! */
long newnap = (long) rnd(100), oldnap = (HSleepy & TIMEOUT);
if (!(HSleepy & FROMOUTSIDE))
/* might also be wearing one; use shorter of two timeouts */
if (newnap < oldnap || oldnap == 0L)
HSleepy = (HSleepy & ~TIMEOUT) | newnap;
- } break;
+ break;
+ }
case RIN_SUSTAIN_ABILITY:
case AMULET_OF_LIFE_SAVING:
case AMULET_OF_REFLECTION: /* nice try */
- /* can't eat Amulet of Yendor or fakes,
- * and no oc_prop even if you could -3.
- */
+ /* can't eat Amulet of Yendor or fakes,
+ * and no oc_prop even if you could -3.
+ */
break;
}
}
edibility_prompts(otmp)
struct obj *otmp;
{
- /* blessed food detection granted you a one-use
- ability to detect food that is unfit for consumption
- or dangerous and avoid it. */
-
- char buf[BUFSZ], foodsmell[BUFSZ], it_or_they[QBUFSZ],
- eat_it_anyway[QBUFSZ];
+ /* Blessed food detection grants hero a one-use
+ * ability to detect food that is unfit for consumption
+ * or dangerous and avoid it.
+ */
+ char buf[BUFSZ], foodsmell[BUFSZ],
+ it_or_they[QBUFSZ], eat_it_anyway[QBUFSZ];
boolean cadaver = (otmp->otyp == CORPSE), stoneorslime = FALSE;
int material = objects[otmp->otyp].oc_material, mnum = otmp->corpsenm;
long rotted = 0L;
* These problems with food should be checked in
* order from most detrimental to least detrimental.
*/
-
if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && !Sick_resistance) {
/* Tainted meat */
Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
if (u.uedibility) {
int res = edibility_prompts(otmp);
if (res) {
- Your("%s stops tingling and your sense of smell returns to "
- "normal.",
+ Your(
+ "%s stops tingling and your sense of smell returns to normal.",
body_part(NOSE));
u.uedibility = 0;
if (res == 1)
/* possible if most has been eaten before */
context.victual.nmod = 0;
else if ((int) otmp->oeaten >= context.victual.reqtime)
- context.victual.nmod =
- -((int) otmp->oeaten / context.victual.reqtime);
+ context.victual.nmod = -((int) otmp->oeaten
+ / context.victual.reqtime);
else
context.victual.nmod = context.victual.reqtime % otmp->oeaten;
context.victual.canchoke = (u.uhs == SATIATED);
-/* NetHack 3.6 lock.c $NHDT-Date: 1446604112 2015/11/04 02:28:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
+/* NetHack 3.6 lock.c $NHDT-Date: 1446808444 2015/11/06 11:14:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
lock_action()
{
/* "unlocking"+2 == "locking" */
- static const char *actions[] = { /* [0] */ "unlocking the door",
- /* [1] */ "unlocking the chest",
- /* [2] */ "unlocking the box",
- /* [3] */ "picking the lock" };
+ static const char *actions[] = {
+ "unlocking the door", /* [0] */
+ "unlocking the chest", /* [1] */
+ "unlocking the box", /* [2] */
+ "picking the lock" /* [3] */
+ };
/* if the target is currently unlocked, we're trying to lock it now */
if (xlock.door && !(xlock.door->doormask & D_LOCKED))
}
if (xlock.picktyp) { /* blade */
-
if (rn2(1000 - (int) uwep->spe) > (992 - greatest_erosion(uwep) * 10)
&& !uwep->cursed && !obj_resists(uwep, 0, 99)) {
/* for a +0 weapon, probability that it survives an unsuccessful
return 1;
}
-/* try to open a door */
-int
-doopen()
-{
- return doopen_indir(0, 0);
-}
-
boolean
stumble_on_door_mimic(x, y)
int x, y;
return FALSE;
}
+/* the 'O' command - try to open a door */
+int
+doopen()
+{
+ return doopen_indir(0, 0);
+}
+
/* try to open a door in direction u.dx/u.dy */
int
doopen_indir(x, y)
return FALSE;
}
-/* try to close a door */
+/* the 'C' command - try to close a door */
int
doclose()
{
-/* NetHack 3.6 makemon.c $NHDT-Date: 1445556868 2015/10/22 23:34:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */
+/* NetHack 3.6 makemon.c $NHDT-Date: 1446808445 2015/11/06 11:14:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
boolean
is_home_elemental(ptr)
-register struct permonst *ptr;
+struct permonst *ptr;
{
if (ptr->mlet == S_ELEMENTAL)
switch (monsndx(ptr)) {
*/
STATIC_OVL boolean
wrong_elem_type(ptr)
-register struct permonst *ptr;
+struct permonst *ptr;
{
if (ptr->mlet == S_ELEMENTAL) {
- return ((boolean)(!is_home_elemental(ptr)));
+ return (boolean) !is_home_elemental(ptr);
} else if (Is_earthlevel(&u.uz)) {
/* no restrictions? */
} else if (Is_waterlevel(&u.uz)) {
return FALSE;
}
-STATIC_OVL void m_initgrp(mtmp, x, y, n) /* make a group just like mtmp */
+/* make a group just like mtmp */
+STATIC_OVL void
+m_initgrp(mtmp, x, y, n)
register struct monst *mtmp;
register int x, y, n;
{
register struct permonst *ptr = mtmp->data;
register int mm = monsndx(ptr);
struct obj *otmp;
+ int bias, spe2, w1, w2;
if (Is_rogue_level(&u.uz))
return;
/*
- * first a few special cases:
- *
- * giants get a boulder to throw sometimes.
- * ettins get clubs
- * kobolds get darts to throw
- * centaurs get some sort of bow & arrows or bolts
- * soldiers get all sorts of things.
- * kops get clubs & cream pies.
+ * First a few special cases:
+ * giants get a boulder to throw sometimes
+ * ettins get clubs
+ * kobolds get darts to throw
+ * centaurs get some sort of bow & arrows or bolts
+ * soldiers get all sorts of things
+ * kops get clubs & cream pies.
*/
switch (ptr->mlet) {
case S_GIANT:
break;
case S_HUMAN:
if (is_mercenary(ptr)) {
- int w1 = 0, w2 = 0;
+ w1 = w2 = 0;
switch (mm) {
case PM_WATCHMAN:
case PM_SOLDIER:
case S_ANGEL:
if (humanoid(ptr)) {
- int spe2;
-
/* create minion stuff; can't use mongets */
otmp = mksobj(LONG_SWORD, FALSE, FALSE);
}
}
break;
- case S_KOP: /* create Keystone Kops with cream pies to
- * throw. As suggested by KAA. [MRS]
- */
+ case S_KOP:
+ /* create Keystone Kops with cream pies to
+ throw. As suggested by KAA. [MRS] */
if (!rn2(4))
m_initthrow(mtmp, CREAM_PIE, 2);
if (!rn2(3))
case S_ORC:
if (rn2(2))
(void) mongets(mtmp, ORCISH_HELM);
- switch (mm != PM_ORC_CAPTAIN ? mm : rn2(2) ? PM_MORDOR_ORC
- : PM_URUK_HAI) {
+ switch ((mm != PM_ORC_CAPTAIN) ? mm
+ : rn2(2) ? PM_MORDOR_ORC : PM_URUK_HAI) {
case PM_MORDOR_ORC:
if (!rn2(3))
(void) mongets(mtmp, SCIMITAR);
*/
if (!is_demon(ptr))
break;
- /* fall thru */
- /*
- * Now the general case, Some chance of getting some type
- * of weapon for "normal" monsters. Certain special types
- * of monsters will get a bonus chance or different selections.
- */
- default: {
- int bias;
-
+ /*FALLTHRU*/
+ default:
+ /*
+ * Now the general case, some chance of getting some type
+ * of weapon for "normal" monsters. Certain special types
+ * of monsters will get a bonus chance or different selections.
+ */
bias = is_lord(ptr) + is_prince(ptr) * 2 + extra_nasty(ptr);
switch (rnd(14 - (2 * bias))) {
case 1:
default:
break;
}
- } break;
+ break;
}
+
if ((int) mtmp->m_lev > rn2(75))
(void) mongets(mtmp, rnd_offensive_item(mtmp));
}
long amount;
{
struct obj *gold = mksobj(GOLD_PIECE, FALSE, FALSE);
+
gold->quan = amount;
add_to_minv(mtmp, gold);
}
register int cnt;
register struct obj *otmp;
register struct permonst *ptr = mtmp->data;
+
if (Is_rogue_level(&u.uz))
return;
/*
- * Soldiers get armour & rations - armour approximates their ac.
- * Nymphs may get mirror or potion of object detection.
+ * Soldiers get armour & rations - armour approximates their ac.
+ * Nymphs may get mirror or potion of object detection.
*/
switch (ptr->mlet) {
case S_HUMAN:
{
boolean result;
uchar lim = mbirth_limit(mndx);
- boolean gone =
- (mvitals[mndx].mvflags & G_GONE); /* genocided or extinct */
+ boolean gone = (mvitals[mndx].mvflags & G_GONE) != 0; /* geno'd|extinct */
result = (((int) mvitals[mndx].born < lim) && !gone) ? TRUE : FALSE;
return mextra;
}
-
boolean
makemon_rnd_goodpos(mon, gpflags, cc)
struct monst *mon;
int tryct = 0;
int nx,ny;
boolean good;
+
do {
nx = rn1(COLNO - 3, 2);
ny = rn2(ROWNO);
- if (!in_mklev && cansee(nx,ny)) good = FALSE;
- else good = goodpos(nx, ny, mon, gpflags);
+ good = (!in_mklev && cansee(nx,ny)) ? FALSE
+ : goodpos(nx, ny, mon, gpflags);
} while ((++tryct < 50) && !good);
+
if (!good) {
/* else go through all map positions, twice, first round
ignoring positions in sight, and pick first good one.
int yofs = ny;
int dx,dy;
int bl = (in_mklev || Blind) ? 1 : 0;
+
for ( ; bl < 2; bl++) {
for (dx = 0; dx < COLNO; dx++)
for (dy = 0; dy < ROWNO; dy++) {
nx = ((dx + xofs) % (COLNO - 1)) + 1;
ny = ((dy + yofs) % (ROWNO - 1)) + 1;
- if ((bl == 0) && cansee(nx,ny)) continue;
+ if (bl == 0 && cansee(nx,ny))
+ continue;
if (goodpos(nx, ny, mon, gpflags))
goto gotgood;
}
/*
* called with [x,y] = coordinates;
- * [0,0] means anyplace
- * [u.ux,u.uy] means: near player (if !in_mklev)
+ * [0,0] means anyplace
+ * [u.ux,u.uy] means: near player (if !in_mklev)
*
- * In case we make a monster group, only return the one at [x,y].
+ * In case we make a monster group, only return the one at [x,y].
*/
struct monst *
makemon(ptr, x, y, mmflags)
register struct permonst *ptr;
register int x, y;
-register int mmflags;
+int mmflags;
{
register struct monst *mtmp;
int mndx, mcham, ct, mitem;
struct monst fakemon;
fakemon.data = ptr; /* set up for goodpos */
- if (!makemon_rnd_goodpos(ptr ? &fakemon : (struct monst *)0, gpflags, &cc))
- return ((struct monst *) 0);
+ if (!makemon_rnd_goodpos(ptr ? &fakemon : (struct monst *)0,
+ gpflags, &cc))
+ return (struct monst *) 0;
x = cc.x;
y = cc.y;
} else if (byyou && !in_mklev) {
x = bypos.x;
y = bypos.y;
} else
- return ((struct monst *) 0);
+ return (struct monst *) 0;
}
/* Does monster already exist at the position? */
x = bypos.x;
y = bypos.y;
} else
- return ((struct monst *) 0);
+ return (struct monst *) 0;
} else
- return ((struct monst *) 0);
+ return (struct monst *) 0;
}
if (ptr) {
/* if you are to make a specific monster and it has
already been genocided, return */
if (mvitals[mndx].mvflags & G_GENOD)
- return ((struct monst *) 0);
+ return (struct monst *) 0;
if (wizard && (mvitals[mndx].mvflags & G_EXTINCT))
debugpline1("Explicitly creating extinct monster %s.",
mons[mndx].mname);
do {
if (!(ptr = rndmonst())) {
debugpline0("Warning: no monster.");
- return ((struct monst *) 0); /* no more monsters! */
+ return (struct monst *) 0; /* no more monsters! */
}
fakemon.data = ptr; /* set up for goodpos */
} while (++tryct <= 50
(void) mongets(mtmp, mitem);
if (in_mklev) {
- if (((is_ndemon(ptr)) || (mndx == PM_WUMPUS) || (mndx == PM_LONG_WORM)
- || (mndx == PM_GIANT_EEL)) && !u.uhave.amulet && rn2(5))
+ if ((is_ndemon(ptr) || mndx == PM_WUMPUS
+ || mndx == PM_LONG_WORM || mndx == PM_GIANT_EEL)
+ && !u.uhave.amulet && rn2(5))
mtmp->msleeping = TRUE;
} else {
if (byyou) {
if (mndx == PM_LONG_WORM && (mtmp->wormno = get_wormno()) != 0)
#else
/* DICE 3.0 doesn't like assigning and comparing mtmp->wormno in the
- * same expression.
- */
+ same expression. */
if (mndx == PM_LONG_WORM
&& (mtmp->wormno = get_wormno(), mtmp->wormno != 0))
#endif
if (!in_mklev)
newsym(mtmp->mx, mtmp->my); /* make sure the mon shows up */
- return (mtmp);
+ return mtmp;
}
int
if (mvitals[mndx].mvflags & G_GONE)
return TRUE;
if (Inhell)
- return (mons[mndx].maligntyp > A_NEUTRAL);
+ return (boolean) (mons[mndx].maligntyp > A_NEUTRAL);
else
- return ((mons[mndx].geno & G_HELL) != 0);
+ return (boolean) ((mons[mndx].geno & G_HELL) != 0);
}
/*
- * shift the probability of a monster's generation by
- * comparing the dungeon alignment and monster alignment.
- * return an integer in the range of 0-5.
+ * shift the probability of a monster's generation by
+ * comparing the dungeon alignment and monster alignment.
+ * return an integer in the range of 0-5.
*/
STATIC_OVL int
align_shift(ptr)
elemlevel = In_endgame(&u.uz) && !Is_astralevel(&u.uz);
/*
- * Find out how many monsters exist in the range we have
- *selected.
+ * Find out how many monsters exist in the range we have selected.
*/
- /* (`mndx' initialized above) */
- for (; mndx < SPECIAL_PM; mndx++) {
+ for ( ; mndx < SPECIAL_PM; mndx++) { /* (`mndx' initialized above) */
ptr = &mons[mndx];
rndmonst_state.mchoices[mndx] = 0;
if (tooweak(mndx, minmlev) || toostrong(mndx, maxmlev))
rndmonst_state.mchoices[mndx] = (char) ct;
}
/*
- * Possible modification: if choice_count is "too low",
- * expand minmlev..maxmlev range and try again.
+ * Possible modification: if choice_count is "too low",
+ * expand minmlev..maxmlev range and try again.
*/
} /* choice_count+mchoices[] recalc */
}
/*
- * Now, select a monster at random.
+ * Now, select a monster at random.
*/
ct = rnd(rndmonst_state.choice_count);
for (mndx = LOW_PM; mndx < SPECIAL_PM; mndx++)
return TRUE;
}
-/* The routine below is used to make one of the multiple types
- * of a given monster class. The second parameter specifies a
- * special casing bit mask to allow the normal genesis
- * masks to be deactivated. Returns 0 if no monsters
- * in that class can be made.
+/* Make one of the multiple types of a given monster class.
+ * The second parameter specifies a special casing bit mask
+ * to allow the normal genesis masks to be deactivated.
+ * Returns Null if no monsters in that class can be made.
*/
-
struct permonst *
mkclass(class, spc)
char class;
maxmlev = level_difficulty() >> 1;
if (class < 1 || class >= MAXMCLASSES) {
impossible("mkclass called with bad class!");
- return ((struct permonst *) 0);
+ return (struct permonst *) 0;
}
- /* Assumption #1: monsters of a given class are contiguous in the
- * mons[] array.
+ /* Assumption #1: monsters of a given class are contiguous in the
+ * mons[] array.
*/
for (first = LOW_PM; first < SPECIAL_PM; first++)
if (mons[first].mlet == class)
break;
num += mons[last].geno & G_FREQ;
}
-
if (!num)
- return ((struct permonst *) 0);
+ return (struct permonst *) 0;
- /* Assumption #2: monsters of a given class are presented in ascending
- * order of strength.
+ /* Assumption #2: monsters of a given class are presented in ascending
+ * order of strength.
*/
for (num = rnd(num); num > 0; first++)
if (mk_gen_ok(first, G_GONE, mask)) {
}
first--; /* correct an off-by-one error */
- return (&mons[first]);
+ return &mons[first];
}
/* like mkclass(), but excludes difficulty considerations; used when
player with polycontrol picks a class instead of a specific type;
genocided types are avoided but extinct ones are acceptable; we don't
check polyok() here--caller accepts some choices !polyok() would reject */
-int mkclass_poly(class)
+int
+mkclass_poly(class)
int class;
{
register int first, last, num = 0;
return first;
}
-int adj_lev(ptr) /* adjust strength of monsters based on u.uz and u.ulevel */
+/* adjust strength of monsters based on u.uz and u.ulevel */
+int
+adj_lev(ptr)
register struct permonst *ptr;
{
int tmp, tmp2;
}
if ((tmp = ptr->mlevel) > 49)
- return (50); /* "special" demons/devils */
+ return 50; /* "special" demons/devils */
tmp2 = (level_difficulty() - tmp);
if (tmp2 < 0)
tmp--; /* if mlevel > u.uz decrement tmp */
return ((tmp > tmp2) ? tmp2 : (tmp > 0 ? tmp : 0)); /* 0 lower limit */
}
+/* monster earned experience and will gain some hit points; it might also
+ grow into a bigger monster (baby to adult, soldier to officer, etc) */
struct permonst *
-grow_up(mtmp, victim) /* `mtmp' might "grow up" into a bigger version */
+grow_up(mtmp, victim)
struct monst *mtmp, *victim;
{
int oldtype, newtype, max_increase, cur_increase, lev_limit, hp_threshold;
/* monster died after killing enemy but before calling this function */
/* currently possible if killing a gas spore */
if (mtmp->mhp <= 0)
- return ((struct permonst *) 0);
+ return (struct permonst *) 0;
/* note: none of the monsters with special hit point calculations
have both little and big forms */
/* growth limits differ depending on method of advancement */
if (victim) { /* killed a monster */
- /*
- * The HP threshold is the maximum number of hit points for the
- * current level; once exceeded, a level will be gained.
- * Possible bug: if somehow the hit points are already higher
- * than that, monster will gain a level without any increase in HP.
- */
+ /*
+ * The HP threshold is the maximum number of hit points for the
+ * current level; once exceeded, a level will be gained.
+ * Possible bug: if somehow the hit points are already higher
+ * than that, monster will gain a level without any increase in HP.
+ */
hp_threshold = mtmp->m_lev * 8; /* normal limit */
if (!mtmp->m_lev)
hp_threshold = 4;
int
mongets(mtmp, otyp)
register struct monst *mtmp;
-register int otyp;
+int otyp;
{
register struct obj *otmp;
int spe;
spe = otmp->spe;
(void) mpickobj(mtmp, otmp); /* might free otmp */
- return (spe);
- } else
- return (0);
+ return spe;
+ }
+ return 0;
}
int
}
/*
- * Alignment vs. yours determines monster's attitude to you.
- * ( some "animal" types are co-aligned, but also hungry )
+ * Alignment vs. yours determines monster's attitude to you.
+ * (Some "animal" types are co-aligned, but also hungry.)
*/
boolean
peace_minded(ptr)
/* minions are hostile to players that have strayed at all */
if (is_minion(ptr))
- return ((boolean)(u.ualign.record >= 0));
+ return (boolean) (u.ualign.record >= 0);
/* Last case: a chance of a co-aligned monster being
* hostile. This chance is greater if the player has strayed
* (u.ualign.record negative) or the monster is not strongly aligned.
*/
- return (
- (boolean)(!!rn2(16 + (u.ualign.record < -15 ? -15 : u.ualign.record))
- && !!rn2(2 + abs(mal))));
+ return (boolean) (!!rn2(16 + (u.ualign.record < -15 ? -15
+ : u.ualign.record))
+ && !!rn2(2 + abs(mal)));
}
/* Set malign to have the proper effect on player alignment if monster is
* greater than the bonus for killing a hostile monster to maintain balance.
* Rules:
* it's bad to kill peaceful monsters, potentially worse to kill always-
- * peaceful monsters
- * it's never bad to kill a hostile monster, although it may not be good
+ * peaceful monsters;
+ * it's never bad to kill a hostile monster, although it may not be good.
*/
void
set_malign(mtmp)
}
}
-/* release a monster from a bag of tricks; return number of monsters created
- */
+/* release monster frome bag of tricks; return number of monsters created */
int
bagotricks(bag, tipping, seencount)
struct obj *bag;
-/* NetHack 3.6 monmove.c $NHDT-Date: 1446604115 2015/11/04 02:28:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.77 $ */
+/* NetHack 3.6 monmove.c $NHDT-Date: 1446808446 2015/11/06 11:14:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.78 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
if (tmp != 2)
distfleeck(mtmp, &inrange, &nearby, &scared); /* recalc */
- switch (tmp) {
+ switch (tmp) { /* for pets, cases 0 and 3 are equivalent */
case 0: /* no movement, but it can still attack you */
case 3: /* absolutely no movement */
- /* for pets, case 0 and 3 are equivalent */
/* vault guard might have vanished */
- if (mtmp->isgd
- && (mtmp->mhp < 1 || (mtmp->mx == 0 && mtmp->my == 0)))
+ if (mtmp->isgd && (mtmp->mhp < 1 || !mtmp->mx == 0))
return 1; /* behave as if it died */
- /* During hallucination, monster appearance should
- * still change - even if it doesn't move.
- */
+ /* During hallucination, monster appearance should
+ * still change - even if it doesn't move.
+ */
if (Hallucination)
newsym(mtmp->mx, mtmp->my);
break;
-/* NetHack 3.6 mthrowu.c $NHDT-Date: 1446604116 2015/11/04 02:28:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
+/* NetHack 3.6 mthrowu.c $NHDT-Date: 1446808447 2015/11/06 11:14:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
ohitmon(mtmp, otmp, range, verbose)
struct monst *mtmp; /* accidental target, located at <bhitpos.x,.y> */
struct obj *otmp; /* missile; might be destroyed by drop_throw */
-int range; /* how much farther will object travel if it misses */
- /* Use -1 to signify to keep going even after hit, */
- /* unless its gone (used for rolling_boulder_traps) */
+int range; /* how much farther will object travel if it misses;
+ use -1 to signify to keep going even after hit,
+ unless it's gone (used for rolling_boulder_traps) */
boolean verbose; /* give message(s) even when you can't see what happened */
{
int damage, tmp;
-/* NetHack 3.6 music.c $NHDT-Date: 1432512773 2015/05/25 00:12:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.38 $ */
-/* Copyright (c) 1989 by Jean-Christophe Collet */
+/* NetHack 3.6 music.c $NHDT-Date: 1446808448 2015/11/06 11:14:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.40 $ */
+/* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */
/*
*
* Actually the list of instruments / effects is :
*
- * (wooden) flute may calm snakes if player has enough dexterity
- * magic flute may put monsters to sleep: area of effect depends
- * on player level.
- * (tooled) horn Will awaken monsters: area of effect depends on
- *player
- * level. May also scare monsters.
- * fire horn Acts like a wand of fire.
- * frost horn Acts like a wand of cold.
- * bugle Will awaken soldiers (if any): area of effect depends
- * on player level.
- * (wooden) harp May calm nymph if player has enough dexterity.
- * magic harp Charm monsters: area of effect depends on player
- * level.
- * (leather) drum Will awaken monsters like the horn.
- * drum of earthquake Will initiate an earthquake whose intensity depends
- * on player level. That is, it creates random pits
- * called here chasms.
+ * (wooden) flute may calm snakes if player has enough dexterity
+ * magic flute may put monsters to sleep: area of effect depends
+ * on player level.
+ * (tooled) horn Will awaken monsters: area of effect depends on
+ * player level. May also scare monsters.
+ * fire horn Acts like a wand of fire.
+ * frost horn Acts like a wand of cold.
+ * bugle Will awaken soldiers (if any): area of effect depends
+ * on player level.
+ * (wooden) harp May calm nymph if player has enough dexterity.
+ * magic harp Charm monsters: area of effect depends on player
+ * level.
+ * (leather) drum Will awaken monsters like the horn.
+ * drum of earthquake Will initiate an earthquake whose intensity depends
+ * on player level. That is, it creates random pits
+ * called here chasms.
*/
#include "hack.h"
mtmp->mcanmove = 1;
mtmp->mfrozen = 0;
/* may scare some monsters -- waiting monsters excluded */
- if (!unique_corpstat(mtmp->data) && (mtmp->mstrategy & STRAT_WAITMASK) != 0)
+ if (!unique_corpstat(mtmp->data)
+ && (mtmp->mstrategy & STRAT_WAITMASK) != 0)
mtmp->mstrategy &= ~STRAT_WAITMASK;
else if (distm < distance / 3
&& !resist(mtmp, TOOL_CLASS, 0, NOTELL))
if (canseemon(mtmp))
pline(
"%s listens cheerfully to the music, then seems quieter.",
- Monnam(mtmp));
+ Monnam(mtmp));
}
}
}
mtmp->mcanmove = 1;
mtmp->mfrozen = 0;
/* may scare some monsters -- waiting monsters excluded */
- if (!unique_corpstat(mtmp->data) && (mtmp->mstrategy & STRAT_WAITMASK) != 0)
+ if (!unique_corpstat(mtmp->data)
+ && (mtmp->mstrategy & STRAT_WAITMASK) != 0)
mtmp->mstrategy &= ~STRAT_WAITMASK;
else if (distm < distance / 3
&& !resist(mtmp, TOOL_CLASS, 0, NOTELL))
/* Charm monsters in range. Note that they may resist the spell.
* If swallowed, range is reduced to 0.
*/
-
STATIC_OVL void
charm_monsters(distance)
int distance;
/* Generate earthquake :-) of desired force.
* That is: create random chasms (pits).
*/
-
STATIC_OVL void
do_earthquake(force)
int force;
/* We have to check whether monsters or player
falls in a chasm... */
-
if (mtmp) {
if (!is_flyer(mtmp->data)
&& !is_clinger(mtmp->data)) {
/*
* The player is trying to extract something from his/her instrument.
*/
-
STATIC_OVL int
do_improvisation(instr)
struct obj *instr;
} else if (!u.dx && !u.dy && !u.dz) {
if ((damage = zapyourself(instr, TRUE)) != 0) {
char buf[BUFSZ];
+
Sprintf(buf, "using a magical horn on %sself", uhim());
- losehp(damage, buf, KILLED_BY); /* frost damage */
- /* fire damage */
+ losehp(damage, buf, KILLED_BY); /* fire or frost damage */
}
} else {
buzz((instr->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1,
/*
* So you want music...
*/
-
int
do_play_instrument(instr)
struct obj *instr;
if (Underwater) {
You_cant("play music underwater!");
- return (0);
+ return 0;
} else if ((instr->otyp == WOODEN_FLUTE || instr->otyp == MAGIC_FLUTE
|| instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN
|| instr->otyp == FIRE_HORN || instr->otyp == BUGLE)
&& !can_blow(&youmonst)) {
You("are incapable of playing %s.", the(distant_name(instr, xname)));
- return (0);
+ return 0;
}
if (instr->otyp != LEATHER_DRUM && instr->otyp != DRUM_OF_EARTHQUAKE) {
c = ynq("Improvise?");
{
char nbuf[20];
int i;
+
for (i = 0; buf[i] && i < 5; ++i) {
nbuf[i * 2] = buf[i];
nbuf[(i * 2) + 1] = 'h';
#define noDEBUG
+/* emit tone of frequency hz for given number of ticks */
STATIC_OVL void
tone(hz, ticks)
-/* emit tone of frequency hz for given number of ticks */
unsigned int hz, ticks;
{
ioctl(0, KDMKTONE, hz | ((ticks * 10) << 16));
nap(ticks * 10);
}
+/* rest for given number of ticks */
STATIC_OVL void
rest(ticks)
-/* rest for given number of ticks */
int ticks;
{
nap(ticks * 10);
playstring(buf, strlen(buf));
}
-#ifdef DEBUG
-main(argc, argv) char *argv[];
+#ifdef VPIX_DEBUG
+main(argc, argv)
+int argc;
+char *argv[];
{
if (argc == 2) {
playinit();
-/* NetHack 3.6 options.c $NHDT-Date: 1446336796 2015/11/01 00:13:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.234 $ */
+/* NetHack 3.6 options.c $NHDT-Date: 1446808448 2015/11/06 11:14:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.235 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/*
* Default menu manipulation command accelerators. These may _not_ be:
*
- * + a number - reserved for counts
- * + an upper or lower case US ASCII letter - used for accelerators
- * + ESC - reserved for escaping the menu
- * + NULL, CR or LF - reserved for commiting the selection(s). NULL
- * is kind of odd, but the tty's xwaitforspace() will return it if
- * someone hits a <ret>.
- * + a default object class symbol - used for object class accelerators
+ * + a number - reserved for counts
+ * + an upper or lower case US ASCII letter - used for accelerators
+ * + ESC - reserved for escaping the menu
+ * + NULL, CR or LF - reserved for commiting the selection(s). NULL
+ * is kind of odd, but the tty's xwaitforspace() will return it if
+ * someone hits a <ret>.
+ * + a default object class symbol - used for object class accelerators
*
* Standard letters (for now) are:
*
- * < back 1 page
- * > forward 1 page
- * ^ first page
- * | last page
- * : search
+ * < back 1 page
+ * > forward 1 page
+ * ^ first page
+ * | last page
+ * : search
*
- * page all
- * , select .
- * \ deselect -
- * ~ invert @
+ * page all
+ * , select .
+ * \ deselect -
+ * ~ invert @
*
* The command name list is duplicated in the compopt array.
*/
STATIC_DCL void FDECL(oc_to_str, (char *, char *));
STATIC_DCL int FDECL(feature_alert_opts, (char *, const char *));
STATIC_DCL const char *FDECL(get_compopt_value, (const char *, char *));
-STATIC_DCL boolean
-FDECL(special_handling, (const char *, BOOLEAN_P, BOOLEAN_P));
+STATIC_DCL boolean FDECL(special_handling, (const char *,
+ BOOLEAN_P, BOOLEAN_P));
STATIC_DCL void FDECL(warning_opts, (char *, const char *));
STATIC_DCL boolean FDECL(duplicate_opt_detection, (const char *, int));
STATIC_DCL void FDECL(complain_about_duplicate, (const char *, int));
for (y = 0; y < ROWNO; y++) {
struct rm *lev = &levl[x][y];
- if (!flags.dark_room || !iflags.use_color || Is_rogue_level(&u.uz)) {
+ if (!flags.dark_room || !iflags.use_color
+ || Is_rogue_level(&u.uz)) {
if (lev->glyph == cmap_to_glyph(S_darkroom))
lev->glyph = lev->waslit ? cmap_to_glyph(S_room)
: cmap_to_glyph(S_stone);
if (!initial) {
Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ,
FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH);
- pline("Feature change alerts disabled for NetHack %s features and "
- "prior.",
+ pline(
+ "Feature change alerts disabled for NetHack %s features and prior.",
buf);
}
return 1;
for (i = 0; i < SIZE(colornames); i++)
if (colornames[i].color == clr)
return colornames[i].name;
- return NULL;
+ return (char *) 0;
}
const char *
for (i = 0; i < SIZE(attrnames); i++)
if (attrnames[i].attr == attr)
return attrnames[i].name;
- return NULL;
+ return (char *) 0;
}
int
int i;
for (i = 0; i < SIZE(msgtype_names); i++)
- if (msgtype_names[i].descr && msgtype_names[i].msgtyp == typ)
- return msgtype_names[i].name;
- return NULL;
+ if (msgtype_names[i].descr && msgtype_names[i].msgtyp == typ)
+ return msgtype_names[i].name;
+ return (char *) 0;
}
int
start_menu(tmpwin);
any = zeroany;
for (i = 0; i < SIZE(msgtype_names); i++)
- if (msgtype_names[i].descr) {
- any.a_int = msgtype_names[i].msgtyp + 1;
- add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
+ if (msgtype_names[i].descr) {
+ any.a_int = msgtype_names[i].msgtyp + 1;
+ add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
msgtype_names[i].descr, MENU_UNSELECTED);
- }
+ }
end_menu(tmpwin, "How to show the message");
pick_cnt = select_menu(tmpwin, PICK_ONE, &picks);
destroy_nhwindow(tmpwin);
tmp->msgtype = typ;
tmp->regex = regex_init();
if (!regex_compile(pattern, tmp->regex)) {
- static const char *re_error = "MSGTYPE regex error";
+ static const char *re_error = "MSGTYPE regex error";
+
if (!iflags.window_inited)
raw_printf("\n%s: %s\n", re_error, regex_error_desc(tmp->regex));
else
void
msgtype_free()
{
- struct plinemsg_type *tmp = plinemsg_types;
- struct plinemsg_type *tmp2;
+ struct plinemsg_type *tmp, *tmp2 = 0;
- while (tmp) {
- free(tmp->pattern);
- regex_free(tmp->regex);
- tmp2 = tmp;
- tmp = tmp->next;
- free(tmp2);
+ for (tmp = plinemsg_types; tmp; tmp = tmp2) {
+ tmp2 = tmp->next;
+ free((genericptr_t) tmp->pattern);
+ regex_free(tmp->regex);
+ free((genericptr_t) tmp);
}
- plinemsg_types = NULL;
+ plinemsg_types = (struct plinemsg_type *) 0;
}
void
while (tmp) {
if (idx == 0) {
struct plinemsg_type *next = tmp->next;
+
regex_free(tmp->regex);
- free(tmp->pattern);
- free(tmp);
+ free((genericptr_t) tmp->pattern);
+ free((genericptr_t) tmp);
if (prev)
prev->next = next;
else
struct plinemsg_type *tmp = plinemsg_types;
while (tmp) {
- if (regex_match(msg, tmp->regex)) return tmp->msgtype;
- tmp = tmp->next;
+ if (regex_match(msg, tmp->regex))
+ return tmp->msgtype;
+ tmp = tmp->next;
}
return MSGTYP_NORMAL;
}
struct plinemsg_type *tmp = plinemsg_types;
while (tmp) {
- c++;
- tmp = tmp->next;
+ c++;
+ tmp = tmp->next;
}
return c;
}
char msgtype[11];
if (sscanf(str, "%10s \"%255[^\"]\"", msgtype, pattern) == 2) {
- int typ = -1;
- int i;
- for (i = 0; i < SIZE(msgtype_names); i++)
- if (!strncmpi(msgtype_names[i].name, msgtype, strlen(msgtype))) {
- typ = msgtype_names[i].msgtyp;
- break;
- }
- if (typ != -1)
- return msgtype_add(typ, pattern);
+ int typ = -1;
+ int i;
+
+ for (i = 0; i < SIZE(msgtype_names); i++)
+ if (!strncmpi(msgtype_names[i].name, msgtype, strlen(msgtype))) {
+ typ = msgtype_names[i].msgtyp;
+ break;
+ }
+ if (typ != -1)
+ return msgtype_add(typ, pattern);
}
return FALSE;
}
if (!str)
return FALSE;
- tmp = (struct menucoloring *) alloc(sizeof(struct menucoloring));
+ tmp = (struct menucoloring *) alloc(sizeof (struct menucoloring));
tmp->match = regex_init();
if (!regex_compile(str, tmp->match)) {
if (!iflags.window_inited)
while (tmp) {
struct menucoloring *tmp2 = tmp->next;
+
regex_free(tmp->match);
- free(tmp->origstr);
- free(tmp);
+ free((genericptr_t) tmp->origstr);
+ free((genericptr_t) tmp);
tmp = tmp2;
}
}
while (tmp) {
if (idx == 0) {
struct menucoloring *next = tmp->next;
+
regex_free(tmp->match);
- free(tmp->origstr);
- free(tmp);
+ free((genericptr_t) tmp->origstr);
+ free((genericptr_t) tmp);
if (prev)
prev->next = next;
else
break;
case 'h': /* horse */
case 'q': /* quadruped */
- /* avoids giving "unrecognized type of pet" but
- pet_type(dog.c) won't actually honor this */
+ /* avoids giving "unrecognized type of pet" but
+ pet_type(dog.c) won't actually honor this */
preferred_pet = 'h';
break;
case 'n': /* no pet */
/* allow option to be silently ignored by non-tty ports */
#ifdef TTY_GRAPHICS
int tmp;
+
if (duplicate)
complain_about_duplicate(opts, 1);
if (!(op = string_for_opt(opts, TRUE))) {
if (match_optname(opts, "fruit", 2, TRUE)) {
struct fruit *forig = 0;
-
char empty_str = '\0';
+
if (duplicate)
complain_about_duplicate(opts, 1);
op = string_for_opt(opts, negated);
bad_negation(fullname, FALSE);
return;
}
- /* if (!(opts = string_for_env_opt(fullname, opts, FALSE)))
+ /* if (!(opts = string_for_env_opt(fullname, opts, FALSE)))
*/
if (!(opts = string_for_opt(opts, FALSE)))
return;
if (match_optname(opts, "disclose", 7, TRUE)) {
/*
* The order that the end_disclose options are stored:
- * inventory, attribs, vanquished, genocided,
- * conduct, overview.
+ * inventory, attribs, vanquished, genocided,
+ * conduct, overview.
* There is an array in flags:
- * end_disclose[NUM_DISCLOSURE_OPT];
+ * end_disclose[NUM_DISCLOSURE_OPT];
* with option settings for the each of the following:
* iagvc [see disclosure_options in decl.c]:
* Legal setting values in that array are:
- * DISCLOSE_PROMPT_DEFAULT_YES ask with default answer yes
- * DISCLOSE_PROMPT_DEFAULT_NO ask with default answer no
- * DISCLOSE_YES_WITHOUT_PROMPT always disclose and don't ask
- * DISCLOSE_NO_WITHOUT_PROMPT never disclose and don't ask
+ * DISCLOSE_PROMPT_DEFAULT_YES ask with default answer yes
+ * DISCLOSE_PROMPT_DEFAULT_NO ask with default answer no
+ * DISCLOSE_YES_WITHOUT_PROMPT always disclose and don't ask
+ * DISCLOSE_NO_WITHOUT_PROMPT never disclose and don't ask
*
* Those setting values can be used in the option
* string as a prefix to get the desired behaviour.
fullname = "DECgraphics";
if (match_optname(opts, fullname, 3, TRUE)) {
boolean badflag = FALSE;
+
if (duplicate)
complain_about_duplicate(opts, 1);
if (!negated) {
if (match_optname(opts, fullname, 3, TRUE)) {
const char *sym_name = fullname;
boolean badflag = FALSE;
+
if (duplicate)
complain_about_duplicate(opts, 1);
if (!negated) {
fullname = "MACgraphics";
if (match_optname(opts, fullname, 3, TRUE)) {
boolean badflag = FALSE;
+
if (duplicate)
complain_about_duplicate(opts, 1);
if (!negated) {
return;
}
#endif
+
/* OK, if we still haven't recognized the option, check the boolean
* options list
*/
*/
for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
opt_indx = pick_list[pick_idx].item.a_int - 1;
- if (opt_indx == -2) { /* -3 due to -1 offset for select_menu() */
+ if (opt_indx == -2) {
+ /* -2 due to -1 offset for select_menu() */
(void) special_handling("autopickup_exception", setinitial,
fromfile);
- } else
#ifdef STATUS_VIA_WINDOWPORT
#ifdef STATUS_HILITES
- if (opt_indx
- == -3) { /* -3 due to -1 offset for select_menu() */
- if (!status_hilite_menu())
+ } else if (opt_indx == -3) {
+ /* -3 due to -1 offset for select_menu() */
+ if (!status_hilite_menu()) {
pline("Bad status hilite(s) specified.");
- else {
+ } else {
if (wc2_supported("status_hilites"))
preference_update("status_hilites");
}
- } else
#endif
#endif
- if (opt_indx == -4) {
- (void) special_handling("menucolors", setinitial, fromfile);
- } else if (opt_indx == -5) {
- (void) special_handling("msgtype", setinitial, fromfile);
+ } else if (opt_indx == -4) {
+ (void) special_handling("menucolors", setinitial,
+ fromfile);
+ } else if (opt_indx == -5) {
+ (void) special_handling("msgtype", setinitial, fromfile);
} else if (opt_indx < boolcount) {
/* boolean option */
Sprintf(buf, "%s%s", *boolopt[opt_indx].addr ? "!" : "",
if (mhattr != -1)
iflags.menu_headings = mhattr;
} else if (!strcmp("msgtype", optname)) {
- int opt_idx, nmt, mttyp;
- char mtbuf[BUFSZ];
+ int opt_idx, nmt, mttyp;
+ char mtbuf[BUFSZ];
msgtypes_again:
- nmt = msgtype_count();
- opt_idx = handle_add_list_remove("message type", nmt);
- if (opt_idx == 3) {
- ; /* done--fall through to function exit */
- } else if (opt_idx == 0) { /* add new */
- getlin("What new message pattern?", mtbuf);
- if (*mtbuf == '\033' || !*mtbuf)
- goto msgtypes_again;
- mttyp = query_msgtype();
- if (mttyp == -1)
- goto msgtypes_again;
+ nmt = msgtype_count();
+ opt_idx = handle_add_list_remove("message type", nmt);
+ if (opt_idx == 3) {
+ ; /* done--fall through to function exit */
+ } else if (opt_idx == 0) { /* add new */
+ getlin("What new message pattern?", mtbuf);
+ if (*mtbuf == '\033' || !*mtbuf)
+ goto msgtypes_again;
+ mttyp = query_msgtype();
+ if (mttyp == -1)
+ goto msgtypes_again;
if (!msgtype_add(mttyp, mtbuf)) {
- pline("Error adding the message type.");
- wait_synch();
- goto msgtypes_again;
- }
- } else { /* list or remove */
+ pline("Error adding the message type.");
+ wait_synch();
+ goto msgtypes_again;
+ }
+ } else { /* list or remove */
int pick_idx, pick_cnt;
int mt_idx;
menu_item *pick_list = (menu_item *) 0;
mt_idx = 0;
while (tmp) {
const char *mtype = msgtype2name(tmp->msgtype);
- any.a_int = (++mt_idx);
+
+ any.a_int = ++mt_idx;
Sprintf(mtbuf, "%-5s \"%s\"", mtype, tmp->pattern);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf,
MENU_UNSELECTED);
Sprintf(mtbuf, "%s message types",
(opt_idx == 1) ? "List of" : "Remove which");
end_menu(tmpwin, mtbuf);
- pick_cnt = select_menu(
- tmpwin, (opt_idx == 1) ? PICK_NONE : PICK_ANY, &pick_list);
+ pick_cnt = select_menu(tmpwin,
+ (opt_idx == 1) ? PICK_NONE : PICK_ANY,
+ &pick_list);
if (pick_cnt > 0) {
for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx)
free_one_msgtype(pick_list[pick_idx].item.a_int - 1
destroy_nhwindow(tmpwin);
if (pick_cnt >= 0)
goto msgtypes_again;
- }
+ }
} else if (!strcmp("menucolors", optname)) {
int opt_idx, nmc, mcclr, mcattr;
char mcbuf[BUFSZ];
else if (!strcmp(optname, "horsename"))
Sprintf(buf, "%s", horsename[0] ? horsename : none);
else if (!strcmp(optname, "map_mode"))
- Sprintf(
- buf, "%s",
- iflags.wc_map_mode == MAP_MODE_TILES
- ? "tiles"
- : iflags.wc_map_mode == MAP_MODE_ASCII4x6
- ? "ascii4x6"
- : iflags.wc_map_mode == MAP_MODE_ASCII6x8
- ? "ascii6x8"
- : iflags.wc_map_mode == MAP_MODE_ASCII8x8
- ? "ascii8x8"
- : iflags.wc_map_mode == MAP_MODE_ASCII16x8
- ? "ascii16x8"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII7x12
- ? "ascii7x12"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII8x12
- ? "ascii8x12"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII16x12
- ? "ascii16x12"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII12x16
- ? "ascii12x16"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII10x18
- ? "asci"
- "i10x"
- "18"
- : iflags.wc_map_mode
- == MAP_MODE_ASCII_FIT_TO_SCREEN
- ? "fit_to_screen"
- : defopt);
+ Sprintf(buf, "%s",
+ iflags.wc_map_mode == MAP_MODE_TILES
+ ? "tiles"
+ : iflags.wc_map_mode == MAP_MODE_ASCII4x6
+ ? "ascii4x6"
+ : iflags.wc_map_mode == MAP_MODE_ASCII6x8
+ ? "ascii6x8"
+ : iflags.wc_map_mode == MAP_MODE_ASCII8x8
+ ? "ascii8x8"
+ : iflags.wc_map_mode == MAP_MODE_ASCII16x8
+ ? "ascii16x8"
+ : iflags.wc_map_mode == MAP_MODE_ASCII7x12
+ ? "ascii7x12"
+ : iflags.wc_map_mode == MAP_MODE_ASCII8x12
+ ? "ascii8x12"
+ : iflags.wc_map_mode
+ == MAP_MODE_ASCII16x12
+ ? "ascii16x12"
+ : iflags.wc_map_mode
+ == MAP_MODE_ASCII12x16
+ ? "ascii12x16"
+ : iflags.wc_map_mode
+ == MAP_MODE_ASCII10x18
+ ? "ascii10x18"
+ : iflags.wc_map_mode
+ == MAP_MODE_ASCII_FIT_TO_SCREEN
+ ? "fit_to_screen"
+ : defopt);
else if (!strcmp(optname, "menustyle"))
Sprintf(buf, "%s", menutype[(int) flags.menu_style]);
else if (!strcmp(optname, "menu_deselect_all"))
: Cmd.swap_yz ? 5 : 0;
Strcpy(buf, numpadmodes[indx]);
- } else if (!strcmp(optname, "objects"))
+ } else if (!strcmp(optname, "objects")) {
Sprintf(buf, "%s", to_be_done);
- else if (!strcmp(optname, "packorder")) {
+ } else if (!strcmp(optname, "packorder")) {
oc_to_str(flags.inv_order, ocl);
Sprintf(buf, "%s", ocl);
- }
#ifdef CHANGE_COLOR
- else if (!strcmp(optname, "palette"))
+ } else if (!strcmp(optname, "palette")) {
Sprintf(buf, "%s", get_color_string());
#endif
- else if (!strcmp(optname, "paranoid_confirmation")) {
+ } else if (!strcmp(optname, "paranoid_confirmation")) {
char tmpbuf[QBUFSZ];
tmpbuf[0] = '\0';
if (ParanoidRemove)
Strcat(tmpbuf, " Remove");
Strcpy(buf, tmpbuf[0] ? &tmpbuf[1] : "none");
- } else if (!strcmp(optname, "pettype"))
- Sprintf(buf, "%s",
- (preferred_pet == 'c')
- ? "cat"
- : (preferred_pet == 'd')
- ? "dog"
- : (preferred_pet == 'h')
- ? "horse"
- : (preferred_pet == 'n') ? "none" : "random");
- else if (!strcmp(optname, "pickup_burden"))
+ } else if (!strcmp(optname, "pettype")) {
+ Sprintf(buf, "%s", (preferred_pet == 'c') ? "cat"
+ : (preferred_pet == 'd') ? "dog"
+ : (preferred_pet == 'h') ? "horse"
+ : (preferred_pet == 'n') ? "none"
+ : "random");
+ } else if (!strcmp(optname, "pickup_burden")) {
Sprintf(buf, "%s", burdentype[flags.pickup_burden]);
- else if (!strcmp(optname, "pickup_types")) {
+ } else if (!strcmp(optname, "pickup_types")) {
oc_to_str(flags.pickup_types, ocl);
Sprintf(buf, "%s", ocl[0] ? ocl : "all");
- } else if (!strcmp(optname, "pile_limit"))
+ } else if (!strcmp(optname, "pile_limit")) {
Sprintf(buf, "%d", flags.pile_limit);
- else if (!strcmp(optname, "playmode")) {
+ } else if (!strcmp(optname, "playmode")) {
Strcpy(buf, wizard ? "debug" : discover ? "explore" : "normal");
- } else if (!strcmp(optname, "race"))
+ } else if (!strcmp(optname, "race")) {
Sprintf(buf, "%s", rolestring(flags.initrace, races, noun));
- else if (!strcmp(optname, "roguesymset")) {
+ } else if (!strcmp(optname, "roguesymset")) {
Sprintf(buf, "%s",
symset[ROGUESET].name ? symset[ROGUESET].name : "default");
if (currentgraphics == ROGUESET && symset[ROGUESET].name)
Strcat(buf, ", active");
- } else if (!strcmp(optname, "role"))
+ } else if (!strcmp(optname, "role")) {
Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m));
- else if (!strcmp(optname, "runmode"))
+ } else if (!strcmp(optname, "runmode")) {
Sprintf(buf, "%s", runmodes[flags.runmode]);
- else if (!strcmp(optname, "scores")) {
+ } else if (!strcmp(optname, "scores")) {
Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around,
flags.end_own ? "/own" : "");
} else if (!strcmp(optname, "scroll_amount")) {
Strcpy(buf, defopt);
} else if (!strcmp(optname, "sortloot")) {
char *sortname = (char *) NULL;
+
for (i = 0; i < SIZE(sortltype) && sortname == (char *) NULL; i++) {
if (flags.sortloot == sortltype[i][0])
sortname = (char *) sortltype[i];
}
if (sortname != (char *) NULL)
Sprintf(buf, "%s", sortname);
- } else if (!strcmp(optname, "player_selection"))
+ } else if (!strcmp(optname, "player_selection")) {
Sprintf(buf, "%s", iflags.wc_player_selection ? "prompts" : "dialog");
#ifdef MSDOS
- else if (!strcmp(optname, "soundcard"))
+ } else if (!strcmp(optname, "soundcard")) {
Sprintf(buf, "%s", to_be_done);
#endif
- else if (!strcmp(optname, "suppress_alert")) {
+ } else if (!strcmp(optname, "suppress_alert")) {
if (flags.suppress_alert == 0L)
Strcpy(buf, none);
else
symset[PRIMARY].name ? symset[PRIMARY].name : "default");
if (currentgraphics == PRIMARY && symset[PRIMARY].name)
Strcat(buf, ", active");
- } else if (!strcmp(optname, "tile_file"))
+ } else if (!strcmp(optname, "tile_file")) {
Sprintf(buf, "%s",
iflags.wc_tile_file ? iflags.wc_tile_file : defopt);
- else if (!strcmp(optname, "tile_height")) {
+ } else if (!strcmp(optname, "tile_height")) {
if (iflags.wc_tile_height)
Sprintf(buf, "%d", iflags.wc_tile_height);
else
Sprintf(buf, "%d", iflags.wc_tile_width);
else
Strcpy(buf, defopt);
- } else if (!strcmp(optname, "traps"))
+ } else if (!strcmp(optname, "traps")) {
Sprintf(buf, "%s", to_be_done);
- else if (!strcmp(optname, "vary_msgcount")) {
+ } else if (!strcmp(optname, "vary_msgcount")) {
if (iflags.wc_vary_msgcount)
Sprintf(buf, "%d", iflags.wc_vary_msgcount);
else
Strcpy(buf, defopt);
- }
#ifdef MSDOS
- else if (!strcmp(optname, "video"))
+ } else if (!strcmp(optname, "video")) {
Sprintf(buf, "%s", to_be_done);
#endif
#ifdef VIDEOSHADES
- else if (!strcmp(optname, "videoshades"))
+ } else if (!strcmp(optname, "videoshades")) {
Sprintf(buf, "%s-%s-%s", shade[0], shade[1], shade[2]);
- else if (!strcmp(optname, "videocolors"))
+ } else if (!strcmp(optname, "videocolors")) {
Sprintf(buf, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",
ttycolors[CLR_RED], ttycolors[CLR_GREEN],
ttycolors[CLR_BROWN], ttycolors[CLR_BLUE],
ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
ttycolors[CLR_BRIGHT_MAGENTA], ttycolors[CLR_BRIGHT_CYAN]);
#endif /* VIDEOSHADES */
- else if (!strcmp(optname, "windowtype"))
+ } else if (!strcmp(optname, "windowtype")) {
Sprintf(buf, "%s", windowprocs.name);
- else if (!strcmp(optname, "windowcolors"))
+ } else if (!strcmp(optname, "windowcolors")) {
Sprintf(
buf, "%s/%s %s/%s %s/%s %s/%s",
iflags.wc_foregrnd_menu ? iflags.wc_foregrnd_menu : defbrief,
iflags.wc_foregrnd_text ? iflags.wc_foregrnd_text : defbrief,
iflags.wc_backgrnd_text ? iflags.wc_backgrnd_text : defbrief);
#ifdef PREFIXES_IN_USE
- else {
+ } else {
for (i = 0; i < PREFIX_COUNT; ++i)
if (!strcmp(optname, fqn_prefix_names[i]) && fqn_prefix[i])
Sprintf(buf, "%s", fqn_prefix[i]);
- }
#endif
+ }
if (buf[0])
return buf;
* (Benefits users whose first exposure to NetHack is via tiles).
*
* prompt
- * The title at the top of the menu.
+ * The title at the top of the menu.
*
* category: 0 = monster class
- * 1 = object class
+ * 1 = object class
*
* way
- * FALSE = PICK_ONE, TRUE = PICK_ANY
+ * FALSE = PICK_ONE, TRUE = PICK_ANY
*
* class_list
- * a null terminated string containing the list of choices.
+ * a null terminated string containing the list of choices.
*
* class_selection
- * a null terminated string containing the selected characters.
+ * a null terminated string containing the selected characters.
*
* Returns number selected.
*/
int status;
{
int k;
+
if (SET__IS_VALUE_VALID(status)) {
impossible("set_option_mod_status: status out of range %d.", status);
return;
int status;
{
int k = 0;
+
if (SET__IS_VALUE_VALID(status)) {
impossible("set_wc_option_mod_status: status out of range %d.",
status);
const char *optnam;
{
int k = 0;
+
while (wc_options[k].wc_name) {
if (strcmp(wc_options[k].wc_name, optnam) == 0)
return TRUE;
const char *optnam;
{
int k = 0;
+
while (wc_options[k].wc_name) {
if (!strcmp(wc_options[k].wc_name, optnam)
&& (windowprocs.wincap & wc_options[k].wc_bit))
int status;
{
int k = 0;
+
if (SET__IS_VALUE_VALID(status)) {
impossible("set_wc2_option_mod_status: status out of range %d.",
status);
const char *optnam;
{
int k = 0;
+
while (wc2_options[k].wc_name) {
if (strcmp(wc2_options[k].wc_name, optnam) == 0)
return TRUE;
const char *optnam;
{
int k = 0;
+
while (wc2_options[k].wc_name) {
if (!strcmp(wc2_options[k].wc_name, optnam)
&& (windowprocs.wincap2 & wc2_options[k].wc_bit))
char *fontname;
{
char **fn = (char **) 0;
+
if (!fontname)
return;
switch (opttype) {
* menu white/black message green/yellow status white/blue text
* white/black
*/
-
int j;
char buf[BUFSZ];
char *wn, *tfg, *tbg, *newop;