switch source tree from k&r to c99

This commit is contained in:
nhmall
2021-01-26 21:06:16 -05:00
parent a2a9cb7b4f
commit f963c5aca7
232 changed files with 12099 additions and 17782 deletions

View File

@@ -7,17 +7,17 @@
/* #define DEBUG */ /* uncomment for debugging */
static void NDECL(maybe_wail);
static int NDECL(moverock);
static void NDECL(dosinkfall);
static boolean FDECL(findtravelpath, (int));
static boolean FDECL(trapmove, (int, int, struct trap *));
static struct monst *FDECL(monstinroom, (struct permonst *, int));
static boolean FDECL(doorless_door, (int, int));
static void FDECL(move_update, (BOOLEAN_P));
static int NDECL(pickup_checks);
static void FDECL(maybe_smudge_engr, (int, int, int, int));
static void NDECL(domove_core);
static void maybe_wail(void);
static int moverock(void);
static void dosinkfall(void);
static boolean findtravelpath(int);
static boolean trapmove(int, int, struct trap *);
static struct monst *monstinroom(struct permonst *, int);
static boolean doorless_door(int, int);
static void move_update(boolean);
static int pickup_checks(void);
static void maybe_smudge_engr(int, int, int, int);
static void domove_core(void);
#define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE)
@@ -27,8 +27,7 @@ static void NDECL(domove_core);
#define TRAVP_VALID 2
anything *
uint_to_any(ui)
unsigned ui;
uint_to_any(unsigned ui)
{
g.tmp_anything = cg.zeroany;
g.tmp_anything.a_uint = ui;
@@ -36,8 +35,7 @@ unsigned ui;
}
anything *
long_to_any(lng)
long lng;
long_to_any(long lng)
{
g.tmp_anything = cg.zeroany;
g.tmp_anything.a_long = lng;
@@ -45,8 +43,7 @@ long lng;
}
anything *
monst_to_any(mtmp)
struct monst *mtmp;
monst_to_any(struct monst *mtmp)
{
g.tmp_anything = cg.zeroany;
g.tmp_anything.a_monst = mtmp;
@@ -54,8 +51,7 @@ struct monst *mtmp;
}
anything *
obj_to_any(obj)
struct obj *obj;
obj_to_any(struct obj *obj)
{
g.tmp_anything = cg.zeroany;
g.tmp_anything.a_obj = obj;
@@ -63,9 +59,7 @@ struct obj *obj;
}
boolean
revive_nasty(x, y, msg)
int x, y;
const char *msg;
revive_nasty(int x, int y, const char *msg)
{
register struct obj *otmp, *otmp2;
struct monst *mtmp;
@@ -100,7 +94,7 @@ const char *msg;
}
static int
moverock()
moverock(void)
{
register xchar rx, ry, sx, sy;
register struct obj *otmp;
@@ -394,8 +388,7 @@ moverock()
* Returns TRUE if still eating, FALSE when done.
*/
int
still_chewing(x, y)
xchar x, y;
still_chewing(xchar x, xchar y)
{
struct rm *lev = &levl[x][y];
struct obj *boulder = sobj_at(BOULDER, x, y);
@@ -566,9 +559,7 @@ xchar x, y;
}
void
movobj(obj, ox, oy)
register struct obj *obj;
register xchar ox, oy;
movobj(register struct obj *obj, register xchar ox, register xchar oy)
{
/* optimize by leaving on the fobj chain? */
remove_object(obj);
@@ -581,7 +572,7 @@ register xchar ox, oy;
static NEARDATA const char fell_on_sink[] = "fell onto a sink";
static void
dosinkfall()
dosinkfall(void)
{
register struct obj *obj;
int dmg;
@@ -667,8 +658,7 @@ dosinkfall()
/* intended to be called only on ROCKs or TREEs */
boolean
may_dig(x, y)
register xchar x, y;
may_dig(register xchar x, register xchar y)
{
struct rm *lev = &levl[x][y];
@@ -677,17 +667,14 @@ register xchar x, y;
}
boolean
may_passwall(x, y)
register xchar x, y;
may_passwall(register xchar x, register xchar y)
{
return (boolean) !(IS_STWALL(levl[x][y].typ)
&& (levl[x][y].wall_info & W_NONPASSWALL));
}
boolean
bad_rock(mdat, x, y)
struct permonst *mdat;
register xchar x, y;
bad_rock(struct permonst *mdat, register xchar x, register xchar y)
{
return (boolean) ((Sokoban && sobj_at(BOULDER, x, y))
|| (IS_ROCK(levl[x][y].typ)
@@ -701,8 +688,7 @@ register xchar x, y;
the reason why: 1: can't fit, 2: possessions won't fit, 3: sokoban
returns 0 if we can squeeze through */
int
cant_squeeze_thru(mon)
struct monst *mon;
cant_squeeze_thru(struct monst *mon)
{
int amt;
struct permonst *ptr = mon->data;
@@ -728,8 +714,7 @@ struct monst *mon;
}
boolean
invocation_pos(x, y)
xchar x, y;
invocation_pos(xchar x, xchar y)
{
return (boolean) (Invocation_lev(&u.uz)
&& x == g.inv_pos.x && y == g.inv_pos.y);
@@ -739,9 +724,7 @@ xchar x, y;
* mode is one of DO_MOVE, TEST_MOVE, TEST_TRAV, or TEST_TRAP
*/
boolean
test_move(ux, uy, dx, dy, mode)
int ux, uy, dx, dy;
int mode;
test_move(int ux, int uy, int dx, int dy, int mode)
{
int x = ux + dx;
int y = uy + dy;
@@ -971,8 +954,7 @@ int mode;
* Returns TRUE if a path was found.
*/
static boolean
findtravelpath(mode)
int mode;
findtravelpath(int mode)
{
/* if travel to adjacent, reachable location, use normal movement rules */
if ((mode == TRAVP_TRAVEL || mode == TRAVP_VALID) && g.context.travel1
@@ -1211,8 +1193,7 @@ int mode;
}
boolean
is_valid_travelpt(x,y)
int x,y;
is_valid_travelpt(int x, int y)
{
int tx = u.tx;
int ty = u.ty;
@@ -1236,9 +1217,8 @@ int x,y;
return true iff moving should continue to intended destination
(all failures and most successful escapes leave hero at original spot) */
static boolean
trapmove(x, y, desttrap)
int x, y; /* targetted destination, <u.ux+u.dx,u.uy+u.dy> */
struct trap *desttrap; /* nonnull if another trap at <x,y> */
trapmove(int x, int y, /* targetted destination, <u.ux+u.dx,u.uy+u.dy> */
struct trap *desttrap) /* nonnull if another trap at <x,y> */
{
boolean anchored = FALSE;
const char *predicament, *culprit;
@@ -1377,7 +1357,7 @@ struct trap *desttrap; /* nonnull if another trap at <x,y> */
}
boolean
u_rooted()
u_rooted(void)
{
if (!g.youmonst.data->mmove) {
You("are rooted %s.",
@@ -1391,7 +1371,7 @@ u_rooted()
}
void
domove()
domove(void)
{
int ux1 = u.ux, uy1 = u.uy;
@@ -1404,7 +1384,7 @@ domove()
}
static void
domove_core()
domove_core(void)
{
register struct monst *mtmp;
register struct rm *tmpr;
@@ -2047,8 +2027,7 @@ domove_core()
}
static void
maybe_smudge_engr(x1,y1,x2,y2)
int x1, y1, x2, y2;
maybe_smudge_engr(int x1, int y1, int x2, int y2)
{
struct engr *ep;
@@ -2063,7 +2042,7 @@ int x1, y1, x2, y2;
/* HP loss or passing out from overexerting yourself */
void
overexert_hp()
overexert_hp(void)
{
int *hp = (!Upolyd ? &u.uhp : &u.mh);
@@ -2079,7 +2058,7 @@ overexert_hp()
/* combat increases metabolism */
boolean
overexertion()
overexertion(void)
{
/* this used to be part of domove() when moving to a monster's
position, but is now called by attack() so that it doesn't
@@ -2092,7 +2071,7 @@ overexertion()
}
void
invocation_message()
invocation_message(void)
{
/* a special clue-msg when on the Invocation position */
if (invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)) {
@@ -2119,7 +2098,7 @@ invocation_message()
might be going into solid rock, inhibiting levitation or flight,
or coming back out of such, reinstating levitation/flying */
void
switch_terrain()
switch_terrain(void)
{
struct rm *lev = &levl[u.ux][u.uy];
boolean blocklev = (IS_ROCK(lev->typ) || closed_door(u.ux, u.uy)
@@ -2158,8 +2137,7 @@ switch_terrain()
/* set or clear u.uinwater */
void
set_uinwater(in_out)
int in_out;
set_uinwater(int in_out)
{
u.uinwater = in_out ? 1 : 0;
}
@@ -2168,8 +2146,7 @@ int in_out;
leaving a pool of water/lava, and by moveloop to check for staying on one;
returns true to skip rest of spoteffects */
boolean
pooleffects(newspot)
boolean newspot; /* true if called by spoteffects */
pooleffects(boolean newspot) /* true if called by spoteffects */
{
/* check for leaving water */
if (u.uinwater) {
@@ -2249,8 +2226,7 @@ boolean newspot; /* true if called by spoteffects */
}
void
spoteffects(pick)
boolean pick;
spoteffects(boolean pick)
{
static int inspoteffects = 0;
static coord spotloc;
@@ -2397,9 +2373,7 @@ boolean pick;
/* returns first matching monster */
static struct monst *
monstinroom(mdat, roomno)
struct permonst *mdat;
int roomno;
monstinroom(struct permonst *mdat, int roomno)
{
register struct monst *mtmp;
@@ -2414,9 +2388,7 @@ int roomno;
}
char *
in_rooms(x, y, typewanted)
register xchar x, y;
register int typewanted;
in_rooms(register xchar x, register xchar y, register int typewanted)
{
static char buf[5];
char rno, *ptr = &buf[4];
@@ -2482,8 +2454,7 @@ register int typewanted;
/* is (x,y) in a town? */
boolean
in_town(x, y)
register int x, y;
in_town(register int x, register int y)
{
s_level *slev = Is_special(&u.uz);
register struct mkroom *sroom;
@@ -2508,8 +2479,7 @@ register int x, y;
}
static void
move_update(newlev)
register boolean newlev;
move_update(register boolean newlev)
{
char *ptr1, *ptr2, *ptr3, *ptr4;
@@ -2549,8 +2519,7 @@ register boolean newlev;
/* possibly deliver a one-time room entry message */
void
check_special_room(newlev)
boolean newlev;
check_special_room(boolean newlev)
{
register struct monst *mtmp;
char *ptr;
@@ -2691,7 +2660,7 @@ boolean newlev;
-1 = do normal pickup
-2 = loot the monster */
static int
pickup_checks()
pickup_checks(void)
{
struct trap *traphere;
@@ -2780,7 +2749,7 @@ pickup_checks()
/* the ',' command */
int
dopickup(VOID_ARGS)
dopickup(void)
{
int count, tmpcount, ret;
@@ -2803,7 +2772,7 @@ dopickup(VOID_ARGS)
/* turn around a corner if that is the only way we can proceed */
/* do not turn left or right twice */
void
lookaround()
lookaround(void)
{
register int x, y;
int i, x0 = 0, y0 = 0, m0 = 1, i0 = 9;
@@ -2957,8 +2926,7 @@ lookaround()
/* check for a doorway which lacks its door (NODOOR or BROKEN) */
static boolean
doorless_door(x, y)
int x, y;
doorless_door(int x, int y)
{
struct rm *lev_p = &levl[x][y];
@@ -2973,8 +2941,7 @@ int x, y;
/* used by drown() to check whether hero can crawl from water to <x,y> */
boolean
crawl_destination(x, y)
int x, y;
crawl_destination(int x, int y)
{
/* is location ok in general? */
if (!goodpos(x, y, &g.youmonst, 0))
@@ -3000,7 +2967,7 @@ int x, y;
/* something like lookaround, but we are not running */
/* react only to monsters that might hit us */
int
monster_nearby()
monster_nearby(void)
{
register int x, y;
register struct monst *mtmp;
@@ -3024,8 +2991,7 @@ monster_nearby()
}
void
end_running(and_travel)
boolean and_travel;
end_running(boolean and_travel)
{
/* moveloop() suppresses time_botl when context.run is non-zero; when
running stops, update 'time' even if other botl status is unchanged */
@@ -3039,8 +3005,7 @@ boolean and_travel;
}
void
nomul(nval)
int nval;
nomul(int nval)
{
if (g.multi < nval)
return; /* This is a bug fix by ab@unido */
@@ -3055,8 +3020,7 @@ int nval;
/* called when a non-movement, multi-turn action has completed */
void
unmul(msg_override)
const char *msg_override;
unmul(const char *msg_override)
{
g.context.botl = TRUE;
g.multi = 0; /* caller will usually have done this already */
@@ -3079,11 +3043,11 @@ const char *msg_override;
u.usleep = 0;
g.multi_reason = NULL;
if (g.afternmv) {
int NDECL((*f)) = g.afternmv;
int (*f)(void) = g.afternmv;
/* clear afternmv before calling it (to override the
encumbrance hack for levitation--see weight_cap()) */
g.afternmv = (int NDECL((*))) 0;
g.afternmv = (int (*)(void)) 0;
(void) (*f)();
/* for finishing Armor/Boots/&c_on() */
update_inventory();
@@ -3091,7 +3055,7 @@ const char *msg_override;
}
static void
maybe_wail()
maybe_wail(void)
{
static short powers[] = { TELEPORT, SEE_INVIS, POISON_RES, COLD_RES,
SHOCK_RES, FIRE_RES, SLEEP_RES, DISINT_RES,
@@ -3125,10 +3089,7 @@ maybe_wail()
}
void
losehp(n, knam, k_format)
register int n;
register const char *knam;
boolean k_format;
losehp(register int n, register const char *knam, boolean k_format)
{
#if 0 /* code below is prepared to handle negative 'loss' so don't add this
* until we've verified that no callers intentionally rely on that */
@@ -3165,7 +3126,7 @@ boolean k_format;
}
int
weight_cap()
weight_cap(void)
{
long carrcap, save_ELev = ELevitation, save_BLev = BLevitation;
@@ -3222,7 +3183,7 @@ weight_cap()
/* returns how far beyond the normal capacity the player is currently. */
/* inv_weight() is negative if the player is below normal capacity. */
int
inv_weight()
inv_weight(void)
{
register struct obj *otmp = g.invent;
register int wt = 0;
@@ -3243,8 +3204,7 @@ inv_weight()
* over the normal capacity the player is loaded. Max is 5.
*/
int
calc_capacity(xtra_wt)
int xtra_wt;
calc_capacity(int xtra_wt)
{
int cap, wt = inv_weight() + xtra_wt;
@@ -3257,13 +3217,13 @@ int xtra_wt;
}
int
near_capacity()
near_capacity(void)
{
return calc_capacity(0);
}
int
max_capacity()
max_capacity(void)
{
int wt = inv_weight();
@@ -3271,8 +3231,7 @@ max_capacity()
}
boolean
check_capacity(str)
const char *str;
check_capacity(const char *str)
{
if (near_capacity() >= EXT_ENCUMBER) {
if (str)
@@ -3285,8 +3244,7 @@ const char *str;
}
int
inv_cnt(incl_gold)
boolean incl_gold;
inv_cnt(boolean incl_gold)
{
register struct obj *otmp = g.invent;
register int ct = 0;
@@ -3304,8 +3262,7 @@ boolean incl_gold;
/* now that u.gold/m.gold is gone.*/
/* Counting money in a container might be possible too. */
long
money_cnt(otmp)
struct obj *otmp;
money_cnt(struct obj *otmp)
{
while (otmp) {
if (otmp->oclass == COIN_CLASS)