Skip to content

Commit

Permalink
Much more silencing of the compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
elunna committed Oct 5, 2023
1 parent 4bdab97 commit 0595e3a
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 85 deletions.
53 changes: 25 additions & 28 deletions src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -3011,30 +3011,30 @@ int dieroll; /* needed for Magicbane and vorpal blades */
}
}
/* Monsters die as soon as they reach level 0 or below. */

int drain = monhp_per_lvl(mdef);

*dmgptr += drain;
mdef->mhpmax -= drain;
mdef->m_lev--;
drain /= 2;
if (drain) {
if (youattack)
healup(drain, 0, FALSE, FALSE);
else if (magr && magr->mhp < magr->mhpmax) {
magr->mhp += drain;
if (magr->mhp > magr->mhpmax)
magr->mhp = magr->mhpmax;
{
int drain = monhp_per_lvl(mdef);

*dmgptr += drain;
mdef->mhpmax -= drain;
mdef->m_lev--;
drain /= 2;
if (drain) {
if (youattack)
healup(drain, 0, FALSE, FALSE);
else if (magr && magr->mhp < magr->mhpmax) {
magr->mhp += drain;
if (magr->mhp > magr->mhpmax)
magr->mhp = magr->mhpmax;
}
if (mdef->data == &mons[PM_HYDRA])
pline("One of %s heads swells up and explodes!",
s_suffix(mon_nam(mdef)));
}
if (DEADMONSTER(mdef) || DRAINEDMONSTER(mdef)) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef, XKILL_NOMSG);
}
if (mdef->data == &mons[PM_HYDRA])
pline("One of %s heads swells up and explodes!",
s_suffix(mon_nam(mdef)));
}
if (DEADMONSTER(mdef) || DRAINEDMONSTER(mdef)) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef, XKILL_NOMSG);
}

