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

@@ -14,22 +14,21 @@
(mptr->mlet == S_HUMAN && Role_if(role_pm) \
&& (mptr->msound == MS_LEADER || mptr->msound == MS_NEMESIS))
static boolean FDECL(uncommon, (int));
static int FDECL(align_shift, (struct permonst *));
static boolean FDECL(mk_gen_ok, (int, unsigned, unsigned));
static boolean FDECL(wrong_elem_type, (struct permonst *));
static void FDECL(m_initgrp, (struct monst *, int, int, int, int));
static void FDECL(m_initthrow, (struct monst *, int, int));
static void FDECL(m_initweap, (struct monst *));
static void FDECL(m_initinv, (struct monst *));
static boolean FDECL(makemon_rnd_goodpos, (struct monst *, long, coord *));
static boolean uncommon(int);
static int align_shift(struct permonst *);
static boolean mk_gen_ok(int, unsigned, unsigned);
static boolean wrong_elem_type(struct permonst *);
static void m_initgrp(struct monst *, int, int, int, int);
static void m_initthrow(struct monst *, int, int);
static void m_initweap(struct monst *);
static void m_initinv(struct monst *);
static boolean makemon_rnd_goodpos(struct monst *, long, coord *);
#define m_initsgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 3, mmf)
#define m_initlgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 10, mmf)
boolean
is_home_elemental(ptr)
struct permonst *ptr;
is_home_elemental(struct permonst *ptr)
{
if (ptr->mlet == S_ELEMENTAL)
switch (monsndx(ptr)) {
@@ -49,8 +48,7 @@ struct permonst *ptr;
* Return true if the given monster cannot exist on this elemental level.
*/
static boolean
wrong_elem_type(ptr)
struct permonst *ptr;
wrong_elem_type(struct permonst *ptr)
{
if (ptr->mlet == S_ELEMENTAL) {
return (boolean) !is_home_elemental(ptr);
@@ -73,9 +71,7 @@ struct permonst *ptr;
/* make a group just like mtmp */
static void
m_initgrp(mtmp, x, y, n, mmflags)
struct monst *mtmp;
int x, y, n, mmflags;
m_initgrp(struct monst *mtmp, int x, int y, int n, int mmflags)
{
coord mm;
register int cnt = rnd(n);
@@ -142,9 +138,7 @@ int x, y, n, mmflags;
static
void
m_initthrow(mtmp, otyp, oquan)
struct monst *mtmp;
int otyp, oquan;
m_initthrow(struct monst *mtmp, int otyp, int oquan)
{
register struct obj *otmp;
@@ -157,8 +151,7 @@ int otyp, oquan;
}
static void
m_initweap(mtmp)
register struct monst *mtmp;
m_initweap(register struct monst *mtmp)
{
register struct permonst *ptr = mtmp->data;
register int mm = monsndx(ptr);
@@ -558,9 +551,7 @@ register struct monst *mtmp;
* Makes up money for monster's inventory.
*/
void
mkmonmoney(mtmp, amount)
struct monst *mtmp;
long amount;
mkmonmoney(struct monst *mtmp, long amount)
{
struct obj *gold = mksobj(GOLD_PIECE, FALSE, FALSE);
@@ -569,8 +560,7 @@ long amount;
}
static void
m_initinv(mtmp)
register struct monst *mtmp;
m_initinv(register struct monst *mtmp)
{
register int cnt;
register struct obj *otmp;
@@ -815,9 +805,8 @@ register struct monst *mtmp;
/* Note: for long worms, always call cutworm (cutworm calls clone_mon) */
struct monst *
clone_mon(mon, x, y)
struct monst *mon;
xchar x, y; /* clone's preferred location or 0 (near mon) */
clone_mon(struct monst *mon,
xchar x, xchar y) /* clone's preferred location or 0 (near mon) */
{
coord mm;
struct monst *m2;
@@ -934,10 +923,7 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
* TRUE propagation successful
*/
boolean
propagate(mndx, tally, ghostly)
int mndx;
boolean tally;
boolean ghostly;
propagate(int mndx, boolean tally, boolean ghostly)
{
boolean gone, result;
int lim = mbirth_limit(mndx);
@@ -965,8 +951,7 @@ boolean ghostly;
/* amount of HP to lose from level drain (or gain from Stormbringer) */
int
monhp_per_lvl(mon)
struct monst *mon;
monhp_per_lvl(struct monst *mon)
{
struct permonst *ptr = mon->data;
int hp = rnd(8); /* default is d8 */
@@ -992,9 +977,7 @@ struct monst *mon;
/* set up a new monster's initial level and hit points;
used by newcham() as well as by makemon() */
void
newmonhp(mon, mndx)
struct monst *mon;
int mndx;
newmonhp(struct monst *mon, int mndx)
{
struct permonst *ptr = &mons[mndx];
int basehp = 0;
@@ -1041,15 +1024,14 @@ int mndx;
static const struct mextra zeromextra = DUMMY;
static void
init_mextra(mex)
struct mextra *mex;
init_mextra(struct mextra *mex)
{
*mex = zeromextra;
mex->mcorpsenm = NON_PM;
}
struct mextra *
newmextra()
newmextra(void)
{
struct mextra *mextra;
@@ -1059,10 +1041,7 @@ newmextra()
}
static boolean
makemon_rnd_goodpos(mon, gpflags, cc)
struct monst *mon;
long gpflags;
coord *cc;
makemon_rnd_goodpos(struct monst *mon, long gpflags, coord *cc)
{
int tryct = 0;
int nx, ny;
@@ -1127,10 +1106,8 @@ coord *cc;
* In case we make a monster group, only return the one at [x,y].
*/
struct monst *
makemon(ptr, x, y, mmflags)
register struct permonst *ptr;
register int x, y;
long mmflags;
makemon(register struct permonst *ptr,
register int x, register int y, long mmflags)
{
register struct monst *mtmp;
struct monst fakemon;
@@ -1435,9 +1412,7 @@ long mmflags;
/* caller rejects makemon()'s result; always returns Null */
struct monst *
unmakemon(mon, mmflags)
struct monst *mon;
long mmflags;
unmakemon(struct monst *mon, long mmflags)
{
boolean countbirth = ((mmflags & MM_NOCOUNTBIRTH) == 0);
int mndx = monsndx(mon->data);
@@ -1462,8 +1437,7 @@ long mmflags;
}
int
mbirth_limit(mndx)
int mndx;
mbirth_limit(int mndx)
{
/* There is an implicit limit of 4 for "high priest of <deity>",
* but aligned priests can grow into high priests, thus they aren't
@@ -1477,10 +1451,9 @@ int mndx;
/* used for wand/scroll/spell of create monster */
/* returns TRUE iff you know monsters have been created */
boolean
create_critters(cnt, mptr, neverask)
int cnt;
struct permonst *mptr; /* usually null; used for confused reading */
boolean neverask;
create_critters(int cnt,
struct permonst *mptr, /* usually null; used for confused reading */
boolean neverask)
{
coord c;
int x, y;
@@ -1514,8 +1487,7 @@ boolean neverask;
}
static boolean
uncommon(mndx)
int mndx;
uncommon(int mndx)
{
if (mons[mndx].geno & (G_NOGEN | G_UNIQ))
return TRUE;
@@ -1533,8 +1505,7 @@ int mndx;
* return an integer in the range of 0-5.
*/
static int
align_shift(ptr)
register struct permonst *ptr;
align_shift(register struct permonst *ptr)
{
static NEARDATA long oldmoves = 0L; /* != 1, starting value of moves */
static NEARDATA s_level *lev;
@@ -1564,7 +1535,7 @@ register struct permonst *ptr;
/* select a random monster type */
struct permonst *
rndmonst()
rndmonst(void)
{
register struct permonst *ptr;
register int mndx;
@@ -1640,9 +1611,7 @@ rndmonst()
/* decide whether it's ok to generate a candidate monster by mkclass() */
static boolean
mk_gen_ok(mndx, mvflagsmask, genomask)
int mndx;
unsigned mvflagsmask, genomask;
mk_gen_ok(int mndx, unsigned mvflagsmask, unsigned genomask)
{
struct permonst *ptr = &mons[mndx];
@@ -1665,19 +1634,15 @@ unsigned mvflagsmask, genomask;
to allow the normal genesis masks to be deactivated.
Returns Null if no monsters in that class can be made. */
struct permonst *
mkclass(class, spc)
char class;
int spc;
mkclass(char class, int spc)
{
return mkclass_aligned(class, spc, A_NONE);
}
/* mkclass() with alignment restrictions; used by ndemon() */
struct permonst *
mkclass_aligned(class, spc, atyp)
char class;
int spc; /* special mons[].geno handling */
aligntyp atyp;
mkclass_aligned(char class, int spc, /* special mons[].geno handling */
aligntyp atyp)
{
register int first, last, num = 0;
int k, nums[SPECIAL_PM + 1]; /* +1: insurance for final return value */
@@ -1769,8 +1734,7 @@ aligntyp atyp;
genocided types are avoided but extinct ones are acceptable; we don't
check polyok() here--caller accepts some choices !polyok() would reject */
int
mkclass_poly(class)
int class;
mkclass_poly(int class)
{
register int first, last, num = 0;
unsigned gmask;
@@ -1803,8 +1767,7 @@ int class;
/* adjust strength of monsters based on u.uz and u.ulevel */
int
adj_lev(ptr)
register struct permonst *ptr;
adj_lev(register struct permonst *ptr)
{
int tmp, tmp2;
@@ -1839,8 +1802,7 @@ register struct permonst *ptr;
/* monster earned experience and will gain some hit points; it might also
grow into a bigger monster (baby to adult, soldier to officer, etc) */
struct permonst *
grow_up(mtmp, victim)
struct monst *mtmp, *victim;
grow_up(struct monst *mtmp, struct monst *victim)
{
int oldtype, newtype, max_increase, cur_increase, lev_limit, hp_threshold;
unsigned fem;
@@ -1965,9 +1927,7 @@ struct monst *mtmp, *victim;
}
struct obj *
mongets(mtmp, otyp)
register struct monst *mtmp;
int otyp;
mongets(register struct monst *mtmp, int otyp)
{
register struct obj *otmp;
@@ -2018,8 +1978,7 @@ int otyp;
}
int
golemhp(type)
int type;
golemhp(int type)
{
switch (type) {
case PM_STRAW_GOLEM:
@@ -2054,8 +2013,7 @@ int type;
* (Some "animal" types are co-aligned, but also hungry.)
*/
boolean
peace_minded(ptr)
register struct permonst *ptr;
peace_minded(register struct permonst *ptr)
{
aligntyp mal = ptr->maligntyp, ual = u.ualign.type;
@@ -2106,8 +2064,7 @@ register struct permonst *ptr;
* it's never bad to kill a hostile monster, although it may not be good.
*/
void
set_malign(mtmp)
struct monst *mtmp;
set_malign(struct monst *mtmp)
{
schar mal = mtmp->data->maligntyp;
boolean coaligned;
@@ -2156,8 +2113,7 @@ struct monst *mtmp;
/* allocate a new mcorpsenm field for a monster; only need mextra itself */
void
newmcorpsenm(mtmp)
struct monst *mtmp;
newmcorpsenm(struct monst *mtmp)
{
if (!mtmp->mextra)
mtmp->mextra = newmextra();
@@ -2166,8 +2122,7 @@ struct monst *mtmp;
/* release monster's mcorpsenm field; basically a no-op */
void
freemcorpsenm(mtmp)
struct monst *mtmp;
freemcorpsenm(struct monst *mtmp)
{
if (has_mcorpsenm(mtmp))
MCORPSENM(mtmp) = NON_PM;
@@ -2181,8 +2136,7 @@ static const NEARDATA char syms[] = {
};
void
set_mimic_sym(mtmp)
register struct monst *mtmp;
set_mimic_sym(register struct monst *mtmp)
{
int typ, roomno, rt;
unsigned appear, ap_type;
@@ -2339,10 +2293,9 @@ register struct monst *mtmp;
/* release monster from bag of tricks; return number of monsters created */
int
bagotricks(bag, tipping, seencount)
struct obj *bag;
boolean tipping; /* caller emptying entire contents; affects shop handling */
int *seencount; /* secondary output */
bagotricks(struct obj *bag,
boolean tipping, /* caller emptying entire contents; affects shop handling */
int *seencount) /* secondary output */
{
int moncount = 0;