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

@ -153,7 +153,7 @@ over:
mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch);
if (!ce(ch_ret, th->t_pos))
{
sch = mvinch(ch_ret.y, ch_ret.x);
sch = mvinch(ch_ret.y, ch_ret.x) & A_CHARTEXT;
if (sch == FLOOR && (th->t_room->r_flags & ISDARK)
&& DISTANCE(th->t_pos.y, th->t_pos.x, hero.y, hero.x)
&& !on(player, ISBLIND))

View file

@ -249,7 +249,7 @@ command(void)
}
else
{
if (wizard = passwd())
if ( (wizard = passwd()) )
{
noscore = TRUE;
turn_see(FALSE);

View file

@ -59,9 +59,9 @@ void tstp(), endit(int);
long lseek();
extern coord ch_ret;
extern shint countch;
extern shint direction;
extern shint newcount;
extern char countch;
extern char direction;
extern char newcount;
extern int between;
extern int num_checks;
extern char lvl_mons[27];
@ -83,6 +83,7 @@ extern FILE *md_fdopen(int fd, char *mode);
extern int md_fileno(FILE *fp);
extern char *md_getusername(int uid);
extern char *md_gethomedir();
extern char *md_getpass(char *prompt);
extern int md_getuid(void);
extern void md_ignore_signals(void);
extern void md_init(void);

View file

@ -137,6 +137,7 @@ attack(THING *mp)
*/
if (cur_armor != NULL && cur_armor->o_ac < 9
&& cur_armor->o_which != LEATHER)
{
if (ISWEARING(R_SUSTARM))
msg("The rust vanishes instantly");
else
@ -147,6 +148,7 @@ attack(THING *mp)
else
msg("your armor weakens");
}
}
when 'E':
/*
* The gaze of the floating eye hypnotizes you
@ -167,6 +169,7 @@ attack(THING *mp)
* Ants have poisonous bites
*/
if (!save(VS_POISON))
{
if (!ISWEARING(R_SUSTSTR))
{
chg_str(-1);
@ -176,10 +179,13 @@ attack(THING *mp)
msg("a sting has weakened you");
}
else
{
if (!terse)
msg("a sting momentarily weakens you");
else
msg("sting has no effect");
}
}
when 'W':
case 'V':
/*

View file

@ -110,7 +110,9 @@ md_init(void)
#endif
}
#ifdef _WIN32
static int md_standout_mode = 0;
#endif
void
md_raw_standout(void)
@ -409,7 +411,7 @@ md_shellescape(void)
*/
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);
}
@ -590,6 +592,7 @@ md_getloadavg(double *avg)
avg[0] = avg[1] = avg[2] = 0.0;
return -1;
}
return 3;
}
long

View file

