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

@@ -10,9 +10,7 @@
/* set up an individual monster's base type (initial creation, shapechange) */
void
set_mon_data(mon, ptr)
struct monst *mon;
struct permonst *ptr;
set_mon_data(struct monst* mon, struct permonst* ptr)
{
int new_speed, old_speed = mon->data ? mon->data->mmove : 0;
@@ -40,9 +38,7 @@ struct permonst *ptr;
/* does monster-type have any attack for a specific type of damage? */
struct attack *
attacktype_fordmg(ptr, atyp, dtyp)
struct permonst *ptr;
int atyp, dtyp;
attacktype_fordmg(struct permonst* ptr, int atyp, int dtyp)
{
struct attack *a;
@@ -54,17 +50,14 @@ int atyp, dtyp;
/* does monster-type have a particular type of attack */
boolean
attacktype(ptr, atyp)
struct permonst *ptr;
int atyp;
attacktype(struct permonst* ptr, int atyp)
{
return attacktype_fordmg(ptr, atyp, AD_ANY) ? TRUE : FALSE;
}
/* returns True if monster doesn't attack, False if it does */
boolean
noattacks(ptr)
struct permonst *ptr;
noattacks(struct permonst* ptr)
{
int i;
struct attack *mattk = ptr->mattk;
@@ -83,8 +76,7 @@ struct permonst *ptr;
/* does monster-type transform into something else when petrified? */
boolean
poly_when_stoned(ptr)
struct permonst *ptr;
poly_when_stoned(struct permonst* ptr)
{
/* non-stone golems turn into stone golems unless latter is genocided */
return (boolean) (is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM]
@@ -94,8 +86,7 @@ struct permonst *ptr;
/* returns True if monster is drain-life resistant */
boolean
resists_drli(mon)
struct monst *mon;
resists_drli(struct monst* mon)
{
struct permonst *ptr = mon->data;
struct obj *wep;
@@ -111,8 +102,7 @@ struct monst *mon;
/* True if monster is magic-missile (actually, general magic) resistant */
boolean
resists_magm(mon)
struct monst *mon;
resists_magm(struct monst* mon)
{
struct permonst *ptr = mon->data;
boolean is_you = (mon == &g.youmonst);
@@ -145,8 +135,7 @@ struct monst *mon;
/* True iff monster is resistant to light-induced blindness */
boolean
resists_blnd(mon)
struct monst *mon;
resists_blnd(struct monst* mon)
{
struct permonst *ptr = mon->data;
boolean is_you = (mon == &g.youmonst);
@@ -186,11 +175,11 @@ struct monst *mon;
magr can be NULL.
*/
boolean
can_blnd(magr, mdef, aatyp, obj)
struct monst *magr; /* NULL == no specific aggressor */
struct monst *mdef;
uchar aatyp;
struct obj *obj; /* aatyp == AT_WEAP, AT_SPIT */
can_blnd(
struct monst *magr, /* NULL == no specific aggressor */
struct monst *mdef,
uchar aatyp,
struct obj *obj) /* aatyp == AT_WEAP, AT_SPIT */
{
boolean is_you = (mdef == &g.youmonst);
boolean check_visor = FALSE;
@@ -279,8 +268,7 @@ struct obj *obj; /* aatyp == AT_WEAP, AT_SPIT */
/* returns True if monster can attack at range */
boolean
ranged_attk(ptr)
struct permonst *ptr;
ranged_attk(struct permonst* ptr)
{
register int i, atyp;
long atk_mask = (1L << AT_BREA) | (1L << AT_SPIT) | (1L << AT_GAZE);
@@ -303,16 +291,14 @@ struct permonst *ptr;
/* True if specific monster is especially affected by silver weapons */
boolean
mon_hates_silver(mon)
struct monst *mon;
mon_hates_silver(struct monst* mon)
{
return (boolean) (is_vampshifter(mon) || hates_silver(mon->data));
}
/* True if monster-type is especially affected by silver weapons */
boolean
hates_silver(ptr)
register struct permonst *ptr;
hates_silver(register struct permonst* ptr)
{
return (boolean) (is_were(ptr) || ptr->mlet == S_VAMPIRE || is_demon(ptr)
|| ptr == &mons[PM_SHADE]
@@ -321,16 +307,14 @@ register struct permonst *ptr;
/* True if specific monster is especially affected by light-emitting weapons */
boolean
mon_hates_light(mon)
struct monst *mon;
mon_hates_light(struct monst* mon)
{
return (boolean) (hates_light(mon->data));
}
/* True iff the type of monster pass through iron bars */
boolean
passes_bars(mptr)
struct permonst *mptr;
passes_bars(struct permonst* mptr)
{
return (boolean) (passes_walls(mptr) || amorphous(mptr) || unsolid(mptr)
|| is_whirly(mptr) || verysmall(mptr)
@@ -343,8 +327,7 @@ struct permonst *mptr;
/* returns True if monster can blow (whistle, etc) */
boolean
can_blow(mtmp)
struct monst *mtmp;
can_blow(struct monst* mtmp)
{
if ((is_silent(mtmp->data) || mtmp->data->msound == MS_BUZZ)
&& (breathless(mtmp->data) || verysmall(mtmp->data)
@@ -357,8 +340,7 @@ struct monst *mtmp;
/* for casting spells and reading scrolls while blind */
boolean
can_chant(mtmp)
struct monst *mtmp;
can_chant(struct monst* mtmp)
{
if ((mtmp == &g.youmonst && Strangled)
|| is_silent(mtmp->data) || !has_head(mtmp->data)
@@ -369,8 +351,7 @@ struct monst *mtmp;
/* True if mon is vulnerable to strangulation */
boolean
can_be_strangled(mon)
struct monst *mon;
can_be_strangled(struct monst* mon)
{
struct obj *mamul;
boolean nonbreathing, nobrainer;
@@ -402,8 +383,7 @@ struct monst *mon;
/* returns True if monster can track well */
boolean
can_track(ptr)
register struct permonst *ptr;
can_track(register struct permonst* ptr)
{
if (uwep && uwep->oartifact == ART_EXCALIBUR)
return TRUE;
@@ -413,8 +393,7 @@ register struct permonst *ptr;
/* creature will slide out of armor */
boolean
sliparm(ptr)
register struct permonst *ptr;
sliparm(register struct permonst* ptr)
{
return (boolean) (is_whirly(ptr) || ptr->msize <= MZ_SMALL
|| noncorporeal(ptr));
@@ -422,8 +401,7 @@ register struct permonst *ptr;
/* creature will break out of armor */
boolean
breakarm(ptr)
register struct permonst *ptr;
breakarm(register struct permonst* ptr)
{
if (sliparm(ptr))
return FALSE;
@@ -437,8 +415,7 @@ register struct permonst *ptr;
/* creature sticks other creatures it hits */
boolean
sticks(ptr)
register struct permonst *ptr;
sticks(register struct permonst* ptr)
{
return (boolean) (dmgtype(ptr, AD_STCK) || dmgtype(ptr, AD_WRAP)
|| attacktype(ptr, AT_HUGS));
@@ -446,8 +423,7 @@ register struct permonst *ptr;
/* some monster-types can't vomit */
boolean
cantvomit(ptr)
struct permonst *ptr;
cantvomit(struct permonst* ptr)
{
/* rats and mice are incapable of vomiting;
which other creatures have the same limitation? */
@@ -459,8 +435,7 @@ struct permonst *ptr;
/* number of horns this type of monster has on its head */
int
num_horns(ptr)
struct permonst *ptr;
num_horns(struct permonst* ptr)
{
switch (monsndx(ptr)) {
case PM_HORNED_DEVIL: /* ? "more than one" */
@@ -482,9 +457,7 @@ struct permonst *ptr;
/* does monster-type deal out a particular type of damage from a particular
type of attack? */
struct attack *
dmgtype_fromattack(ptr, dtyp, atyp)
struct permonst *ptr;
int dtyp, atyp;
dmgtype_fromattack(struct permonst* ptr, int dtyp, int atyp)
{
struct attack *a;
@@ -496,9 +469,7 @@ int dtyp, atyp;
/* does monster-type deal out a particular type of damage from any attack */
boolean
dmgtype(ptr, dtyp)
struct permonst *ptr;
int dtyp;
dmgtype(struct permonst* ptr, int dtyp)
{
return dmgtype_fromattack(ptr, dtyp, AT_ANY) ? TRUE : FALSE;
}
@@ -506,8 +477,7 @@ int dtyp;
/* returns the maximum damage a defender can do to the attacker via
a passive defense */
int
max_passive_dmg(mdef, magr)
register struct monst *mdef, *magr;
max_passive_dmg(register struct monst* mdef, register struct monst* magr)
{
int i, dmg, multi2 = 0;
uchar adtyp;
@@ -558,8 +528,7 @@ register struct monst *mdef, *magr;
/* determine whether two monster types are from the same species */
boolean
same_race(pm1, pm2)
struct permonst *pm1, *pm2;
same_race(struct permonst* pm1, struct permonst* pm2)
{
char let1 = pm1->mlet, let2 = pm2->mlet;
@@ -663,8 +632,7 @@ struct permonst *pm1, *pm2;
/* return an index into the mons array */
int
monsndx(ptr)
struct permonst *ptr;
monsndx(struct permonst* ptr)
{
register int i;
@@ -687,9 +655,7 @@ struct alt_spl {
/* figure out what type of monster a user-supplied string is specifying;
ingore anything past the monster name */
int
name_to_mon(in_str, gender_name_var)
const char *in_str;
int *gender_name_var;
name_to_mon(const char *in_str, int * gender_name_var)
{
return name_to_monplus(in_str, (const char **) 0, gender_name_var);
}
@@ -699,10 +665,10 @@ int *gender_name_var;
caller wants to strip off the name and it matches one of the alternate
names rather the canonical mons[].mname */
int
name_to_monplus(in_str, remainder_p, gender_name_var)
const char *in_str;
const char **remainder_p;
int *gender_name_var;
name_to_monplus(
const char *in_str,
const char **remainder_p,
int *gender_name_var)
{
/* Be careful. We must check the entire string in case it was
* something such as "ettin zombie corpse". The calling routine
@@ -882,9 +848,7 @@ int *gender_name_var;
/* monster class from user input; used for genocide and controlled polymorph;
returns 0 rather than MAXMCLASSES if no match is found */
int
name_to_monclass(in_str, mndx_p)
const char *in_str;
int *mndx_p;
name_to_monclass(const char *in_str, int * mndx_p)
{
/* Single letters are matched against def_monsyms[].sym; words
or phrases are first matched against def_monsyms[].explain
@@ -974,8 +938,7 @@ int *mndx_p;
/* returns 3 values (0=male, 1=female, 2=none) */
int
gender(mtmp)
register struct monst *mtmp;
gender(register struct monst* mtmp)
{
if (is_neuter(mtmp->data))
return 2;
@@ -986,10 +949,10 @@ register struct monst *mtmp;
and lower animals and such are "it" even when seen; hallucination might
yield "they". This is the one we want to use when printing messages. */
int
pronoun_gender(mtmp, pg_flags)
register struct monst *mtmp;
unsigned pg_flags; /* flags&1: 'no it' unless neuter,
* flags&2: random if hallucinating */
pronoun_gender(
register struct monst *mtmp,
unsigned pg_flags) /* flags&1: 'no it' unless neuter,
* flags&2: random if hallucinating */
{
boolean override_vis = (pg_flags & PRONOUN_NO_IT) ? TRUE : FALSE,
hallu_rand = (pg_flags & PRONOUN_HALLU) ? TRUE : FALSE;
@@ -1006,8 +969,7 @@ unsigned pg_flags; /* flags&1: 'no it' unless neuter,
/* used for nearby monsters when you go to another level */
boolean
levl_follower(mtmp)
struct monst *mtmp;
levl_follower(struct monst* mtmp)
{
if (mtmp == u.usteed)
return TRUE;
@@ -1098,8 +1060,7 @@ static const short grownups[][2] = {
};
int
little_to_big(montype)
int montype;
little_to_big(int montype)
{
register int i;
@@ -1112,8 +1073,7 @@ int montype;
}
int
big_to_little(montype)
int montype;
big_to_little(int montype)
{
register int i;
@@ -1128,8 +1088,7 @@ int montype;
/* determine whether two permonst indices are part of the same progression;
existence of progressions with more than one step makes it a bit tricky */
boolean
big_little_match(montyp1, montyp2)
int montyp1, montyp2;
big_little_match(int montyp1, int montyp2)
{
int l, b;
@@ -1157,8 +1116,7 @@ int montyp1, montyp2;
* player. It does not return a pointer to player role character.
*/
const struct permonst *
raceptr(mtmp)
struct monst *mtmp;
raceptr(struct monst* mtmp)
{
if (mtmp == &g.youmonst && !Upolyd)
return &mons[g.urace.malenum];
@@ -1175,9 +1133,7 @@ static const char *immobile[4] = { "wiggle", "Wiggle", "pulsate", "Pulsate" };
static const char *crawl[4] = { "crawl", "Crawl", "falter", "Falter" };
const char *
locomotion(ptr, def)
const struct permonst *ptr;
const char *def;
locomotion(const struct permonst* ptr, const char* def)
{
int capitalize = (*def == highc(*def));
@@ -1192,9 +1148,7 @@ const char *def;
}
const char *
stagger(ptr, def)
const struct permonst *ptr;
const char *def;
stagger(const struct permonst* ptr, const char* def)
{
int capitalize = 2 + (*def == highc(*def));
@@ -1210,9 +1164,7 @@ const char *def;
/* return phrase describing the effect of fire attack on a type of monster */
const char *
on_fire(mptr, mattk)
struct permonst *mptr;
struct attack *mattk;
on_fire(struct permonst* mptr, struct attack* mattk)
{
const char *what;
@@ -1258,8 +1210,7 @@ struct attack *mattk;
* We're assuming all insects can smell at a distance too.
*/
boolean
olfaction(mdat)
struct permonst *mdat;
olfaction(struct permonst* mdat)
{
if (is_golem(mdat)
|| mdat->mlet == S_EYE /* spheres */