diff --git a/src/allmain.c b/src/allmain.c index 024867dc8..058e7e905 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -320,7 +320,8 @@ moveloop_core(void) } } - if (!svl.level.flags.noautosearch && Searching && gm.multi >= 0) + if (Searching && !svl.level.flags.noautosearch + && gm.multi >= 0) (void) dosearch0(1); if (Warning) warnreveal(); @@ -751,7 +752,7 @@ newgame(void) * any artifacts */ u_init(); - l_nhcore_init(); /* create a Lua state that lasts until the end of the game */ + l_nhcore_init(); /* create a Lua state that lasts until end of game */ reset_glyphmap(gm_newgame); #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); @@ -828,11 +829,12 @@ welcome(boolean new_game) /* false => restoring an old game */ Sprintf(eos(buf), " %s", align_str(u.ualignbase[A_ORIGINAL])); if (!gu.urole.name.f && (new_game - ? (gu.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) - : currentgend != flags.initgend)) + ? (gu.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) + : currentgend != flags.initgend)) Sprintf(eos(buf), " %s", genders[currentgend].adj); Sprintf(eos(buf), " %s %s", gu.urace.adj, - (currentgend && gu.urole.name.f) ? gu.urole.name.f : gu.urole.name.m); + (currentgend && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m); pline(new_game ? "%s %s, welcome to NetHack! You are a%s." : "%s %s, the%s, welcome back to NetHack!", @@ -1242,11 +1244,13 @@ dump_enums(void) objclass_syms_dump, arti_enum_dump, }; - static const char *const pfx[NUM_ENUM_DUMPS] = { "PM_", "", "", - "", "", "", "", - "", "", "" }; + static const char *const pfx[NUM_ENUM_DUMPS] = { + "PM_", "", "", "", "", "", "", "", "", "" + }; /* 0 = dump numerically only, 1 = add 'char' comment */ - static const int dumpflgs[NUM_ENUM_DUMPS] = { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }; + static const int dumpflgs[NUM_ENUM_DUMPS] = { + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 + }; static int szd[NUM_ENUM_DUMPS] = { SIZE(monsdump), SIZE(objdump), SIZE(omdump), SIZE(defsym_cmap_dump), SIZE(defsym_mon_syms_dump), diff --git a/src/apply.c b/src/apply.c index bf867c3e5..2edc474f2 100644 --- a/src/apply.c +++ b/src/apply.c @@ -947,7 +947,8 @@ check_leash(coordxy x, coordxy y) if (!DEADMONSTER(mtmp)) u.uconduct.killer = save_pacifism; } else { - pline_mon(mtmp, "%s is choked by the leash!", Monnam(mtmp)); + pline_mon(mtmp, "%s is choked by the leash!", + Monnam(mtmp)); /* tameness eventually drops to 1 here (never 0) */ if (mtmp->mtame && rn2(mtmp->mtame)) mtmp->mtame--; @@ -1428,7 +1429,8 @@ use_candle(struct obj **optr) else if (!otmp->lamplit && was_lamplit) pline("%s out.", (obj->quan > 1L) ? "They go" : "It goes"); if (obj->unpaid) { - struct monst *shkp VOICEONLY = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); + struct monst *shkp VOICEONLY + = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); SetVoice(shkp, 0, 80, 0); verbalize("You %s %s, you bought %s!", @@ -1590,7 +1592,8 @@ catch_lit(struct obj *obj) if (obj->otyp == POT_OIL) makeknown(obj->otyp); if (carried(obj) && obj->unpaid && costly_spot(u.ux, u.uy)) { - struct monst *shkp VOICEONLY = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); + struct monst *shkp VOICEONLY + = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); /* if it catches while you have it, then it's your tough luck */ check_unpaid(obj); @@ -1670,7 +1673,8 @@ use_lamp(struct obj *obj) if (obj->unpaid && costly_spot(u.ux, u.uy) && obj->age == 20L * (long) objects[obj->otyp].oc_cost) { const char *ithem = (obj->quan > 1L) ? "them" : "it"; - struct monst *shkp VOICEONLY = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); + struct monst *shkp VOICEONLY + = shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE)); SetVoice(shkp, 0, 80, 0); verbalize("You burn %s, you bought %s!", ithem, ithem); diff --git a/src/artifact.c b/src/artifact.c index c02a6cfb7..a693bc159 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -14,7 +14,7 @@ * the contents, just the total size. */ -staticfn struct artifact *get_artifact(struct obj *) NONNULL; /* never returns null */ +staticfn struct artifact *get_artifact(struct obj *) NONNULL; /* #define get_artifact(o) \ (((o) && ((o)->artifact > 0 && (o)->artifact < AFTER_LAST_ARTIFACT)) \ @@ -2041,7 +2041,8 @@ finesse_ahriman(struct obj *obj) /* if we aren't levitating or this isn't an artifact which confers levitation via #invoke then freeinv() won't toggle levitation */ - if (!Levitation || (oart = get_artifact(obj)) == &artilist[ART_NONARTIFACT] + if (!Levitation + || (oart = get_artifact(obj)) == &artilist[ART_NONARTIFACT] || oart->inv_prop != LEVITATION || !(ELevitation & W_ARTI)) return FALSE; @@ -2258,7 +2259,9 @@ glow_verb(int count, /* 0 means blind rather than no applicable creatures */ /* use for warning "glow" for Sting, Orcrist, and Grimtooth */ void -Sting_effects(int orc_count) /* new count (warn_obj_cnt is old count); -1 is a flag value */ +Sting_effects( + int orc_count) /* new count (warn_obj_cnt is old count); + * -1 is a flag value */ { if (u_wield_art(ART_STING) || u_wield_art(ART_ORCRIST) @@ -2501,8 +2504,7 @@ staticfn int count_surround_traps(coordxy x, coordxy y) { struct rm *levp; - struct obj *otmp; - struct trap *ttmp; + struct obj *o; coordxy dx, dy; int glyph, ret = 0; @@ -2518,7 +2520,7 @@ count_surround_traps(coordxy x, coordxy y) glyph = glyph_at(dx, dy); if (glyph_is_trap(glyph)) continue; - if ((ttmp = t_at(dx, dy)) != 0) { + if (t_at(dx, dy)) { ++ret; continue; } @@ -2527,8 +2529,8 @@ count_surround_traps(coordxy x, coordxy y) ++ret; continue; } - for (otmp = svl.level.objects[dx][dy]; otmp; otmp = otmp->nexthere) - if (Is_container(otmp) && otmp->otrapped) { + for (o = svl.level.objects[dx][dy]; o; o = o->nexthere) + if (Is_container(o) && o->otrapped) { ++ret; /* we're counting locations, so just */ break; /* count the first one in a pile */ } diff --git a/src/attrib.c b/src/attrib.c index 32581990e..ccd5af9a7 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -405,8 +405,10 @@ change_luck(schar n) u.uluck = LUCKMAX; } +/* decide whether there are more blessed luckstones (plus luck-conferring + artifacts) than cursed ones; optionally combine uncursed with blessed */ int -stone_luck(boolean parameter) /* So I can't think up of a good name. So sue me. --KAA */ +stone_luck(boolean include_uncursed) { struct obj *otmp; long bonchance = 0; @@ -415,9 +417,7 @@ stone_luck(boolean parameter) /* So I can't think up of a good name. So sue me. if (confers_luck(otmp)) { if (otmp->cursed) bonchance -= otmp->quan; - else if (otmp->blessed) - bonchance += otmp->quan; - else if (parameter) + else if (otmp->blessed || include_uncursed) bonchance += otmp->quan; } diff --git a/src/ball.c b/src/ball.c index f09a45efa..1ff2cc339 100644 --- a/src/ball.c +++ b/src/ball.c @@ -868,8 +868,6 @@ drag_ball(coordxy x, coordxy y, int *bc_control, return TRUE; } -DISABLE_WARNING_FORMAT_NONLITERAL - /* * drop_ball() * @@ -890,7 +888,7 @@ drop_ball(coordxy x, coordxy y) } if (x != u.ux || y != u.uy) { - static const char *const pullmsg = "The ball pulls you out of the %s!"; + static const char pullmsg[] = "The ball pulls you out of the "; struct trap *t; long side; @@ -898,20 +896,20 @@ drop_ball(coordxy x, coordxy y) && u.utraptype != TT_INFLOOR && u.utraptype != TT_BURIEDBALL) { switch (u.utraptype) { case TT_PIT: - pline(pullmsg, "pit"); + pline("%s%s!", pullmsg, "pit"); break; case TT_WEB: - pline(pullmsg, "web"); + pline("%s%s!", pullmsg, "web"); Soundeffect(se_destroy_web, 30); pline_The("web is destroyed!"); deltrap(t_at(u.ux, u.uy)); break; case TT_LAVA: - pline(pullmsg, hliquid("lava")); + pline("%s%s!", pullmsg, hliquid("lava")); break; case TT_BEARTRAP: side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE; - pline(pullmsg, "bear trap"); + pline("%s%s!", pullmsg, "bear trap"); set_wounded_legs(side, rn1(1000, 500)); if (!u.usteed) { Your("%s %s is severely damaged.", @@ -940,7 +938,7 @@ drop_ball(coordxy x, coordxy y) u.ux = x - u.dx; u.uy = y - u.dy; } - gv.vision_full_recalc = 1; /* hero has moved, recalculate vision later */ + gv.vision_full_recalc = 1; /* hero has moved, recalc vision later */ if (Blind) { /* drop glyph under the chain */ @@ -961,8 +959,6 @@ drop_ball(coordxy x, coordxy y) } } -RESTORE_WARNING_FORMAT_NONLITERAL - /* ball&chain cause hero to randomly lose stuff from inventory */ staticfn void litter(void) diff --git a/src/bones.c b/src/bones.c index 2fce425ed..963c6d8f9 100644 --- a/src/bones.c +++ b/src/bones.c @@ -94,7 +94,7 @@ resetobjs(struct obj *ochain, boolean restore) result depends upon hero's location */ && inside_shop(ox, oy) && *(p = in_rooms(ox, oy, SHOPBASE)) - && tended_shop(&svr.rooms[*p - ROOMOFFSET])); + && tended_shop(&svr.rooms[*p - ROOMOFFSET])); } } else { /* saving */ /* do not zero out o_ids for ghost levels anymore */ diff --git a/src/botl.c b/src/botl.c index f3230cab7..21692d4bb 100644 --- a/src/botl.c +++ b/src/botl.c @@ -2276,7 +2276,7 @@ get_hilite( txtstr = gb.blstats[idx][fldidx].val; if (fldidx == BL_TITLE) /* " the ", skip past " the " */ - txtstr += (strlen(svp.plname) + sizeof " the " - sizeof ""); + txtstr += strlen(svp.plname) + sizeof " the " - sizeof ""; if (hl->rel == TXT_VALUE && hl->textmatch[0]) { if (fuzzymatch(hl->textmatch, txtstr, "\" -_", TRUE)) { rule = hl; @@ -2697,7 +2697,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) is_out_of_range); return FALSE; } else if (dt == ANY_LONG - && (hilite.value.a_long < (grt ? -1L : lt ? 1L : 0L))) { + && hilite.value.a_long < (grt ? -1L : lt ? 1L : 0L)) { config_error_add("%s'%s%ld'%s", threshold_value, op, hilite.value.a_long, is_out_of_range); return FALSE; @@ -3509,7 +3509,8 @@ status_hilite_menu_choose_behavior(int fld) if (fld == BL_HP) { any = cg.zeroany; any.a_int = onlybeh = BL_TH_CRITICALHP; - Sprintf(buf, "Highlight critically low %s", initblstats[fld].fldname); + Sprintf(buf, "Highlight critically low %s", + initblstats[fld].fldname); add_menu(tmpwin, &nul_glyphinfo, &any, 'C', 0, ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE); nopts++; diff --git a/src/cmd.c b/src/cmd.c index cd2b4b135..d00f10ec6 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -215,18 +215,30 @@ set_occupation(int (*fn)(void), const char *txt, cmdcount_nht xtime) void cmdq_print(int q) { - struct _cmd_queue *cq = gc.command_queue[q]; char buf[QBUFSZ]; + struct _cmd_queue *cq = gc.command_queue[q]; pline("CQ:%i", q); while (cq) { switch (cq->typ) { - case CMDQ_KEY: pline("(key:%s)", key2txt(cq->key, buf)); break; - case CMDQ_EXTCMD: pline("(extcmd:#%s)", cq->ec_entry->ef_txt); break; - case CMDQ_DIR: pline("(dir:%i,%i,%i)", cq->dirx, cq->diry, cq->dirz); break; - case CMDQ_USER_INPUT: pline1("(userinput)"); break; - case CMDQ_INT: pline("(int:%i)", cq->intval); break; - default: pline("(ERROR:%i)",cq->typ); break; + case CMDQ_KEY: + pline("(key:%s)", key2txt(cq->key, buf)); + break; + case CMDQ_EXTCMD: + pline("(extcmd:#%s)", cq->ec_entry->ef_txt); + break; + case CMDQ_DIR: + pline("(dir:%i,%i,%i)", cq->dirx, cq->diry, cq->dirz); + break; + case CMDQ_USER_INPUT: + pline("(userinput)"); + break; + case CMDQ_INT: + pline("(int:%i)", cq->intval); + break; + default: + pline("(ERROR:%i)",cq->typ); + break; } cq = cq->next; } @@ -878,7 +890,8 @@ domonability(void) char c = '\0'; if (might_hide && webmaker(uptr)) { - c = yn_function("Hide [h] or spin a web [s]?", hidespinchars, 'q', TRUE); + c = yn_function("Hide [h] or spin a web [s]?", + hidespinchars, 'q', TRUE); if (c == 'q' || c == '\033') return ECMD_OK; } @@ -2198,7 +2211,8 @@ bindit: pline("Changed key '%s' from \"%s\" to \"%s\".", key2txt(key, buf2), prevec->ef_txt, cmdstr); } else if (!prevec) { - pline("Bound key '%s' to \"%s\".", key2txt(key, buf2), cmdstr); + pline("Bound key '%s' to \"%s\".", + key2txt(key, buf2), cmdstr); } } else { pline("Key binding failed?!"); @@ -3371,7 +3385,8 @@ rhack(int key) pline( "The '%s' prefix should be followed by a movement command%s.", - which, (up || down) ? " other than up or down" : ""); + which, + (up || down) ? " other than up or down" : ""); } res = ECMD_FAIL; prefix_seen = 0; @@ -3620,7 +3635,8 @@ getdir(const char *s) if (!cmdq->dirz) { dirsym = gc.Cmd.dirchars[xytod(cmdq->dirx, cmdq->diry)]; } else { - dirsym = gc.Cmd.dirchars[(cmdq->dirz > 0) ? DIR_DOWN : DIR_UP]; + dirsym = gc.Cmd.dirchars[(cmdq->dirz > 0) ? DIR_DOWN + : DIR_UP]; } } else if (cmdq->typ == CMDQ_KEY) { dirsym = cmdq->key; @@ -3734,7 +3750,7 @@ getdir(const char *s) did_help = help_dir((s && *s == '^') ? dirsym : '\0', gc.Cmd.spkeys[NHKF_ESC], help_requested ? (const char *) 0 - : "Invalid direction key!"); + : "Invalid direction key!"); if (help_requested) goto retry; } diff --git a/src/dbridge.c b/src/dbridge.c index 565572ef2..8e2f081bd 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -287,8 +287,9 @@ e_at(coordxy x, coordxy y) int entitycnt; for (entitycnt = 0; entitycnt < ENTITIES; entitycnt++) - if ((go.occupants[entitycnt].edata) && (go.occupants[entitycnt].ex == x) - && (go.occupants[entitycnt].ey == y)) + if (go.occupants[entitycnt].edata + && go.occupants[entitycnt].ex == x + && go.occupants[entitycnt].ey == y) break; debugpline1("entitycnt = %d", entitycnt); #ifdef D_DEBUG diff --git a/src/dig.c b/src/dig.c index 309f06a67..ed0879683 100644 --- a/src/dig.c +++ b/src/dig.c @@ -371,7 +371,8 @@ dig(void) if (svc.context.digging.down) { struct trap *ttmp = t_at(dpx, dpy); - if (svc.context.digging.effort > 250 || (ttmp && ttmp->ttyp == HOLE)) { + if (svc.context.digging.effort > 250 + || (ttmp && ttmp->ttyp == HOLE)) { (void) dighole(FALSE, FALSE, (coord *) 0); (void) memset((genericptr_t) &svc.context.digging, 0, sizeof svc.context.digging); @@ -491,7 +492,8 @@ dig(void) } if (svl.level.flags.is_maze_lev) { lev->typ = ROOM, lev->flags = 0; - } else if (svl.level.flags.is_cavernous_lev && !in_town(dpx, dpy)) { + } else if (svl.level.flags.is_cavernous_lev + && !in_town(dpx, dpy)) { lev->typ = CORR, lev->flags = 0; } else { lev->typ = DOOR, lev->doormask = D_NODOOR; @@ -1287,7 +1289,8 @@ use_pick_axe2(struct obj *obj) || svc.context.digging.down) { if (flags.autodig && dig_target == DIGTYP_ROCK && !svc.context.digging.down - && u_at(svc.context.digging.pos.x, svc.context.digging.pos.y) + && u_at(svc.context.digging.pos.x, + svc.context.digging.pos.y) && (svm.moves <= svc.context.digging.lastdigtime + 2 && svm.moves >= svc.context.digging.lastdigtime)) { /* avoid messages if repeated autodigging */ @@ -1333,7 +1336,8 @@ use_pick_axe2(struct obj *obj) surface(u.ux, u.uy)); u_wipe_engr(3); } else { - if (svc.context.digging.pos.x != u.ux || svc.context.digging.pos.y != u.uy + if (svc.context.digging.pos.x != u.ux + || svc.context.digging.pos.y != u.uy || !on_level(&svc.context.digging.level, &u.uz) || !svc.context.digging.down) { svc.context.digging.chew = FALSE; diff --git a/src/display.c b/src/display.c index 1c22ebbfe..71ce67766 100644 --- a/src/display.c +++ b/src/display.c @@ -1592,7 +1592,8 @@ see_traps(void) } /* glyph, ttychar, framecolor, - { glyphflags, { NO_COLOR, sym.symidx }, customcolor, color256idx, tileidx, u } */ + { glyphflags, { NO_COLOR, sym.symidx }, + customcolor, color256idx, tileidx, u } */ static glyph_info no_ginfo = { NO_GLYPH, ' ', NO_COLOR, { MG_BADXY, { NO_COLOR, 0 }, @@ -2086,7 +2087,8 @@ clear_glyph_buffer(void) || giptr->gm.sym.color != nul_gbuf.glyphinfo.gm.sym.color || giptr->gm.glyphflags != nul_gbuf.glyphinfo.gm.glyphflags - || giptr->gm.customcolor != nul_gbuf.glyphinfo.gm.customcolor + || giptr->gm.customcolor + != nul_gbuf.glyphinfo.gm.customcolor || giptr->gm.tileidx != nul_gbuf.glyphinfo.gm.tileidx) #else nul_gbuf.gnew = (giptr->ttychar != ' ' @@ -2211,9 +2213,11 @@ flush_screen(int cursor_on_u) if (gptr->gnew || (gw.wsettings.map_frame_color != NO_COLOR && bkglyphinfo.framecolor != NO_COLOR)) { - map_glyphinfo(x, y, bkglyph, 0, &bkglyphinfo); /* won't touch framecolor */ + /* map_glyphinfo() won't touch framecolor */ + map_glyphinfo(x, y, bkglyph, 0, &bkglyphinfo); print_glyph(WIN_MAP, x, y, - Glyphinfo_at(x, y, gptr->glyphinfo.glyph), &bkglyphinfo); + Glyphinfo_at(x, y, gptr->glyphinfo.glyph), + &bkglyphinfo); gptr->gnew = 0; } } @@ -2509,7 +2513,7 @@ get_bkglyph_and_framecolor( } if (!cansee(x, y) && (!lev->waslit || flags.dark_room)) { - /* Floor spaces are dark if unlit. Corridors are dark if unlit. */ + /* Floor spaces and corridors are dark if unlit. */ if (lev->typ == CORR && idx == S_litcorr) idx = S_corr; else if (idx == S_room) @@ -3126,7 +3130,9 @@ set_twall( #else coordxy x0 UNUSED, coordxy y0 UNUSED, #endif - coordxy x1, coordxy y1, coordxy x2, coordxy y2, coordxy x3, coordxy y3) + coordxy x1, coordxy y1, + coordxy x2, coordxy y2, + coordxy x3, coordxy y3) { int wmode, is_1, is_2, is_3; @@ -3164,7 +3170,11 @@ set_wall(coordxy x, coordxy y, int horiz) /* Return a wall mode for a corner wall. (x4,y4) is the "inner" position. */ staticfn int -set_corn(coordxy x1, coordxy y1, coordxy x2, coordxy y2, coordxy x3, coordxy y3, coordxy x4, coordxy y4) +set_corn( + coordxy x1, coordxy y1, + coordxy x2, coordxy y2, + coordxy x3, coordxy y3, + coordxy x4, coordxy y4) { coordxy wmode, is_1, is_2, is_3, is_4;