@ -58,9 +58,7 @@ look(bool wakeup)
register int passcount = 0;
register char pfl, *fp, pch;
register int sy, sx, sumhero = 0, diffhero = 0;
register int oldx, oldy;
getyx(stdscr, oldy, oldx);
rp = proom;
if (!ce(oldpos, hero))
{
@ -115,12 +113,15 @@ look(bool wakeup)
fp = &_flags[index];
ch = _level[index];
if (pch != DOOR && ch != DOOR)
{
if ((pfl & F_PASS) != (*fp & F_PASS))
continue;
else if ((*fp & F_PASS) && (*fp & F_PNUM) != (pfl & F_PNUM))
continue;
}
if ((tp = _monst[index]) != NULL)
{
if (on(player, SEEMONST) && on(*tp, ISINVIS))
{
if (door_stop && !firstmove)
@ -137,6 +138,7 @@ look(bool wakeup)
if (see_monst(tp))
ch = tp->t_disguise;
}
}
move(y, x);
if (ch != inch())

View file

@ -75,7 +75,7 @@ new_monster(THING *tp, char type, coord *cp)
tp->t_type = type;
tp->t_disguise = type;
tp->t_pos = *cp;
tp->t_oldch = mvinch(cp->y, cp->x);
tp->t_oldch = mvinch(cp->y, cp->x) & A_CHARTEXT;
tp->t_room = roomin(cp);
moat(cp->y, cp->x) = tp;
mp = &monsters[tp->t_type-'A'];

View file

@ -15,6 +15,7 @@
#include <curses.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "rogue.h"
#define EQSTR(a, b, c) (strncmp(a, b, c) == 0)

View file

@ -102,6 +102,7 @@ add_pack(THING *obj, bool silent)
* Check for and deal with scare monster scrolls
*/
if (obj->o_type == SCROLL && obj->o_which == S_SCARE)
{
if (obj->o_flags & ISFOUND)
{
detach(lvl_obj, obj);
@ -112,6 +113,7 @@ add_pack(THING *obj, bool silent)
}
else
obj->o_flags |= ISFOUND;
}
inpack++;
if (from_floor)
@ -256,7 +258,7 @@ inventory(THING *list, int type)
void
pick_up(char ch)
{
register THING *obj, *mp;
register THING *obj;
switch (ch)
{

View file

@ -99,10 +99,12 @@ score(int amount, int flags, char monst)
}
#ifdef WIZARD
if (wizard)
{
if (strcmp(prbuf, "names") == 0)
prflags = 1;
else if (strcmp(prbuf, "edit") == 0)
prflags = 2;
}
#endif
for(i=0; i<10; i++)
{
@ -164,7 +166,7 @@ score(int amount, int flags, char monst)
for (scp = top_ten; scp <= &top_ten[9]; scp++)
{
if (scp->sc_score) {
printf("%d\t%d\t%s: %s on level %d", scp - top_ten + 1,
printf("%d\t%d\t%s: %s on level %d", (int) (scp - top_ten + 1),
scp->sc_score, scp->sc_name, reason[scp->sc_flags],
scp->sc_level);
if (scp->sc_flags == 0)
@ -414,10 +416,12 @@ total_winner(void)
worth = r_magic[obj->o_which].mi_worth;
if (obj->o_which == R_ADDSTR || obj->o_which == R_ADDDAM ||
obj->o_which == R_PROTECT || obj->o_which == R_ADDHIT)
{
if (obj->o_ac > 0)
worth += obj->o_ac * 100;
else
worth = 10;
}
if (!(obj->o_flags & ISKNOW))
worth /= 2;
obj->o_flags |= ISKNOW;

View file

@ -10,6 +10,10 @@
* See the file LICENSE.TXT for full copyright and licensing information.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
typedef struct {
const char *st_name;
const int st_value;
@ -50,7 +54,7 @@ extern const char *metal[];
/*
* All the fun defines
*/
#define shint char /* short integer (for very small #s) */
#define shint signed char /* short integer (for very small #s) */
#define when break;case
#define otherwise break;default
#define until(expr) while(!(expr))
@ -83,7 +87,7 @@ extern const char *metal[];
#define moat(y,x) (_monst[((x) << 5) + (y)])
#define unc(cp) (cp).y, (cp).x
#ifdef WIZARD
#define debug if (wizard) msg
#define debug if (wizard) msg
#endif
/*
@ -532,6 +536,9 @@ void fuse(void (*func)(), int arg, int time, int type);
void genocide(void);
bool get_dir(void);
THING *get_item(char *purpose, int type);
#ifdef WIZARD
int get_num(short *opt, WINDOW *win);
#endif
int get_str(char *opt, WINDOW *win);
void give_pack(THING *tp);
bool hit_monster(int y, int x, THING *obj);
@ -542,7 +549,7 @@ void init_names(void);
void init_player(void);
void init_stones(void);
void init_things(void);
void init_weapon(THING *weap, char type);
void init_weapon(THING *weap, signed char type);
char *inv_name(THING *obj, bool drop);
bool inventory(THING *list, int type);
void invis_on(void);
@ -633,9 +640,6 @@ void whatis(bool insist);
void wield(void);
void writelog(int amount, int flags, char monst);
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "extern.h"
#ifndef PATH_MAX

View file

@ -235,7 +235,7 @@ leave_room(coord *cp)
floor = ((rp->r_flags & ISDARK) && !on(player, ISBLIND)) ? ' ' : FLOOR;
for (y = rp->r_pos.y + 1; y < rp->r_max.y + rp->r_pos.y - 1; y++)
for (x = rp->r_pos.x + 1; x < rp->r_max.x + rp->r_pos.x - 1; x++)
switch (ch = mvinch(y, x))
switch (ch = mvinch(y, x) & A_CHARTEXT)
{
case ' ':
case TRAP:
@ -251,6 +251,7 @@ leave_room(coord *cp)
* standout bit
*/
if (isupper(toascii(ch)))
{
if (on(player, SEEMONST))
{
standout();
@ -270,6 +271,7 @@ leave_room(coord *cp)
msg("couldn't find monster in leave_room at (%d,%d)", y, x);
#endif
}
}
addch(floor);
}

View file

@ -2078,7 +2078,9 @@ rs_save_file(FILE *savef)
int
rs_restore_file(FILE *inf)
{
#ifndef WIZARD
bool junk;
#endif
THING *mitem;
int endian = 0x01020304;
big_endian = ( *((char *)&endian) == 0x01 );

View file

@ -159,7 +159,8 @@ do_zap(void)
rnd_pos(&rooms[rm], &tp->t_pos);
} until (winat(tp->t_pos.y, tp->t_pos.x) == FLOOR);
tp->t_room = roomin(&tp->t_pos);
tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x);
tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x) &
A_CHARTEXT;
if (see_monst(tp))
mvaddch(tp->t_pos.y, tp->t_pos.x, tp->t_disguise);
else if (on(player, SEEMONST))
@ -175,7 +176,8 @@ do_zap(void)
tp->t_pos.x = hero.x + delta.x;
if (tp->t_pos.y != y || tp->t_pos.x != x)
tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x);
tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x) &
A_CHARTEXT;
}
moat(y, x) = NULL;
moat(tp->t_pos.y, tp->t_pos.x) = tp;
@ -423,10 +425,12 @@ def:
if (!save(VS_MAGIC))
{
if ((pstats.s_hpt -= roll(6, 6)) <= 0)
{
if (start == &hero)
death('b');
else
death(moat(start->y, start->x)->t_type);
}
used = TRUE;
if (terse)
msg("the %s hits", name);

View file

@ -287,10 +287,12 @@ new_thing(void)
* the second one, then turn it into a identify scroll
*/
if (cur->o_which == S_GENOCIDE)
{
if (got_genocide)
cur->o_which = S_IDENT;
else
got_genocide = TRUE;
}
when 2:
no_food = 0;
cur->o_type = FOOD;

View file

@ -162,7 +162,7 @@ fall(THING *obj, bool pr)
* Set up the initial goodies for a weapon
*/
void
init_weapon(THING *weap, char type)
init_weapon(THING *weap, signed char type)
{
register struct init_weps *iwp;