Fix many compiler warnings.

There should only be two changes in behavior:

arogue7/fight.c, arogue7/fight.c: a to-hit bonus is now correctly
applied to characters who are not monks instead of monks who are not
empty-handed.

urogue/fight.c: fixed an interaction with the "debug" macro that could
cause the wrong message to be displayed.
This commit is contained in:
John "Elwin" Edwards 2021-04-14 18:55:33 -04:00
parent 6f21b5b88a
commit 6c3cd116ff
122 changed files with 374 additions and 280 deletions

View file

@ -33,7 +33,9 @@ command(void)
static int fight_to_death; /* Flags if we are fighting to death */
static coord dir; /* Last direction specified */
#ifdef WIZARD
object *obj;
#endif
char ch;
int ntimes = 1; /* Number of player moves */
coord nullcoord;
@ -579,10 +581,12 @@ command(void)
* If he ran into something to take, let him pick it up.
*/
if (take != 0)
{
if (!moving)
pick_up(take);
else
show_floor();
}
if (!running)
door_stop = FALSE;
} /* end while */
@ -676,10 +680,11 @@ do_after_effects(void)
}
}
}
}
}
/* Time to enforce weapon and armor restrictions */
if (rnd(9999) == 0)
/* Time to enforce weapon and armor restrictions */
if (rnd(9999) == 0)
{
if (((cur_weapon == NULL) ||
(wield_ok(&player, cur_weapon, NOMESSAGE)))
&& ((cur_armor == NULL) ||
@ -774,6 +779,7 @@ do_after_effects(void)
death(death_cause);
}
}
}
if (rnd(500000) == 0)
{
@ -1038,6 +1044,7 @@ help(void)
while (strp->h_ch)
{
if (strp->h_desc == 0)
{
if (!wizard)
break;
else
@ -1045,6 +1052,7 @@ help(void)
strp++;
continue;
}
}
if (strp->h_ch == helpch)
{
@ -1071,6 +1079,7 @@ help(void)
while (strp->h_ch)
{
if (strp->h_desc == 0)
{
if (!wizard)
break;
else
@ -1078,6 +1087,7 @@ help(void)
strp++;
continue;
}
}
mvwaddstr(hw, cnt % 23, cnt > 22 ? 40 : 0, unctrl(strp->h_ch));
waddstr(hw, strp->h_desc);

View file

@ -245,9 +245,8 @@ fight(coord *mp, struct object *weap, int thrown)
if (is_wearing(R_HEALTH) ||
player.t_ctype == C_PALADIN ||
(player.t_ctype == C_NINJA && pstats.s_lvl
> 6) ||
thrown && rnd(50) > 0 ||
(player.t_ctype == C_NINJA && pstats.s_lvl > 6) ||
(thrown && rnd(50) > 0) ||
rnd(20) > 0)
{
msg("The dust makes it hard to breath.");
@ -331,7 +330,9 @@ fight(coord *mp, struct object *weap, int thrown)
}
if (itm == NULL)
{
debug("Can't find crystalline armor being worn.");
}
else
{
msg("Your armor shatters from the shriek.");
@ -554,7 +555,9 @@ attack(struct thing *mp, struct object *weapon, int thrown)
}
if (item == NULL)
{
debug("Can't find crystalline armor being worn.");
}
else
{
msg("Your armor is shattered by the blow.");
@ -1034,20 +1037,20 @@ attack(struct thing *mp, struct object *weapon, int thrown)
msg("You feel nimble fingers reach into you pack.");
}
if ((obj != cur_armor &&
obj != cur_weapon &&
obj != cur_ring[LEFT_1] &&
obj != cur_ring[LEFT_2] &&
obj != cur_ring[LEFT_3] &&
obj != cur_ring[LEFT_4] &&
obj != cur_ring[LEFT_5] &&
obj != cur_ring[RIGHT_1] &&
obj != cur_ring[RIGHT_2] &&
obj != cur_ring[RIGHT_3] &&
obj != cur_ring[RIGHT_4] &&
obj != cur_ring[RIGHT_5] &&
!(obj->o_flags & ISPROT) &&
is_magic(obj)
if (((obj != cur_armor &&
obj != cur_weapon &&
obj != cur_ring[LEFT_1] &&
obj != cur_ring[LEFT_2] &&
obj != cur_ring[LEFT_3] &&
obj != cur_ring[LEFT_4] &&
obj != cur_ring[LEFT_5] &&
obj != cur_ring[RIGHT_1] &&
obj != cur_ring[RIGHT_2] &&
obj != cur_ring[RIGHT_3] &&
obj != cur_ring[RIGHT_4] &&
obj != cur_ring[RIGHT_5] &&
!(obj->o_flags & ISPROT) &&
is_magic(obj))
|| level > 45)
&& get_worth(obj) > worth)
{
@ -2099,9 +2102,9 @@ summon_help(struct thing *mons, int force)
/* Try to summon if less than 1/3 max hit points */
if (on(*mons, CANSUMMON) &&
(force == FORCE ||
(mons->t_stats.s_hpt < mons->maxstats.s_hpt / 3) &&
(rnd(40 * 10) < (mons->t_stats.s_lvl * mons->t_stats.s_intel))))
(force == FORCE ||
((mons->t_stats.s_hpt < mons->maxstats.s_hpt / 3) &&
(rnd(40 * 10) < (mons->t_stats.s_lvl * mons->t_stats.s_intel)))))
{
turn_off(*mons, CANSUMMON);
msg("The %s summons its attendants!", mname);

View file

@ -107,7 +107,8 @@ endmsg(void)
{
strcpy(msgbuf[msg_index], mbuf);
msg_index = ++msg_index % 10;
msg_index++;
msg_index %= 10;
if (mpos)
{

View file

@ -109,7 +109,9 @@ md_init()
# define SE exit_standout_mode
#endif
#ifdef _WIN32
static int md_standout_mode = 0;
#endif
void
md_raw_standout()
@ -281,7 +283,9 @@ md_gethomedir()
#endif
if ( (h == NULL) || (*h == '\0') )
{
if ( (h = getenv("HOME")) == NULL )
{
if ( (h = getenv("HOMEDRIVE")) == NULL)
h = "";
else
@ -292,6 +296,8 @@ md_gethomedir()
if ( (h = getenv("HOMEPATH")) == NULL)
h = "";
}
}
}
len = strlen(homedir);
@ -372,7 +378,7 @@ md_shellescape()
*/
setuid(getuid());
setgid(getgid());
execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", 0);
execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", (char *) NULL);
perror("No shelly");
_exit(-1);
}
@ -601,6 +607,7 @@ md_getloadavg(double *avg)
avg[0] = avg[1] = avg[2] = 0.0;
return -1;
}
return 3;
}
long

View file

@ -36,8 +36,10 @@ static char sccsid[] = "%W%\t%G%";
#define FENCE_SIZE (sizeof(size_t) * 1024)
static int memdebug_level = 0;
#ifdef MEM_DEBUG
static DICTIONARY *allocations = NULL;
static FILE *trace_file = NULL;
#endif
/* set the debug level */
void mem_debug(const int level)

View file

@ -207,7 +207,7 @@ look(int wakeup)
if (off(player, ISBLIND))
{
if (y == hero.y && x == hero.x || (inpass && (ch == '-' ||
if ((y == hero.y && x == hero.x) || (inpass && (ch == '-' ||
ch == '|')))
continue;

View file

@ -892,6 +892,7 @@ wake_monster(int y, int x)
}
}
else if (off(player, ISBLIND))
{
if (save(VS_WAND) || is_wearing(R_TRUESEE) || is_wearing(R_SEEINVIS))
msg("Your eyes film over for a moment.");
else
@ -901,6 +902,7 @@ wake_monster(int y, int x)
light_fuse(FUSE_SIGHT, 0, rnd(30) + 20, AFTER);
look(FALSE);
}
}
}
if (on(*tp, LOOKSTONE)) /* Stoning */

View file

@ -222,7 +222,7 @@ do_move(int dy, int dx)
if ((rnd(100) < 80 && on(player, ISHUH)) ||
(is_wearing(R_DELUSION) && rnd(100) < 25) ||
on(player, STUMBLER) && rnd(40) == 0)
(on(player, STUMBLER) && rnd(40) == 0))
player.t_nxtpos = rndmove(&player);
else
{
@ -768,10 +768,10 @@ be_trapped(struct thing *th, coord tc)
if (((is_wearing(R_LEVITATION) || on(player, CANFLY)) &&
(ch != FIRETRAP ||
(ch == FIRETRAP && !(tp->tr_flags & ISFOUND))))
|| (moving && (tp->tr_flags & ISFOUND) && rnd(100) <
|| ((moving && (tp->tr_flags & ISFOUND) && rnd(100) <
thief_bonus + 2 * pstats.s_dext + 5 * pstats.s_lvl) &&
(ch == BEARTRAP || ch == MAZETRAP || ch == TRAPDOOR
|| ch == ARROWTRAP || ch == DARTTRAP))
|| ch == ARROWTRAP || ch == DARTTRAP)))
{
static char trname[1024];
msg(tr_name(ch,trname));
@ -1070,6 +1070,7 @@ be_trapped(struct thing *th, coord tc)
th->t_stats.s_hpt -= roll(1, 4);
if (orig_hp == th->t_stats.s_hpt)
{
if (can_see)
msg("The dart has not effect!");
else if (th->t_stats.s_hpt < 0)
@ -1082,6 +1083,7 @@ be_trapped(struct thing *th, coord tc)
killed(NULL, mitem, NOMESSAGE, NOPOINTS);
}
}
}
}
else

