diff --git a/src/dbridge.c b/src/dbridge.c index cc38bf641..393831241 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 dbridge.c $NHDT-Date: 1432512770 2015/05/25 00:12:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.32 $ */ -/* Copyright (c) 1989 by Jean-Christophe Collet */ +/* NetHack 3.6 dbridge.c $NHDT-Date: 1446955279 2015/11/08 04:01:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ +/* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ /* @@ -143,22 +143,22 @@ int x, y; lev = &levl[x][y]; if (lev->typ != DOOR && lev->typ != DBWALL) - return (-1); + return -1; if (IS_DRAWBRIDGE(levl[x + 1][y].typ) && (levl[x + 1][y].drawbridgemask & DB_DIR) == DB_WEST) - return (DB_WEST); + return DB_WEST; if (IS_DRAWBRIDGE(levl[x - 1][y].typ) && (levl[x - 1][y].drawbridgemask & DB_DIR) == DB_EAST) - return (DB_EAST); + return DB_EAST; if (IS_DRAWBRIDGE(levl[x][y - 1].typ) && (levl[x][y - 1].drawbridgemask & DB_DIR) == DB_SOUTH) - return (DB_SOUTH); + return DB_SOUTH; if (IS_DRAWBRIDGE(levl[x][y + 1].typ) && (levl[x][y + 1].drawbridgemask & DB_DIR) == DB_NORTH) - return (DB_NORTH); + return DB_NORTH; - return (-1); + return -1; } /* @@ -170,7 +170,7 @@ boolean is_db_wall(x, y) int x, y; { - return ((boolean)(levl[x][y].typ == DBWALL)); + return (boolean) (levl[x][y].typ == DBWALL); } /* @@ -261,14 +261,14 @@ boolean flag; break; default: impossible("bad direction in create_drawbridge"); - /* fall through */ + /*FALLTHRU*/ case DB_WEST: horiz = FALSE; x2--; break; } if (!IS_WALL(levl[x2][y2].typ)) - return (FALSE); + return FALSE; if (flag) { /* We want the bridge open */ levl[x][y].typ = DRAWBRIDGE_DOWN; levl[x2][y2].typ = DOOR; @@ -284,7 +284,7 @@ boolean flag; levl[x][y].drawbridgemask = dir; if (lava) levl[x][y].drawbridgemask |= DB_LAVA; - return (TRUE); + return TRUE; } struct entity { @@ -312,8 +312,8 @@ int x, y; #ifdef D_DEBUG wait_synch(); #endif - return ((entitycnt == ENTITIES) ? (struct entity *) 0 - : &(occupants[entitycnt])); + return (entitycnt == ENTITIES) ? (struct entity *) 0 + : &(occupants[entitycnt]); } STATIC_OVL void @@ -372,7 +372,7 @@ STATIC_OVL const char * e_nam(etmp) struct entity *etmp; { - return (is_u(etmp) ? "you" : mon_nam(etmp->emon)); + return is_u(etmp) ? "you" : mon_nam(etmp->emon); } /* @@ -389,13 +389,13 @@ const char *verb; Strcpy(wholebuf, is_u(etmp) ? "You" : Monnam(etmp->emon)); if (!*verb) - return (wholebuf); + return wholebuf; Strcat(wholebuf, " "); if (is_u(etmp)) Strcat(wholebuf, verb); else Strcat(wholebuf, vtense((char *) 0, verb)); - return (wholebuf); + return wholebuf; } /* @@ -408,20 +408,22 @@ struct entity *etmp; int x, y; { if (noncorporeal(etmp->edata)) - return (TRUE); + return TRUE; if (is_pool(x, y)) - return (boolean)((is_u(etmp) && (Wwalking || Amphibious || Swimming - || Flying || Levitation)) - || is_swimmer(etmp->edata) || is_flyer(etmp->edata) - || is_floater(etmp->edata)); + return (boolean) ((is_u(etmp) && (Wwalking || Amphibious || Swimming + || Flying || Levitation)) + || is_swimmer(etmp->edata) + || is_flyer(etmp->edata) + || is_floater(etmp->edata)); /* must force call to lava_effects in e_died if is_u */ if (is_lava(x, y)) - return (boolean)((is_u(etmp) && (Levitation || Flying)) - || likes_lava(etmp->edata) || is_flyer(etmp->edata)); + return (boolean) ((is_u(etmp) && (Levitation || Flying)) + || likes_lava(etmp->edata) + || is_flyer(etmp->edata)); if (is_db_wall(x, y)) - return ( - (boolean)(is_u(etmp) ? Passes_walls : passes_walls(etmp->edata))); - return (TRUE); + return (boolean) (is_u(etmp) ? Passes_walls + : passes_walls(etmp->edata)); + return TRUE; } STATIC_OVL void @@ -492,8 +494,8 @@ STATIC_OVL boolean automiss(etmp) struct entity *etmp; { - return (boolean)((is_u(etmp) ? Passes_walls : passes_walls(etmp->edata)) - || noncorporeal(etmp->edata)); + return (boolean) ((is_u(etmp) ? Passes_walls : passes_walls(etmp->edata)) + || noncorporeal(etmp->edata)); } /* @@ -510,7 +512,7 @@ boolean chunks; if (chunks) debugpline0("Do chunks miss?"); if (automiss(etmp)) - return (TRUE); + return TRUE; if (is_flyer(etmp->edata) && (is_u(etmp) ? !Unaware @@ -530,7 +532,7 @@ boolean chunks; debugpline1("Miss chance = %d (out of 8)", misses); - return ((boolean)((misses >= rnd(8)) ? TRUE : FALSE)); + return (misses >= rnd(8)) ? TRUE : FALSE; } /* @@ -546,7 +548,7 @@ struct entity *etmp; if (is_u(etmp) ? (Unaware || Fumbling) : (!etmp->emon->mcanmove || etmp->emon->msleeping || !etmp->edata->mmove || etmp->emon->wormno)) - return (FALSE); + return FALSE; if (is_u(etmp) ? Confusion : etmp->emon->mconf) tmp -= 2; @@ -558,7 +560,7 @@ struct entity *etmp; tmp -= 2; /* less room to maneuver */ debugpline2("%s to jump (%d chances in 10)", E_phrase(etmp, "try"), tmp); - return ((boolean)((tmp >= rnd(10)) ? TRUE : FALSE)); + return (tmp >= rnd(10)) ? TRUE : FALSE; } STATIC_OVL void diff --git a/src/dokick.c b/src/dokick.c index cdaf8ab74..1f4d1b42a 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dokick.c $NHDT-Date: 1446808441 2015/11/06 11:14:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */ +/* NetHack 3.6 dokick.c $NHDT-Date: 1446955295 2015/11/08 04:01:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -213,13 +213,13 @@ xchar x, y; } else if (tmp > (kickdieroll = rnd(20))) { You("kick %s.", mon_nam(mon)); sum = damageum(mon, uattk); - (void) passive(mon, (boolean)(sum > 0), (sum != 2), AT_KICK, + (void) passive(mon, (boolean) (sum > 0), (sum != 2), AT_KICK, FALSE); if (sum == 2) break; /* Defender died */ } else { missum(mon, uattk, (tmp + armorpenalty > kickdieroll)); - (void) passive(mon, 0, 1, AT_KICK, FALSE); + (void) passive(mon, FALSE, 1, AT_KICK, FALSE); } } return; diff --git a/src/dungeon.c b/src/dungeon.c index 064798ef5..33843e95b 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dungeon.c $NHDT-Date: 1446808442 2015/11/06 11:14:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ +/* NetHack 3.6 dungeon.c $NHDT-Date: 1446955297 2015/11/08 04:01:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.68 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2539,7 +2539,7 @@ int why, reason, *lastdun_p; /* only print out info for a level or a dungeon if interest */ if (why > 0 || interest_mapseen(mptr)) { - showheader = (boolean)(mptr->lev.dnum != *lastdun_p); + showheader = (boolean) (mptr->lev.dnum != *lastdun_p); print_mapseen(win, mptr, why, reason, showheader); *lastdun_p = mptr->lev.dnum; } diff --git a/src/explode.c b/src/explode.c index 9f32b5e82..08a9a704e 100644 --- a/src/explode.c +++ b/src/explode.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 explode.c $NHDT-Date: 1445388916 2015/10/21 00:55:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ */ -/* Copyright (C) 1990 by Ken Arromdee */ +/* NetHack 3.6 explode.c $NHDT-Date: 1446955298 2015/11/08 04:01:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */ +/* Copyright (C) 1990 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -18,11 +18,11 @@ static int explosion[3][3] = { { S_explode1, S_explode4, S_explode7 }, * these disadvantages.... * * Important note about Half_physical_damage: - * Unlike losehp() , explode() makes the Half_physical_damage adjustments - * itself, so the caller should never have done that ahead of time. - * It has to be done this way because the damage value is applied to - * things beside the player. Care is taken within explode() to ensure - * that Half_physical_damage only affects the damage applied to the hero. + * Unlike losehp(), explode() makes the Half_physical_damage adjustments + * itself, so the caller should never have done that ahead of time. + * It has to be done this way because the damage value is applied to + * things beside the player. Care is taken within explode() to ensure + * that Half_physical_damage only affects the damage applied to the hero. */ void explode(x, y, type, dam, olet, expltype) @@ -48,8 +48,8 @@ int expltype; short exploding_wand_typ = 0; if (olet == WAND_CLASS) { /* retributive strike */ - /* 'type' is passed as (wand's object type * -1); save - object type and convert 'type' itself to zap-type */ + /* 'type' is passed as (wand's object type * -1); save + object type and convert 'type' itself to zap-type */ if (type < 0) { type = -type; exploding_wand_typ = (short) type; @@ -100,9 +100,8 @@ int expltype; adtyp = AD_MAGM; break; case 1: - str = olet == BURNING_OIL ? "burning oil" : olet == SCROLL_CLASS - ? "tower of flame" - : "fireball"; + str = (olet == BURNING_OIL) ? "burning oil" + : (olet == SCROLL_CLASS) ? "tower of flame" : "fireball"; /* fire damage, not physical damage */ adtyp = AD_FIRE; break; @@ -111,8 +110,8 @@ int expltype; adtyp = AD_COLD; break; case 4: - str = - (olet == WAND_CLASS) ? "death field" : "disintegration field"; + str = (olet == WAND_CLASS) ? "death field" + : "disintegration field"; adtyp = AD_DISN; break; case 5: @@ -296,8 +295,8 @@ int expltype; continue; idamres = idamnonres = 0; if (type >= 0 && !u.uswallow) - (void) zap_over_floor((xchar)(i + x - 1), - (xchar)(j + y - 1), type, + (void) zap_over_floor((xchar) (i + x - 1), + (xchar) (j + y - 1), type, &shopdamage, exploding_wand_typ); mtmp = m_at(i + x - 1, j + y - 1); @@ -520,31 +519,31 @@ int expltype; } struct scatter_chain { - struct scatter_chain *next; /* pointer to next scatter item */ - struct obj *obj; /* pointer to the object */ - xchar ox; /* location of */ - xchar oy; /* item */ - schar dx; /* direction of */ - schar dy; /* travel */ - int range; /* range of object */ - boolean stopped; /* flag for in-motion/stopped */ + struct scatter_chain *next; /* pointer to next scatter item */ + struct obj *obj; /* pointer to the object */ + xchar ox; /* location of */ + xchar oy; /* item */ + schar dx; /* direction of */ + schar dy; /* travel */ + int range; /* range of object */ + boolean stopped; /* flag for in-motion/stopped */ }; /* * scflags: - * VIS_EFFECTS Add visual effects to display - * MAY_HITMON Objects may hit monsters - * MAY_HITYOU Objects may hit hero - * MAY_HIT Objects may hit you or monsters - * MAY_DESTROY Objects may be destroyed at random - * MAY_FRACTURE Stone objects can be fractured (statues, boulders) + * VIS_EFFECTS Add visual effects to display + * MAY_HITMON Objects may hit monsters + * MAY_HITYOU Objects may hit hero + * MAY_HIT Objects may hit you or monsters + * MAY_DESTROY Objects may be destroyed at random + * MAY_FRACTURE Stone objects can be fractured (statues, boulders) */ /* returns number of scattered objects */ long scatter(sx, sy, blastforce, scflags, obj) int sx, sy; /* location of objects to scatter */ -int blastforce; /* force behind the scattering */ +int blastforce; /* force behind the scattering */ unsigned int scflags; struct obj *obj; /* only scatter this obj */ { diff --git a/src/files.c b/src/files.c index 5f5e4e199..f9638681c 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1446854228 2015/11/06 23:57:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.185 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1446955299 2015/11/08 04:01:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.186 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3572,7 +3572,7 @@ char *nowin_buf; putstr(tribwin, 0, line); Strcpy(lastline, line); } else if (nowin_buf) { - if ((int)strlen(line) < bufsz-1) + if ((int) strlen(line) < bufsz - 1) Strcpy(nowin_buf, line); } } diff --git a/src/lock.c b/src/lock.c index 3e018fec2..db9a57995 100644 --- a/src/lock.c +++ b/src/lock.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 lock.c $NHDT-Date: 1446808444 2015/11/06 11:14:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */ +/* NetHack 3.6 lock.c $NHDT-Date: 1446955300 2015/11/08 04:01:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.67 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -144,7 +144,7 @@ boolean destroyit; struct monst *shkp = (*u.ushops && costly_spot(u.ux, u.uy)) ? shop_keeper(*u.ushops) : 0; - boolean costly = (boolean)(shkp != 0), + boolean costly = (boolean) (shkp != 0), peaceful_shk = costly && (boolean) shkp->mpeaceful; long loss = 0L; @@ -212,7 +212,7 @@ forcelock(VOID_ARGS) return 1; /* still busy */ You("succeed in forcing the lock."); - breakchestlock(xlock.box, (boolean)(!xlock.picktyp && !rn2(3))); + breakchestlock(xlock.box, (boolean) (!xlock.picktyp && !rn2(3))); exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE); return ((xlock.usedtime = 0)); diff --git a/src/makemon.c b/src/makemon.c index 4917b4079..89b36dc62 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makemon.c $NHDT-Date: 1446808445 2015/11/06 11:14:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */ +/* NetHack 3.6 makemon.c $NHDT-Date: 1446955301 2015/11/08 04:01:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.101 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1274,7 +1274,7 @@ int mmflags; mtmp->isminion = 1; /* make priest be a roamer */ eminp->min_align = rn2(3) - 1; /* no A_NONE */ - eminp->renegade = (boolean)((mmflags & MM_ANGRY) ? 1 : !rn2(3)); + eminp->renegade = (boolean) ((mmflags & MM_ANGRY) ? 1 : !rn2(3)); mtmp->mpeaceful = (eminp->min_align == u.ualign.type) ? !eminp->renegade : eminp->renegade; diff --git a/src/mapglyph.c b/src/mapglyph.c index 8015fa0de..d3e72d790 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -1,5 +1,5 @@ -/* NetHack 3.6 mapglyph.c $NHDT-Date: 1432512766 2015/05/25 00:12:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */ -/* Copyright (c) David Cohrs, 1991 */ +/* NetHack 3.6 mapglyph.c $NHDT-Date: 1446955302 2015/11/08 04:01:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.38 $ */ +/* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" @@ -67,14 +67,14 @@ unsigned *ospecial; unsigned special = 0; /* condense multiple tests in macro version down to single */ boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS; - boolean has_rogue_color = - (has_rogue_ibm_graphics && (symset[currentgraphics].nocolor == 0)); + boolean has_rogue_color = (has_rogue_ibm_graphics + && symset[currentgraphics].nocolor == 0); /* * Map the glyph back to a character and color. * * Warning: For speed, this makes an assumption on the order of - * offsets. The order is set in display.h. + * offsets. The order is set in display.h. */ if ((offset = (glyph - GLYPH_STATUE_OFF)) >= 0) { /* a statue */ idx = mons[offset].mlet + SYM_OFF_M; @@ -83,10 +83,9 @@ unsigned *ospecial; else obj_color(STATUE); special |= MG_STATUE; - if (level.objects[x][y] && level.objects[x][y]->nexthere) - special |= MG_OBJPILE; - } else if ((offset = (glyph - GLYPH_WARNING_OFF)) - >= 0) { /* a warning flash */ + if (level.objects[x][y] && level.objects[x][y]->nexthere) + special |= MG_OBJPILE; + } else if ((offset = (glyph - GLYPH_WARNING_OFF)) >= 0) { /* warn flash */ idx = offset + SYM_OFF_W; if (has_rogue_color) color = NO_COLOR; @@ -151,8 +150,9 @@ unsigned *ospecial; } } else obj_color(offset); - if (offset != BOULDER && level.objects[x][y] && level.objects[x][y]->nexthere) - special |= MG_OBJPILE; + if (offset != BOULDER && level.objects[x][y] + && level.objects[x][y]->nexthere) + special |= MG_OBJPILE; } else if ((offset = (glyph - GLYPH_RIDDEN_OFF)) >= 0) { /* mon ridden */ idx = mons[offset].mlet + SYM_OFF_M; if (has_rogue_color) @@ -170,8 +170,8 @@ unsigned *ospecial; else mon_color(offset); special |= MG_CORPSE; - if (level.objects[x][y] && level.objects[x][y]->nexthere) - special |= MG_OBJPILE; + if (level.objects[x][y] && level.objects[x][y]->nexthere) + special |= MG_OBJPILE; } else if ((offset = (glyph - GLYPH_DETECT_OFF)) >= 0) { /* mon detect */ idx = mons[offset].mlet + SYM_OFF_M; if (has_rogue_color) @@ -199,17 +199,16 @@ unsigned *ospecial; idx = mons[glyph].mlet + SYM_OFF_M; if (has_rogue_color && iflags.use_color) { if (x == u.ux && y == u.uy) - /* actually player should be yellow-on-gray if in a corridor - */ + /* actually player should be yellow-on-gray if in corridor */ color = CLR_YELLOW; else color = NO_COLOR; } else { mon_color(glyph); -/* special case the hero for `showrace' option */ #ifdef TEXTCOLOR - if (iflags.use_color && x == u.ux && y == u.uy && flags.showrace - && !Upolyd) + /* special case the hero for `showrace' option */ + if (iflags.use_color && x == u.ux && y == u.uy + && flags.showrace && !Upolyd) color = HI_DOMESTIC; #endif } @@ -235,6 +234,7 @@ encglyph(glyph) int glyph; { static char encbuf[20]; + Sprintf(encbuf, "\\G%04X%04X", context.rndencode, glyph); return encbuf; } @@ -242,7 +242,7 @@ int glyph; /* * This differs from putstr() because the str parameter can * contain a sequence of characters representing: - * \GXXXXNNNN a glyph value, encoded by encglyph(). + * \GXXXXNNNN a glyph value, encoded by encglyph(). * * For window ports that haven't yet written their own * XXX_putmixed() routine, this general one can be used. @@ -260,6 +260,7 @@ const char *str; char buf[BUFSZ]; const char *cp = str; char *put = buf; + while (*cp) { if (*cp == '\\') { int rndchk = 0, so = 0, gv = 0, ch, oc, dcount; @@ -288,18 +289,19 @@ const char *str; } break; #if 0 - case 'S': /* symbol offset */ - dcount = 0; - for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++) - rndchk = (int)((rndchk * 16) + ((int)(dp - hex) / 2)); - - if (rndchk == context.rndencode) { - dcount = 0; - for (; *cp && (dp = index(hex, *cp)) && (dcount++ < 2); cp++) - so = (int)((so * 16) + ((int)(dp - hex) / 2)); - } - *put++ = showsyms[so]; - break; + case 'S': /* symbol offset */ + dcount = 0; + for (++cp; *cp && (dp = index(hex, *cp)) != 0 && dcount++ < 4; + cp++) + rndchk = (int) ((rndchk * 16) + ((int) (dp - hex) / 2)); + if (rndchk == context.rndencode) { + dcount = 0; + for (; *cp && (dp = index(hex, *cp)) != 0 && dcount++ < 2; + cp++) + so = (int) ((so * 16) + ((int) (dp - hex) / 2)); + } + *put++ = showsyms[so]; + break; #endif case '\\': break;