diff --git a/include/extern.h b/include/extern.h index 8b4fa0835..619c20141 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1945,8 +1945,8 @@ E int NDECL(randrole); E int FDECL(randrace, (int)); E int FDECL(randgend, (int, int)); E int FDECL(randalign, (int, int)); -E int FDECL(str2role, (char *)); -E int FDECL(str2race, (char *)); +E int FDECL(str2role, (const char *)); +E int FDECL(str2race, (const char *)); E int FDECL(str2gend, (char *)); E int FDECL(str2align, (char *)); E boolean FDECL(ok_role, (int, int, int, int)); diff --git a/include/objclass.h b/include/objclass.h index 91171e429..8b9a58de2 100644 --- a/include/objclass.h +++ b/include/objclass.h @@ -111,8 +111,8 @@ struct objclass { struct class_sym { char sym; - char *name; - char *explain; + const char *name; + const char *explain; }; struct objdescr { diff --git a/src/botl.c b/src/botl.c index 9761fdffd..5cbac1050 100644 --- a/src/botl.c +++ b/src/botl.c @@ -33,7 +33,7 @@ STATIC_OVL int FDECL(percentage, (struct istat_s *, struct istat_s *)); STATIC_OVL int FDECL(compare_blstats, (struct istat_s *, struct istat_s *)); # ifdef STATUS_HILITES STATIC_DCL boolean FDECL(assign_hilite, (char *, char *, char *, char *)); -STATIC_DCL char *FDECL(clridx_to_s, (char *, int)); +STATIC_DCL const char *FDECL(clridx_to_s, (char *, int)); # endif #else STATIC_DCL void NDECL(bot1); @@ -81,12 +81,12 @@ rank_of(lev, monnum, female) short monnum; boolean female; { - register struct Role *role; + register const struct Role *role; register int i; /* Find the role */ - for (role = (struct Role *) roles; role->name.m; role++) + for (role = roles; role->name.m; role++) if (monnum == role->malenum || monnum == role->femalenum) break; if (!role->name.m) @@ -937,8 +937,8 @@ clear_status_hilites() } STATIC_OVL boolean -assign_hilite(a,b,c,d) -char *a, *b, *c, *d; +assign_hilite(sa,sb,sc,sd) +char *sa, *sb, *sc, *sd; { char *tmp, *how; int i, dt, idx = -1; @@ -946,7 +946,7 @@ char *a, *b, *c, *d; boolean inverse[2] = {FALSE, FALSE}; boolean bold[2] = {FALSE, FALSE}; boolean normal[2] = {0,0}; - boolean percentage = FALSE, down_up = FALSE, changed = FALSE; + boolean percent = FALSE, down_up = FALSE, changed = FALSE; anything threshold; threshold.a_void = 0; @@ -956,8 +956,8 @@ char *a, *b, *c, *d; */ /* field name to idx */ - for (i = 0; a && i < MAXBLSTATS; ++i) { - if (strcmpi(a,status_fieldnames[i]) == 0) { + for (i = 0; sa && i < MAXBLSTATS; ++i) { + if (strcmpi(sa,status_fieldnames[i]) == 0) { idx = i; break; } @@ -966,43 +966,43 @@ char *a, *b, *c, *d; status_hilites[idx].set = FALSE; /* mark it "unset" */ /* threshold */ - if (!b) return FALSE; - if ((strcmpi(b, "updown") == 0) || (strcmpi(b, "downup") == 0) || - (strcmpi(b, "up") == 0) || (strcmpi(b, "down") == 0)) { + if (!sb) return FALSE; + if ((strcmpi(sb, "updown") == 0) || (strcmpi(sb, "downup") == 0) || + (strcmpi(sb, "up") == 0) || (strcmpi(sb, "down") == 0)) { down_up = TRUE; - } else if ((strcmpi(b, "changed") == 0) && + } else if ((strcmpi(sb, "changed") == 0) && (idx == BL_TITLE || idx == BL_ALIGN || idx == BL_LEVELDESC || idx == BL_CONDITION)) { changed = TRUE; /* changed is only thing allowed */ } else { - tmp = b; + tmp = sb; while (*tmp) { if (*tmp == '%') { *tmp = '\0'; - percentage = TRUE; + percent = TRUE; break; } else if (!index("0123456789", *tmp)) return FALSE; tmp++; } - if (strlen(b) > 0) { + if (strlen(sb) > 0) { dt = blstats[0][idx].anytype; - if (percentage) dt = ANY_INT; - (void) s_to_anything(&threshold, b, dt); + if (percent) dt = ANY_INT; + (void) s_to_anything(&threshold, sb, dt); } else return FALSE; - if (percentage && + if (percent && (threshold.a_int < 1 || threshold.a_int > 100)) return FALSE; - if (!threshold.a_void && (strcmp(b, "0") != 0)) return FALSE; + if (!threshold.a_void && (strcmp(sb, "0") != 0)) return FALSE; } /* actions */ for (i = 0; i < 2; ++i) { - if (!i) how = c; - else how = d; + if (!i) how = sc; + else how = sd; if (!how) { if (!i) return FALSE; - else break; /* c is mandatory; d is not */ + else break; /* sc is mandatory; sd is not */ } if (strcmpi(how, "bold") == 0) { @@ -1038,7 +1038,7 @@ char *a, *b, *c, *d; else status_hilites[idx].coloridx[i] = BL_HILITE_NONE; } - if (percentage) + if (percent) status_hilites[idx].behavior = BL_TH_VAL_PERCENTAGE; else if (down_up) status_hilites[idx].behavior = BL_TH_UPDOWN; @@ -1150,12 +1150,12 @@ int bufsiz; return buf; } -STATIC_OVL char * +STATIC_OVL const char * clridx_to_s(buf, idx) char *buf; int idx; { - char *a[] = {"bold", "inverse", "normal"}; + const char *a[] = {"bold", "inverse", "normal"}; if (buf) { buf[0] = '\0'; @@ -1280,7 +1280,7 @@ status_hilite_menu() for (j = 0; j < 2 && (hltemp[i].behavior != BL_TH_NONE); ++j) { char prompt[QBUFSZ]; /* j == 0 below, j == 1 above */ - menu_item *pick = (menu_item *)0; + menu_item *pick2 = (menu_item *)0; Sprintf(prompt, "Display how when %s?", j ? above : below); tmpwin = create_nhwindow(NHW_MENU); @@ -1303,11 +1303,11 @@ status_hilite_menu() MENU_UNSELECTED); } end_menu(tmpwin, prompt); - if ((res = select_menu(tmpwin, PICK_ONE, &pick)) > 0) { - hltemp[i].coloridx[j] = (pick->item.a_char > 0) ? - pick->item.a_int - 1 : - pick->item.a_int; - free((genericptr_t)pick); + if ((res = select_menu(tmpwin, PICK_ONE, &pick2)) > 0) { + hltemp[i].coloridx[j] = (pick2->item.a_char > 0) ? + pick2->item.a_int - 1 : + pick2->item.a_int; + free((genericptr_t)pick2); } destroy_nhwindow(tmpwin); if (res < 0) return FALSE; @@ -1437,18 +1437,18 @@ genericptr_t ptr; } } - /* This genl version updates everything on the display, evertime */ + /* This genl version updates everything on the display, everytime */ newbot1[0] = '\0'; for (i = 0; fieldorder1[i] >= 0; ++i) { - int idx = fieldorder1[i]; - if (activefields[idx]) - Strcat(newbot1, vals[idx]); + int idx1 = fieldorder1[i]; + if (activefields[idx1]) + Strcat(newbot1, vals[idx1]); } newbot2[0] = '\0'; for (i = 0; fieldorder2[i] >= 0; ++i) { - int idx = fieldorder2[i]; - if (activefields[idx]) - Strcat(newbot2, vals[idx]); + int idx2 = fieldorder2[i]; + if (activefields[idx2]) + Strcat(newbot2, vals[idx2]); } curs(WIN_STATUS, 1, 0); putstr(WIN_STATUS, 0, newbot1); diff --git a/src/cmd.c b/src/cmd.c index 58d404dfa..4d751d30d 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1086,16 +1086,16 @@ int propindx; /* index of a property which can be conveyed by worn item */ /* format a characteristic value, accommodating Strength's strangeness */ STATIC_OVL char * -attrval(attrindx, attrval, resultbuf) -int attrindx, attrval; +attrval(attrindx, attrvalue, resultbuf) +int attrindx, attrvalue; char resultbuf[]; /* should be at least [7] to hold "18/100\0" */ { - if (attrindx != A_STR || attrval <= 18) - Sprintf(resultbuf, "%d", attrval); - else if (attrval > STR18(100)) /* 19 to 25 */ - Sprintf(resultbuf, "%d", attrval - 100); + if (attrindx != A_STR || attrvalue <= 18) + Sprintf(resultbuf, "%d", attrvalue); + else if (attrvalue > STR18(100)) /* 19 to 25 */ + Sprintf(resultbuf, "%d", attrvalue - 100); else /* simplify "18/ **" to be "18/100" */ - Sprintf(resultbuf, "18/%02d", attrval - 18); + Sprintf(resultbuf, "18/%02d", attrvalue - 18); return resultbuf; } diff --git a/src/dbridge.c b/src/dbridge.c index 2e5cfe9f4..e85e2b0da 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -857,7 +857,7 @@ int x,y; lev2 = &levl[x2][y2]; if ((lev1->drawbridgemask & DB_UNDER) == DB_MOAT || (lev1->drawbridgemask & DB_UNDER) == DB_LAVA) { - struct obj *otmp; + struct obj *otmp2; boolean lava = (lev1->drawbridgemask & DB_UNDER) == DB_LAVA; if (lev1->typ == DRAWBRIDGE_UP) { if (cansee(x2,y2)) @@ -874,9 +874,9 @@ int x,y; } lev1->typ = lava ? LAVAPOOL : MOAT; lev1->drawbridgemask = 0; - if ((otmp = sobj_at(BOULDER,x,y)) != 0) { - obj_extract_self(otmp); - (void) flooreffects(otmp,x,y,"fall"); + if ((otmp2 = sobj_at(BOULDER,x,y)) != 0) { + obj_extract_self(otmp2); + (void) flooreffects(otmp2,x,y,"fall"); } } else { if (cansee(x,y)) diff --git a/src/dungeon.c b/src/dungeon.c index fca349c94..a38689b4c 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -67,7 +67,7 @@ STATIC_DCL void FDECL(save_mapseen, (int, mapseen *)); STATIC_DCL mapseen *FDECL(find_mapseen, (d_level *)); STATIC_DCL void FDECL(print_mapseen, (winid,mapseen *,BOOLEAN_P)); STATIC_DCL boolean FDECL(interest_mapseen, (mapseen *)); -STATIC_DCL char *FDECL(seen_string, (XCHAR_P,const char *)); +STATIC_DCL const char *FDECL(seen_string, (XCHAR_P,const char *)); STATIC_DCL const char *FDECL(br_string2, (branch *)); #endif /* DUNGEON_OVERVIEW */ @@ -1897,14 +1897,14 @@ d_level *lev; } void -forget_mapseen(ledger_no) -int ledger_no; +forget_mapseen(ledger_num) +int ledger_num; { mapseen *mptr; for (mptr = mapseenchn; mptr; mptr = mptr->next) if (dungeons[mptr->lev.dnum].ledger_start + - mptr->lev.dlevel == ledger_no) break; + mptr->lev.dlevel == ledger_num) break; /* if not found, then nothing to forget */ if (mptr) { @@ -2213,7 +2213,7 @@ dooverview() return 0; } -STATIC_OVL char * +STATIC_OVL const char * seen_string(x, obj) xchar x; const char *obj; diff --git a/src/hacklib.c b/src/hacklib.c index 14e6e3aa2..c8baaf910 100644 --- a/src/hacklib.c +++ b/src/hacklib.c @@ -674,7 +674,7 @@ char *buf; { int k; struct tm t, *lt; - char *g, *p, y[5],mo[3],d[3],h[3],mi[3],s[3]; + char *g, *p, y[5],mo[3],md[3],h[3],mi[3],s[3]; if (buf && strlen(buf) == 14) { g = buf; p = y; /* year */ @@ -685,7 +685,7 @@ char *buf; for (k = 0; k < 2; ++k) *p++ = *g++; *p = '\0'; - p = d; /* day */ + p = md; /* day */ for (k = 0; k < 2; ++k) *p++ = *g++; *p = '\0'; @@ -706,7 +706,7 @@ char *buf; t = *lt; t.tm_year = atoi(y) - 1900; t.tm_mon = atoi(mo) - 1; - t.tm_mday = atoi(d); + t.tm_mday = atoi(md); t.tm_hour = atoi(h); t.tm_min = atoi(mi); t.tm_sec = atoi(s); diff --git a/src/invent.c b/src/invent.c index 77d7e3e36..886a5ba87 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1991,7 +1991,7 @@ char avoidlet; struct obj *otmp; char ilet, ret = 0; char *invlet = flags.inv_order; - int n, classcount, done = 0; + int n, classcount, invdone = 0; winid win; anything any; menu_item *selected; @@ -1999,7 +1999,7 @@ char avoidlet; if (invent) { win = create_nhwindow(NHW_MENU); start_menu(win); - while (!done) { + while (!invdone) { any = zeroany; /* set all bits to zero */ classcount = 0; for(otmp = invent; otmp; otmp = otmp->nobj) { @@ -2019,7 +2019,7 @@ char avoidlet; } } if (flags.sortpack && *++invlet) continue; - done = 1; + invdone = 1; } end_menu(win, "Inventory letters used:"); diff --git a/src/mondata.c b/src/mondata.c index cd8010b5d..d6ca72742 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -429,7 +429,7 @@ int max_passive_dmg(mdef, magr) register struct monst *mdef, *magr; { - int i, dmg = 0, multi = 0; + int i, dmg = 0, multi2 = 0; uchar adtyp; /* each attack by magr can result in passive damage */ @@ -437,7 +437,7 @@ max_passive_dmg(mdef, magr) switch (magr->data->mattk[i].aatyp) { case AT_CLAW: case AT_BITE: case AT_KICK: case AT_BUTT: case AT_TUCH: case AT_STNG: case AT_HUGS: case AT_ENGL: case AT_TENT: case AT_WEAP: - multi++; + multi2++; break; default: break; @@ -457,7 +457,7 @@ max_passive_dmg(mdef, magr) dmg *= mdef->data->mattk[i].damd; } else dmg = 0; - return dmg * multi; + return dmg * multi2; } return 0; } diff --git a/src/options.c b/src/options.c index 1945a01b1..76db8ea7b 100644 --- a/src/options.c +++ b/src/options.c @@ -3137,7 +3137,7 @@ boolean setinitial,setfromfile; int pick_cnt, pick_idx, opt_idx, pass; int totalapes = 0, numapes[2] = {0,0}; menu_item *pick_list = (menu_item *)0; - anything any; + anything apany; char apebuf[1+BUFSZ]; /* so &apebuf[1] is BUFSZ long for getlin() */ struct autopickup_exception *ape; static struct ape_action { @@ -3155,12 +3155,12 @@ boolean setinitial,setfromfile; totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]); tmpwin = create_nhwindow(NHW_MENU); start_menu(tmpwin); - any = zeroany; + apany = zeroany; for (i = 0; i < SIZE(action_titles); i++) { - any.a_int++; + apany.a_int++; /* omit list and remove if there aren't any yet */ if (!totalapes && (i == 1 || i == 2)) continue; - add_menu(tmpwin, NO_GLYPH, &any, action_titles[i].letr, + add_menu(tmpwin, NO_GLYPH, &apany, action_titles[i].letr, 0, ATR_NONE, action_titles[i].desc, #if 0 /* this ought to work but doesn't... */ (action_titles[i].letr == 'x') ? MENU_SELECTED : @@ -3202,14 +3202,14 @@ boolean setinitial,setfromfile; for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) { if (numapes[pass] == 0) continue; ape = iflags.autopickup_exceptions[pass]; - any = zeroany; - add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, + apany = zeroany; + add_menu(tmpwin, NO_GLYPH, &apany, 0, 0, iflags.menu_headings, (pass == 0) ? "Never pickup" : "Always pickup", MENU_UNSELECTED); for (i = 0; i < numapes[pass] && ape; i++) { - any.a_void = (opt_idx == 1) ? 0 : ape; + apany.a_void = (opt_idx == 1) ? 0 : ape; Sprintf(apebuf, "\"%s\"", ape->pattern); - add_menu(tmpwin, NO_GLYPH, &any, + add_menu(tmpwin, NO_GLYPH, &apany, 0, 0, ATR_NONE, apebuf, MENU_UNSELECTED); ape = ape->next; } diff --git a/src/role.c b/src/role.c index 4614748c0..512acef36 100644 --- a/src/role.c +++ b/src/role.c @@ -533,7 +533,7 @@ randrole() int str2role(str) - char *str; + const char *str; { int i, len; @@ -601,7 +601,7 @@ randrace(rolenum) int str2race(str) - char *str; + const char *str; { int i, len; diff --git a/src/topten.c b/src/topten.c index 6ecd8cc42..4d3a20c47 100644 --- a/src/topten.c +++ b/src/topten.c @@ -748,7 +748,7 @@ int uid; for (i = 0; i < playerct; i++) { if (players[i][0] == '-' && index("pr", players[i][1]) && players[i][2] == 0 && i + 1 < playerct) { - char *arg = (char *)players[i + 1]; + const char *arg = players[i + 1]; if ((players[i][1] == 'p' && str2role(arg) == str2role(t1->plrole)) || (players[i][1] == 'r' && diff --git a/src/trap.c b/src/trap.c index a366d8989..392c486d3 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1209,29 +1209,29 @@ glovecheck: (void) rust_dmg(uarmg, "gauntlets", 1, TRUE, &youmonst); if (!Antimagic) { drain_en(rnd(u.ulevel) + 1); } else { - int dmgval = rnd(4), hp = Upolyd ? u.mh : u.uhp; + int dmgval2 = rnd(4), hp = Upolyd ? u.mh : u.uhp; /* Half_XXX_damage has opposite its usual effect (approx) but isn't cumulative if hero has more than one */ if (Half_physical_damage || Half_spell_damage) - dmgval += rnd(4); + dmgval2 += rnd(4); /* give Magicbane wielder dose of own medicine */ if (uwep && uwep->oartifact == ART_MAGICBANE) - dmgval += rnd(4); + dmgval2 += rnd(4); /* having an artifact--other than own quest one--which confers magic resistance simply by being carried also increases the effect */ for (otmp = invent; otmp; otmp = otmp->nobj) if (otmp->oartifact && !is_quest_artifact(otmp) && protects(AD_MAGM, otmp)) break; - if (otmp) dmgval += rnd(4); - if (Passes_walls) dmgval = (dmgval + 3) / 4; + if (otmp) dmgval2 += rnd(4); + if (Passes_walls) dmgval2 = (dmgval2 + 3) / 4; - You_feel((dmgval >= hp) ? "unbearably torpid!" : - (dmgval >= hp / 4) ? "very lethargic." : + You_feel((dmgval2 >= hp) ? "unbearably torpid!" : + (dmgval2 >= hp / 4) ? "very lethargic." : "sluggish."); /* opposite of magical explosion */ - losehp(dmgval, "anti-magic implosion", KILLED_BY_AN); + losehp(dmgval2, "anti-magic implosion", KILLED_BY_AN); } break; @@ -2385,19 +2385,19 @@ glovecheck: target = which_armor(mtmp, W_ARMG); } } } else { /* take some damage */ - int dmgval = rnd(4); + int dmgval2 = rnd(4); if ((otmp = MON_WEP(mtmp)) != 0 && otmp->oartifact == ART_MAGICBANE) - dmgval += rnd(4); + dmgval2 += rnd(4); for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) if (otmp->oartifact && protects(AD_MAGM, otmp)) break; - if (otmp) dmgval += rnd(4); - if (passes_walls(mptr)) dmgval = (dmgval + 3) / 4; + if (otmp) dmgval2 += rnd(4); + if (passes_walls(mptr)) dmgval2 = (dmgval2 + 3) / 4; if (in_sight) seetrap(trap); - if ((mtmp->mhp -= dmgval) <= 0) + if ((mtmp->mhp -= dmgval2) <= 0) monkilled(mtmp, in_sight ? "compression from an anti-magic field" : 0, -AD_MAGM);