View file

@ -264,7 +264,7 @@ new_level(LEVTYPE ltype, int special)
turn_off(player, BLESSMAP);
}
if (player.t_ctype == C_THIEF || on(player, BLESSGOLD) && rnd(5) == 0)
if (player.t_ctype == C_THIEF || (on(player, BLESSGOLD) && rnd(5) == 0))
{
read_scroll(&player, S_GFIND, ISNORMAL);
@ -272,7 +272,8 @@ new_level(LEVTYPE ltype, int special)
turn_off(player, BLESSGOLD);
}
if (player.t_ctype == C_RANGER || on(player, BLESSFOOD) && rnd(5) == 0)
if (player.t_ctype == C_RANGER ||
(on(player, BLESSFOOD) && rnd(5) == 0))
{
read_scroll(&player, S_FOODDET, ISNORMAL);
@ -281,7 +282,7 @@ new_level(LEVTYPE ltype, int special)
}
if (player.t_ctype == C_MAGICIAN || player.t_ctype == C_ILLUSION ||
on(player, BLESSMAGIC) && rnd(5) == 0)
(on(player, BLESSMAGIC) && rnd(5) == 0))
{
quaff(&player, P_TREASDET, ISNORMAL);
@ -289,7 +290,7 @@ new_level(LEVTYPE ltype, int special)
turn_off(player, BLESSMAGIC);
}
if (player.t_ctype == C_DRUID || on(player, BLESSMONS) && rnd(5) == 0)
if (player.t_ctype == C_DRUID || (on(player, BLESSMONS) && rnd(5) == 0))
{
quaff(&player, P_MONSTDET, ISNORMAL);
@ -305,7 +306,7 @@ new_level(LEVTYPE ltype, int special)
aggravate();
if (is_wearing(R_ADORNMENT) ||
cur_armor != NULL && cur_armor->o_which == MITHRIL)
(cur_armor != NULL && cur_armor->o_which == MITHRIL))
{
int greed = FALSE;

View file

@ -78,6 +78,7 @@ option(void)
retval = (*op->o_getfunc)(&op->o_opt, hw);
if (retval)
{
if (retval == QUIT)
break;
else if (op > optlist) /* MINUS */
@ -91,6 +92,7 @@ option(void)
wmove(hw, 0, 0);
op--;
}
}
}
/* Switch back to original screen */

