switch source tree from k&r to c99
This commit is contained in:
173
src/detect.c
173
src/detect.c
@@ -11,23 +11,22 @@
|
||||
#include "hack.h"
|
||||
#include "artifact.h"
|
||||
|
||||
static boolean NDECL(unconstrain_map);
|
||||
static void NDECL(reconstrain_map);
|
||||
static void NDECL(map_redisplay);
|
||||
static void FDECL(browse_map, (int, const char *));
|
||||
static void FDECL(map_monst, (struct monst *, BOOLEAN_P));
|
||||
static void FDECL(do_dknown_of, (struct obj *));
|
||||
static boolean FDECL(check_map_spot, (int, int, CHAR_P, unsigned));
|
||||
static boolean FDECL(clear_stale_map, (CHAR_P, unsigned));
|
||||
static void FDECL(sense_trap, (struct trap *, XCHAR_P, XCHAR_P, int));
|
||||
static int FDECL(detect_obj_traps, (struct obj *, BOOLEAN_P, int));
|
||||
static int NDECL(furniture_detect);
|
||||
static void FDECL(show_map_spot, (int, int));
|
||||
static void FDECL(findone, (int, int, genericptr_t));
|
||||
static void FDECL(openone, (int, int, genericptr_t));
|
||||
static int FDECL(mfind0, (struct monst *, BOOLEAN_P));
|
||||
static int FDECL(reveal_terrain_getglyph, (int, int, int,
|
||||
unsigned, int, int));
|
||||
static boolean unconstrain_map(void);
|
||||
static void reconstrain_map(void);
|
||||
static void map_redisplay(void);
|
||||
static void browse_map(int, const char *);
|
||||
static void map_monst(struct monst *, boolean);
|
||||
static void do_dknown_of(struct obj *);
|
||||
static boolean check_map_spot(int, int, char, unsigned);
|
||||
static boolean clear_stale_map(char, unsigned);
|
||||
static void sense_trap(struct trap *, xchar, xchar, int);
|
||||
static int detect_obj_traps(struct obj *, boolean, int);
|
||||
static int furniture_detect(void);
|
||||
static void show_map_spot(int, int);
|
||||
static void findone(int, int, genericptr_t);
|
||||
static void openone(int, int, genericptr_t);
|
||||
static int mfind0(struct monst *, boolean);
|
||||
static int reveal_terrain_getglyph(int, int, int, unsigned, int, int);
|
||||
|
||||
/* wildcard class for clear_stale_map - this used to be used as a getobj() input
|
||||
* but it's no longer used for that function */
|
||||
@@ -36,7 +35,7 @@ static int FDECL(reveal_terrain_getglyph, (int, int, int,
|
||||
/* bring hero out from underwater or underground or being engulfed;
|
||||
return True iff any change occurred */
|
||||
static boolean
|
||||
unconstrain_map()
|
||||
unconstrain_map(void)
|
||||
{
|
||||
boolean res = u.uinwater || u.uburied || u.uswallow;
|
||||
|
||||
@@ -50,7 +49,7 @@ unconstrain_map()
|
||||
|
||||
/* put hero back underwater or underground or engulfed */
|
||||
static void
|
||||
reconstrain_map()
|
||||
reconstrain_map(void)
|
||||
{
|
||||
u.uinwater = iflags.save_uinwater, iflags.save_uinwater = 0; /* set_uinwater() */
|
||||
u.uburied = iflags.save_uburied, iflags.save_uburied = 0;
|
||||
@@ -58,7 +57,7 @@ reconstrain_map()
|
||||
}
|
||||
|
||||
static void
|
||||
map_redisplay()
|
||||
map_redisplay(void)
|
||||
{
|
||||
reconstrain_map();
|
||||
docrt(); /* redraw the screen to remove unseen traps from the map */
|
||||
@@ -70,9 +69,7 @@ map_redisplay()
|
||||
|
||||
/* use getpos()'s 'autodescribe' to view whatever is currently shown on map */
|
||||
static void
|
||||
browse_map(ter_typ, ter_explain)
|
||||
int ter_typ;
|
||||
const char *ter_explain;
|
||||
browse_map(int ter_typ, const char *ter_explain)
|
||||
{
|
||||
coord dummy_pos; /* don't care whether player actually picks a spot */
|
||||
boolean save_autodescribe;
|
||||
@@ -88,9 +85,7 @@ const char *ter_explain;
|
||||
|
||||
/* extracted from monster_detection() so can be shared by do_vicinity_map() */
|
||||
static void
|
||||
map_monst(mtmp, showtail)
|
||||
struct monst *mtmp;
|
||||
boolean showtail;
|
||||
map_monst(struct monst *mtmp, boolean showtail)
|
||||
{
|
||||
if (def_monsyms[(int) mtmp->data->mlet].sym == ' ')
|
||||
show_glyph(mtmp->mx, mtmp->my,
|
||||
@@ -107,9 +102,7 @@ boolean showtail;
|
||||
/* this is checking whether a trap symbol represents a trapped chest,
|
||||
not whether a trapped chest is actually present */
|
||||
boolean
|
||||
trapped_chest_at(ttyp, x, y)
|
||||
int ttyp;
|
||||
int x, y;
|
||||
trapped_chest_at(int ttyp, int x, int y)
|
||||
{
|
||||
struct monst *mtmp;
|
||||
struct obj *otmp;
|
||||
@@ -152,9 +145,7 @@ int x, y;
|
||||
/* this is checking whether a trap symbol represents a trapped door,
|
||||
not whether the door here is actually trapped */
|
||||
boolean
|
||||
trapped_door_at(ttyp, x, y)
|
||||
int ttyp;
|
||||
int x, y;
|
||||
trapped_door_at(int ttyp, int x, int y)
|
||||
{
|
||||
struct rm *lev;
|
||||
|
||||
@@ -173,9 +164,7 @@ int x, y;
|
||||
|
||||
/* recursively search obj for an object in class oclass, return 1st found */
|
||||
struct obj *
|
||||
o_in(obj, oclass)
|
||||
struct obj *obj;
|
||||
char oclass;
|
||||
o_in(struct obj *obj, char oclass)
|
||||
{
|
||||
register struct obj *otmp;
|
||||
struct obj *temp;
|
||||
@@ -203,9 +192,7 @@ char oclass;
|
||||
* Return first found.
|
||||
*/
|
||||
struct obj *
|
||||
o_material(obj, material)
|
||||
struct obj *obj;
|
||||
unsigned material;
|
||||
o_material(struct obj *obj, unsigned material)
|
||||
{
|
||||
register struct obj *otmp;
|
||||
struct obj *temp;
|
||||
@@ -225,8 +212,7 @@ unsigned material;
|
||||
}
|
||||
|
||||
static void
|
||||
do_dknown_of(obj)
|
||||
struct obj *obj;
|
||||
do_dknown_of(struct obj *obj)
|
||||
{
|
||||
struct obj *otmp;
|
||||
|
||||
@@ -239,10 +225,7 @@ struct obj *obj;
|
||||
|
||||
/* Check whether the location has an outdated object displayed on it. */
|
||||
static boolean
|
||||
check_map_spot(x, y, oclass, material)
|
||||
int x, y;
|
||||
char oclass;
|
||||
unsigned material;
|
||||
check_map_spot(int x, int y, char oclass, unsigned material)
|
||||
{
|
||||
int glyph;
|
||||
register struct obj *otmp;
|
||||
@@ -296,9 +279,7 @@ unsigned material;
|
||||
* change occurs.
|
||||
*/
|
||||
static boolean
|
||||
clear_stale_map(oclass, material)
|
||||
char oclass;
|
||||
unsigned material;
|
||||
clear_stale_map(char oclass, unsigned material)
|
||||
{
|
||||
register int zx, zy;
|
||||
boolean change_made = FALSE;
|
||||
@@ -315,8 +296,7 @@ unsigned material;
|
||||
|
||||
/* look for gold, on the floor or in monsters' possession */
|
||||
int
|
||||
gold_detect(sobj)
|
||||
register struct obj *sobj;
|
||||
gold_detect(struct obj *sobj)
|
||||
{
|
||||
register struct obj *obj;
|
||||
register struct monst *mtmp;
|
||||
@@ -462,8 +442,7 @@ register struct obj *sobj;
|
||||
|
||||
/* returns 1 if nothing was detected, 0 if something was detected */
|
||||
int
|
||||
food_detect(sobj)
|
||||
register struct obj *sobj;
|
||||
food_detect(struct obj *sobj)
|
||||
{
|
||||
register struct obj *obj;
|
||||
register struct monst *mtmp;
|
||||
@@ -587,9 +566,8 @@ register struct obj *sobj;
|
||||
* 0 - something was detected
|
||||
*/
|
||||
int
|
||||
object_detect(detector, class)
|
||||
struct obj *detector; /* object doing the detecting */
|
||||
int class; /* an object class, 0 for all */
|
||||
object_detect(struct obj *detector, /* object doing the detecting */
|
||||
int class) /* an object class, 0 for all */
|
||||
{
|
||||
register int x, y;
|
||||
char stuff[BUFSZ];
|
||||
@@ -782,9 +760,8 @@ int class; /* an object class, 0 for all */
|
||||
* Returns 0 if something was detected.
|
||||
*/
|
||||
int
|
||||
monster_detect(otmp, mclass)
|
||||
register struct obj *otmp; /* detecting object (if any) */
|
||||
int mclass; /* monster class, 0 for all */
|
||||
monster_detect(struct obj *otmp, /* detecting object (if any) */
|
||||
int mclass) /* monster class, 0 for all */
|
||||
{
|
||||
register struct monst *mtmp;
|
||||
int mcnt = 0;
|
||||
@@ -851,10 +828,7 @@ int mclass; /* monster class, 0 for all */
|
||||
}
|
||||
|
||||
static void
|
||||
sense_trap(trap, x, y, src_cursed)
|
||||
struct trap *trap;
|
||||
xchar x, y;
|
||||
int src_cursed;
|
||||
sense_trap(struct trap *trap, xchar x, xchar y, int src_cursed)
|
||||
{
|
||||
if (Hallucination || src_cursed) {
|
||||
struct obj obj; /* fake object */
|
||||
@@ -894,10 +868,8 @@ int src_cursed;
|
||||
2 if found at some other spot, 3 if both, 0 otherwise; optionally
|
||||
update the map to show where such traps were found */
|
||||
static int
|
||||
detect_obj_traps(objlist, show_them, how)
|
||||
struct obj *objlist;
|
||||
boolean show_them;
|
||||
int how; /* 1 for misleading map feedback */
|
||||
detect_obj_traps(struct obj *objlist, boolean show_them,
|
||||
int how) /* 1 for misleading map feedback */
|
||||
{
|
||||
struct obj *otmp;
|
||||
xchar x, y;
|
||||
@@ -927,8 +899,8 @@ int how; /* 1 for misleading map feedback */
|
||||
* returns 0 if something was detected
|
||||
*/
|
||||
int
|
||||
trap_detect(sobj)
|
||||
struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */
|
||||
trap_detect(struct obj *sobj) /* null if crystal ball,
|
||||
*scroll if gold detection scroll */
|
||||
{
|
||||
register struct trap *ttmp;
|
||||
struct monst *mon;
|
||||
@@ -1033,7 +1005,7 @@ struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */
|
||||
}
|
||||
|
||||
static int
|
||||
furniture_detect()
|
||||
furniture_detect(void)
|
||||
{
|
||||
struct monst *mon;
|
||||
int x, y, glyph, sym, found = 0, revealed = 0;
|
||||
@@ -1078,8 +1050,7 @@ furniture_detect()
|
||||
}
|
||||
|
||||
const char *
|
||||
level_distance(where)
|
||||
d_level *where;
|
||||
level_distance(d_level *where)
|
||||
{
|
||||
register schar ll = depth(&u.uz) - depth(where);
|
||||
register boolean indun = (u.uz.dnum == where->dnum);
|
||||
@@ -1139,8 +1110,7 @@ static const struct crystalballlevels {
|
||||
};
|
||||
|
||||
void
|
||||
use_crystal_ball(optr)
|
||||
struct obj **optr;
|
||||
use_crystal_ball(struct obj **optr)
|
||||
{
|
||||
char ch;
|
||||
int oops;
|
||||
@@ -1305,8 +1275,7 @@ struct obj **optr;
|
||||
}
|
||||
|
||||
static void
|
||||
show_map_spot(x, y)
|
||||
register int x, y;
|
||||
show_map_spot(int x, int y)
|
||||
{
|
||||
struct rm *lev;
|
||||
struct trap *t;
|
||||
@@ -1350,7 +1319,7 @@ register int x, y;
|
||||
}
|
||||
|
||||
void
|
||||
do_mapping()
|
||||
do_mapping(void)
|
||||
{
|
||||
register int zx, zy;
|
||||
boolean unconstrained;
|
||||
@@ -1373,8 +1342,7 @@ do_mapping()
|
||||
|
||||
/* clairvoyance */
|
||||
void
|
||||
do_vicinity_map(sobj)
|
||||
struct obj *sobj; /* scroll--actually fake spellbook--object */
|
||||
do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */
|
||||
{
|
||||
register int zx, zy;
|
||||
struct monst *mtmp;
|
||||
@@ -1514,8 +1482,7 @@ struct obj *sobj; /* scroll--actually fake spellbook--object */
|
||||
|
||||
/* convert a secret door into a normal door */
|
||||
void
|
||||
cvt_sdoor_to_door(lev)
|
||||
struct rm *lev;
|
||||
cvt_sdoor_to_door(struct rm *lev)
|
||||
{
|
||||
int newmask = lev->doormask & ~WM_MASK;
|
||||
|
||||
@@ -1534,9 +1501,7 @@ struct rm *lev;
|
||||
/* find something at one location; it should find all somethings there
|
||||
since it is used for magical detection rather than physical searching */
|
||||
static void
|
||||
findone(zx, zy, num)
|
||||
int zx, zy;
|
||||
genericptr_t num;
|
||||
findone(int zx, int zy, genericptr_t num)
|
||||
{
|
||||
register struct trap *ttmp;
|
||||
register struct monst *mtmp;
|
||||
@@ -1590,9 +1555,7 @@ genericptr_t num;
|
||||
}
|
||||
|
||||
static void
|
||||
openone(zx, zy, num)
|
||||
int zx, zy;
|
||||
genericptr_t num;
|
||||
openone(int zx, int zy, genericptr_t num)
|
||||
{
|
||||
register struct trap *ttmp;
|
||||
register struct obj *otmp;
|
||||
@@ -1653,7 +1616,7 @@ genericptr_t num;
|
||||
|
||||
/* returns number of things found */
|
||||
int
|
||||
findit()
|
||||
findit(void)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
@@ -1665,7 +1628,7 @@ findit()
|
||||
|
||||
/* returns number of things found and opened */
|
||||
int
|
||||
openit()
|
||||
openit(void)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
@@ -1686,15 +1649,13 @@ openit()
|
||||
|
||||
/* callback hack for overriding vision in do_clear_area() */
|
||||
boolean
|
||||
detecting(func)
|
||||
void FDECL((*func), (int, int, genericptr_t));
|
||||
detecting(void (*func)(int, int, genericptr_t))
|
||||
{
|
||||
return (func == findone || func == openone);
|
||||
}
|
||||
|
||||
void
|
||||
find_trap(trap)
|
||||
struct trap *trap;
|
||||
find_trap(struct trap *trap)
|
||||
{
|
||||
boolean cleared = FALSE;
|
||||
|
||||
@@ -1723,9 +1684,7 @@ struct trap *trap;
|
||||
}
|
||||
|
||||
static int
|
||||
mfind0(mtmp, via_warning)
|
||||
struct monst *mtmp;
|
||||
boolean via_warning;
|
||||
mfind0(struct monst *mtmp, boolean via_warning)
|
||||
{
|
||||
int x = mtmp->mx, y = mtmp->my;
|
||||
boolean found_something = FALSE;
|
||||
@@ -1773,8 +1732,7 @@ boolean via_warning;
|
||||
}
|
||||
|
||||
int
|
||||
dosearch0(aflag)
|
||||
register int aflag; /* intrinsic autosearch vs explicit searching */
|
||||
dosearch0(int aflag) /* intrinsic autosearch vs explicit searching */
|
||||
{
|
||||
xchar x, y;
|
||||
register struct trap *trap;
|
||||
@@ -1852,7 +1810,7 @@ register int aflag; /* intrinsic autosearch vs explicit searching */
|
||||
|
||||
/* the 's' command -- explicit searching */
|
||||
int
|
||||
dosearch()
|
||||
dosearch(void)
|
||||
{
|
||||
if (cmd_safety_prevention("another search",
|
||||
"You already found a monster.",
|
||||
@@ -1862,7 +1820,7 @@ dosearch()
|
||||
}
|
||||
|
||||
void
|
||||
warnreveal()
|
||||
warnreveal(void)
|
||||
{
|
||||
int x, y;
|
||||
struct monst *mtmp;
|
||||
@@ -1879,7 +1837,7 @@ warnreveal()
|
||||
|
||||
/* Pre-map the sokoban levels */
|
||||
void
|
||||
sokoban_detect()
|
||||
sokoban_detect(void)
|
||||
{
|
||||
register int x, y;
|
||||
register struct trap *ttmp;
|
||||
@@ -1906,10 +1864,8 @@ sokoban_detect()
|
||||
}
|
||||
|
||||
static int
|
||||
reveal_terrain_getglyph(x, y, full, swallowed, default_glyph, which_subset)
|
||||
int x, y, full;
|
||||
unsigned swallowed;
|
||||
int default_glyph, which_subset;
|
||||
reveal_terrain_getglyph(int x, int y, int full, unsigned swallowed,
|
||||
int default_glyph, int which_subset)
|
||||
{
|
||||
int glyph, levl_glyph;
|
||||
uchar seenv;
|
||||
@@ -1987,7 +1943,7 @@ int default_glyph, which_subset;
|
||||
|
||||
#ifdef DUMPLOG
|
||||
void
|
||||
dump_map()
|
||||
dump_map(void)
|
||||
{
|
||||
int x, y, glyph, skippedrows, lastnonblank;
|
||||
int subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON;
|
||||
@@ -2044,9 +2000,10 @@ dump_map()
|
||||
/* idea from crawl; show known portion of map without any monsters,
|
||||
objects, or traps occluding the view of the underlying terrain */
|
||||
void
|
||||
reveal_terrain(full, which_subset)
|
||||
int full; /* wizard|explore modes allow player to request full map */
|
||||
int which_subset; /* when not full, whether to suppress objs and/or traps */
|
||||
reveal_terrain(int full, /* wizard|explore modes allow player
|
||||
to request full map */
|
||||
int which_subset) /* when not full, whether to suppress
|
||||
objs and/or traps */
|
||||
{
|
||||
if ((Hallucination || Stunned || Confusion) && !full) {
|
||||
You("are too disoriented for this.");
|
||||
@@ -2101,7 +2058,7 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */
|
||||
}
|
||||
|
||||
int
|
||||
wiz_mgender(VOID_ARGS)
|
||||
wiz_mgender(void)
|
||||
{
|
||||
iflags.wizmgender = !iflags.wizmgender;
|
||||
pline("wizmgender toggled %s", iflags.wizmgender ? "on" : "off");
|
||||
|
||||
Reference in New Issue
Block a user