return vis;
} else { /* youdefend */
int oldhpmax = u.uhpmax;
Expand Down Expand Up @@ -3092,7 +3092,9 @@ int dieroll; /* needed for Magicbane and vorpal blades */
/* Origin can teleport/confuse enemies */
{
char nambuf[BUFSZ];

boolean u_saw_mon = (canseemon(mdef)
|| (u.uswallow && u.ustuck == mdef));

if (otmp->oartifact == ART_ORIGIN) {
if (realizes_damage) {
if (youdefend && !Antimagic && !rn2(5)) {
Expand All @@ -3104,11 +3106,6 @@ int dieroll; /* needed for Magicbane and vorpal blades */
&& !defended(mdef, AD_MAGM)) {
if (*dmgptr <= 0)
*dmgptr = 1;


boolean u_saw_mon = (canseemon(mdef)
|| (u.uswallow && u.ustuck == mdef));

/* record the name before losing sight of monster */
Strcpy(nambuf, Monnam(mdef));
if (u_teleport_mon(mdef, FALSE) && u_saw_mon
Expand Down
13 changes: 6 additions & 7 deletions src/do_wear.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,14 +1279,13 @@ dragon_armor_handling(struct obj *otmp, boolean puton)
Free_action &= ~W_ARM;
}
break;
case VIOLET_DRAGON_SCALES:
/* Copied from EvilHack's CELESTIAL_DRAGON_SCALES code */
case VIOLET_DRAGON_SCALES: {
boolean already_flying;
if (puton) {
/* setworn() has already set extrinisic flying */
float_vs_flight(); /* block flying if levitating */
check_wings(TRUE); /* are we in a form that has wings and can already fly? */
boolean already_flying;


/* to determine whether this flight is new we have to muck
about in the Flying intrinsic (actually extrinsic) */
EFlying &= ~W_ARM;
Expand All @@ -1299,7 +1298,6 @@ dragon_armor_handling(struct obj *otmp, boolean puton)
}
} else {
boolean was_flying = !!Flying;

/* remove scales 'early' to determine whether Flying changes */
/*setworn((struct obj *) 0, W_ARM);*/
EFlying &= ~W_ARM;
Expand All @@ -1310,12 +1308,13 @@ dragon_armor_handling(struct obj *otmp, boolean puton)
context.botl = TRUE; /* status: 'Fly' Off */
You("%s.", (is_pool_or_lava(u.ux, u.uy)
|| Is_waterlevel(&u.uz) || Is_airlevel(&u.uz))
? "stop flying"
: "land");
? "stop flying"
: "land");
spoteffects(TRUE);
}
}
break;
}
case SILVER_DRAGON_SCALES:
if (puton) {
ECold_resistance |= W_ARM;
Expand Down
13 changes: 7 additions & 6 deletions src/dothrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,13 @@ struct obj *oldslot; /* for thrown-and-return used with !fixinv */
{
register struct monst *mon;
int range, urange;
boolean crossbowing, gunning, boomeranging, clear_thrownobj,
impaired = (Confusion || Stunned || Blind
|| Hallucination || Fumbling || Afraid),
tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0);

crossbowing = gunning = boomeranging = clear_thrownobj = FALSE;
boolean crossbowing = FALSE;
boolean gunning = FALSE;
boolean boomeranging = FALSE;
boolean clear_thrownobj = FALSE;
boolean impaired = (Confusion || Stunned || Blind
|| Hallucination || Fumbling || Afraid);
boolean tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0);

/* 5lo: This gets used a lot, so put it here
* hackem: Updated so that the lightsaber only auto-returns if thrown from
Expand Down
3 changes: 2 additions & 1 deletion src/hack.c
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,7 @@ weight_cap()
{
long carrcap, save_ELev = ELevitation, save_BLev = BLevitation;
long maxcarrcap = MAX_CARR_CAP;
int pct_increase;
struct obj *boots = uarmf;

/* boots take multiple turns to wear but any properties they
Expand Down Expand Up @@ -3699,7 +3700,7 @@ weight_cap()

/* final adjustment: ring of carrying lets you carry more than usual and go
* over the normal carrycap */
int pct_increase = ringbon(RIN_CARRYING) * 10;
pct_increase = ringbon(RIN_CARRYING) * 10;
carrcap = (carrcap * (100 + pct_increase)) / 100;

return (int) carrcap;
Expand Down
2 changes: 1 addition & 1 deletion src/makemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,7 @@ long mmflags;
{
register struct monst *mtmp;
struct monst fakemon;
struct obj *otmp;
coord cc;
int mndx, mcham, ct, mitem;
boolean anymon = (!ptr);
Expand Down Expand Up @@ -3440,7 +3441,6 @@ long mmflags;
mtmp->iscerberus = TRUE;
} else if (mndx == PM_VECNA) {
mtmp->isvecna = TRUE;
struct obj *otmp;
otmp = oname(mksobj(SKELETON_KEY, TRUE, FALSE),
artiname(ART_KEY_OF_CHAOS));
if (otmp) {
Expand Down
17 changes: 8 additions & 9 deletions src/mhitm.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ register struct monst *magr, *mdef;
struct attack *mattk, alt_attk;
struct obj *mwep;
struct obj * marmf = which_armor(magr, W_ARMF);
struct obj *helmet = which_armor(magr, W_ARMH);
struct permonst *pa; /* *pd no longer used (for now) */

if (!magr || !mdef)
Expand Down Expand Up @@ -634,7 +635,6 @@ register struct monst *magr, *mdef;
strike = FALSE;
}
/* Impossible to bite with this on */
struct obj *helmet = which_armor(magr, W_ARMH);
if (mattk->aatyp == AT_BITE
&& helmet && helmet->otyp == PLASTEEL_HELM)
strike = FALSE;
Expand Down Expand Up @@ -2244,7 +2244,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
break;
case AD_SSEX:
case AD_SITM: /* for now these are the same */
case AD_SEDU:
case AD_SEDU: {
if (magr->mcan)
break;
/* find an object to steal, non-cursed if magr is tame */
Expand Down Expand Up @@ -2283,8 +2283,8 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
mdefnambuf,
obj->greased ? "greased" : "slippery",
(obj->greased || objects[obj->otyp].oc_name_known)
? xname(obj)
: cloak_simple_name(obj));
? xname(obj)
: cloak_simple_name(obj));
}
if (obj->greased && !rn2(2)) {
if (vis && canseemon(mdef))
Expand Down Expand Up @@ -2332,6 +2332,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
}
tmp = 0;
break;
}
case AD_DREN:
if (!cancelled && !rn2(4))
xdrainenergym(mdef, (boolean) (vis && canspotmon(mdef)
Expand Down Expand Up @@ -3063,11 +3064,9 @@ struct obj *mwep;
register struct permonst *madat = magr->data;
char buf[BUFSZ];
int i, tmp;
struct attack *mdattk;
struct obj *otmp;
mdattk = has_erac(mdef) ? ERAC(mdef)->mattk : mddat->mattk;

struct obj *passive_armor;
struct attack *mdattk = has_erac(mdef) ? ERAC(mdef)->mattk : mddat->mattk;
struct obj *otmp, *passive_armor;

if ((passive_armor = which_armor(mdef, W_ARM))) {
if (mhit && !rn2(3)
&& Is_dragon_scaled_armor(passive_armor)) {
Expand Down
2 changes: 1 addition & 1 deletion src/muse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ struct monst *mtmp;
case MUSE_HORN_OF_BLASTING:
mplayhorn(mtmp, otmp, FALSE);
m_using = TRUE;
buzz(ZT_MONWAND((otmp->otyp == FROST_HORN) ? ZT_COLD : ZT_FIRE),
buzz(ZT_MONWAND(otmp->otyp == FROST_HORN ? ZT_COLD : ZT_FIRE),
rn1(6, 6), mtmp->mx, mtmp->my, sgn(tbx),
sgn(tby));
m_using = FALSE;
Expand Down
26 changes: 13 additions & 13 deletions src/pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,9 +1763,9 @@ char *usr_text;
/* TRANSFORMATIONS */

/* tinker/upgrades */
int newtyp = obj2upgrade(otyp);
if (reveal_info && newtyp && !is_artifact) {
Sprintf(buf, "Can be tinkered into: %s", OBJ_NAME(objects[newtyp]));
i = obj2upgrade(otyp);
if (reveal_info && i && !is_artifact) {
Sprintf(buf, "Can be tinkered into: %s", OBJ_NAME(objects[i]));
OBJPUTSTR(buf);
}

Expand Down Expand Up @@ -1813,14 +1813,14 @@ char *usr_text;
if (reveal_info && otyp == POT_ACID) {
OBJPUTSTR("Gem alchemy recipes:");
OBJPUTSTR("(Dipping a gem into this can alchemize a new potion)");
for (int g = bases[GEM_CLASS]; g <= LAST_GEM; g++) {
const char *result = gem_to_potion(g);
if (g == DILITHIUM_CRYSTAL)
for (i = bases[GEM_CLASS]; i <= LAST_GEM; i++) {
const char *result = gem_to_potion(i);
if (i == DILITHIUM_CRYSTAL)
OBJPUTSTR(" acid + dilithium crystal = an explosion");
else if (result) {
struct obj *potion = mksobj(figure_out_potion(result), FALSE, FALSE);
Sprintf(buf, " acid + %-12s = %s",
OBJ_NAME(objects[g]), /* The gem */
OBJ_NAME(objects[i]), /* The gem */
xname(potion)); /* The potion */
OBJPUTSTR(buf);
obfree(potion, (struct obj *)0);
Expand All @@ -1843,24 +1843,24 @@ char *usr_text;
/* Display all fermenting recipes here */
OBJPUTSTR("Juice fermentation recipes:");
OBJPUTSTR("(#dipping a mold corpse can ferment a new potion)");
for (int g = PM_BROWN_MOLD; g < PM_VOLATILE_MUSHROOM; g++) {
short result = mold_to_potion(g);
for (i = PM_BROWN_MOLD; i < PM_VOLATILE_MUSHROOM; i++) {
short result = mold_to_potion(i);
/* Important: Display the actual potion result - NOT the
* appearance, otherwise we directly leak info. */
if (result) {
Sprintf(buf, " fruit juice + %-15s = %s",
mons[g].mname, /* The mold */
mons[i].mname, /* The mold */
OBJ_NAME(objects[result])); /* The potion */
OBJPUTSTR(buf);

}
}
} else if (reveal_info && oc.oc_class == POTION_CLASS) {
for (int g = PM_BROWN_MOLD; g < PM_VOLATILE_MUSHROOM; g++) {
if (mold_to_potion(g) == otyp) {
for (i = PM_BROWN_MOLD; i < PM_VOLATILE_MUSHROOM; i++) {
if (mold_to_potion(i) == otyp) {
OBJPUTSTR("Fermentation recipes:");
Sprintf(buf, "#dipping a %s corpse into fruit juice ferments a potion of %s.",
mons[g].mname, /* The mold */
mons[i].mname, /* The mold */
OBJ_NAME(objects[otyp])); /* The potion */
OBJPUTSTR(buf);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ boolean *cancelled;
anything any;
char buf[BUFSZ];
menu_item *pick_list = (menu_item *) 0;
struct obj dummyobj, *otmp;
struct obj dummyobj, *otmp, *obj2;;
boolean hands_available = TRUE, exclude_it;

#if 0 /* [skip potential early return so that menu response is needed
Expand Down Expand Up @@ -3883,7 +3883,7 @@ boolean *cancelled;
add_menu(win, NO_GLYPH, &any, !exclude_it ? otmp->invlet : 0, 0,
ATR_NONE, buf, MENU_UNSELECTED);
}
struct obj *obj2;

/* TODO: This is just duplicated from above for containers on the floor.
* Maybe refactor to not be copy/paste */
for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = obj2) {
Expand Down
7 changes: 5 additions & 2 deletions src/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -2851,7 +2851,8 @@ potion_to_gem(potion_otyp)
int potion_otyp;
{
const char *result;
for (int i = bases[GEM_CLASS]; i <= LAST_GEM; i++) {
int i;
for (i = bases[GEM_CLASS]; i <= LAST_GEM; i++) {
result = gem_to_potion(i);
if (result && !strcmp(result, OBJ_DESCR(objects[potion_otyp])))
return i;
Expand Down Expand Up @@ -2950,6 +2951,8 @@ boolean ourfault;
{
char Your_buf[BUFSZ];
boolean used = FALSE;
int res;

if (!potion || potion->otyp != POT_AMNESIA)
return FALSE;
if (snuff_lit(targobj))
Expand Down Expand Up @@ -3142,7 +3145,7 @@ boolean ourfault;
* need handling specifically. This has to come after most of the
* cancel effects, otherwise the messages and effects don't really
* make sense for this potion. */
int res = water_damage(targobj, 0, TRUE, u.ux, u.uy);
res = water_damage(targobj, 0, TRUE, u.ux, u.uy);

if (res == ER_DAMAGED) {
used = TRUE;
Expand Down
13 changes: 6 additions & 7 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4223,20 +4223,19 @@ int class_type;
}

static void do_acquirement() {
winid win;
winid win = create_nhwindow(NHW_MENU);
anything any;
int i;
char ch = 'q';

win = create_nhwindow(NHW_MENU);
start_menu(win);

char item_chars[] = { 'r', '"', ')', '[', '%', '?', '+', '!', '=', '/', '(', '*' };
const char *item_names[] = {
"Random item", "Amulet", "Weapon", "Armor", "Comestible", "Scroll",
"Spellbook", "Potion", "Ring", "Wand", "Tool", "Gem"
};

for (int i = 0; i < (int) sizeof(item_chars); i++) {

start_menu(win);

for (i = 0; i < (int) sizeof(item_chars); i++) {
any.a_void = 0;
any.a_char = item_chars[i];
add_menu(win, NO_GLYPH, &any, item_chars[i], 0, ATR_NONE, item_names[i], MENU_UNSELECTED);
Expand Down
Loading

0 comments on commit 0595e3a

Please sign in to comment.