View file

@ -361,10 +361,12 @@ quaff(struct thing *quaffer, int which, int flags)
char mag_type = MAGIC;
if (blessed)
{
if (tp->o_flags & ISCURSED)
mag_type = CMAGIC;
else if (tp->o_flags & ISBLESSED)
mag_type = BMAGIC;
}
showit = TRUE;
mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, mag_type);

View file

@ -319,8 +319,8 @@ score(long amount, int lvl, int flags, int monst) /*ARGSUSED*/
{
char lev[20];
sprintf(lev, "%ld+%ld", scp->sc_lvl, scp->sc_score);
printf("%4d %15s %10ld %s:", scp - top_ten + 1,
sprintf(lev, "%d+%ld", scp->sc_lvl, scp->sc_score);
printf("%4d %15s %10ld %s:", (int) (scp - top_ten + 1),
lev,
scp->sc_gold,
scp->sc_name);

View file

@ -508,10 +508,12 @@ read_scroll(struct thing *reader, int which, int flags)
obj = OBJPTR(nitem);
if (rnd(5) == 0)
{
if (obj->o_flags & ISBLESSED)
obj->o_flags &= ~ISBLESSED;
else
obj->o_flags |= ISCURSED;
}
}
msg("The smell of fire and brimstone comes from your pack.");
}
@ -797,7 +799,7 @@ read_scroll(struct thing *reader, int which, int flags)
break;
case STICK:
if (wizard || howmuch != 1 && rnd(5) == 0)
if (wizard || (howmuch != 1 && rnd(5) == 0))
lb->o_flags |= flg;
lb->o_charges += howmuch + 10;

View file

@ -266,10 +266,12 @@ do_zap(struct thing *zapper, int which, unsigned long flags)
save_adj = -5;
if (cursed)
{
if (which == WS_POLYMORPH)
save_adj = -5; /* not save vs becoming tougher */
else
save_adj = 5;
}
if (save_throw(VS_MAGIC - save_adj, tp))
{
@ -1239,7 +1241,6 @@ shoot_bolt(struct thing *shooter, coord start, coord dir, int get_points, int re
short y, x;
coord pos;
coord spotpos[BOLT_LENGTH + 1];
int ret_val = FALSE;/* True if breathing monster gets killed */
struct linked_list *item;
struct thing *tp;
char *mname;
@ -1419,7 +1420,6 @@ shoot_bolt(struct thing *shooter, coord start, coord dir, int get_points, int re
mname);
take_that[y] += tp->t_stats.s_hpt + 1;
ret_val = TRUE;
}
}
else if (strcmp(name, "lightning bolt") == 0)
@ -1604,7 +1604,6 @@ shoot_bolt(struct thing *shooter, coord start, coord dir, int get_points, int re
on(player, ISBLIND) ? "monster" : mname);
killed(shooter, item, NOMESSAGE, get_points);
ret_val = TRUE;
}
else if (get_points)
{

View file

@ -201,9 +201,8 @@ ascii_to_bin(char ch)
static void
des_init()
{
int j, b, k, inbit, obit;
int i, j, b, k, inbit, obit;
unsigned int *p, *il, *ir, *fl, *fr;
unsigned char i;
old_rawkey0 = old_rawkey1 = 0;
saltbits = 0;