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

@@ -9,37 +9,34 @@
/* croom->lx etc are schar (width <= int), so % arith ensures that */
/* conversion of result to int is reasonable */
static boolean FDECL(generate_stairs_room_good, (struct mkroom *, int));
static struct mkroom *NDECL(generate_stairs_find_room);
static void NDECL(generate_stairs);
static void FDECL(mkfount, (int, struct mkroom *));
static boolean FDECL(find_okay_roompos, (struct mkroom *, coord *));
static void FDECL(mksink, (struct mkroom *));
static void FDECL(mkaltar, (struct mkroom *));
static void FDECL(mkgrave, (struct mkroom *));
static void NDECL(makevtele);
void NDECL(clear_level_structures);
static void FDECL(fill_ordinary_room, (struct mkroom *));
static void NDECL(makelevel);
static boolean FDECL(bydoor, (XCHAR_P, XCHAR_P));
static struct mkroom *FDECL(find_branch_room, (coord *));
static struct mkroom *FDECL(pos_to_room, (XCHAR_P, XCHAR_P));
static boolean FDECL(place_niche, (struct mkroom *, int *, int *, int *));
static void FDECL(makeniche, (int));
static void NDECL(make_niches);
static int FDECL(CFDECLSPEC do_comp, (const genericptr,
const genericptr));
static void FDECL(dosdoor, (XCHAR_P, XCHAR_P, struct mkroom *, int));
static void FDECL(join, (int, int, BOOLEAN_P));
static void FDECL(do_room_or_subroom, (struct mkroom *, int, int,
int, int, BOOLEAN_P,
SCHAR_P, BOOLEAN_P, BOOLEAN_P));
static void NDECL(makerooms);
static boolean FDECL(door_into_nonjoined, (XCHAR_P, XCHAR_P));
static void FDECL(finddpos, (coord *, XCHAR_P, XCHAR_P,
XCHAR_P, XCHAR_P));
static void FDECL(mkinvpos, (XCHAR_P, XCHAR_P, int));
static void FDECL(mk_knox_portal, (XCHAR_P, XCHAR_P));
static boolean generate_stairs_room_good(struct mkroom *, int);
static struct mkroom *generate_stairs_find_room(void);
static void generate_stairs(void);
static void mkfount(int, struct mkroom *);
static boolean find_okay_roompos(struct mkroom *, coord *);
static void mksink(struct mkroom *);
static void mkaltar(struct mkroom *);
static void mkgrave(struct mkroom *);
static void makevtele(void);
void clear_level_structures(void);
static void fill_ordinary_room(struct mkroom *);
static void makelevel(void);
static boolean bydoor(xchar, xchar);
static struct mkroom *find_branch_room(coord *);
static struct mkroom *pos_to_room(xchar, xchar);
static boolean place_niche(struct mkroom *, int *, int *, int *);
static void makeniche(int);
static void make_niches(void);
static int CFDECLSPEC do_comp(const genericptr, const genericptr);
static void dosdoor(xchar, xchar, struct mkroom *, int);
static void join(int, int, boolean);
static void do_room_or_subroom(struct mkroom *, int, int, int, int, boolean,
schar, boolean, boolean);
static void makerooms(void);
static boolean door_into_nonjoined(xchar, xchar);
static void finddpos(coord *, xchar, xchar, xchar, xchar);
static void mkinvpos(xchar, xchar, int);
static void mk_knox_portal(xchar, xchar);
#define create_vault() create_room(-1, -1, 2, 2, -1, -1, VAULT, TRUE)
#define init_vault() g.vault_x = -1
@@ -48,9 +45,7 @@ static void FDECL(mk_knox_portal, (XCHAR_P, XCHAR_P));
/* Args must be (const genericptr) so that qsort will always be happy. */
static int CFDECLSPEC
do_comp(vx, vy)
const genericptr vx;
const genericptr vy;
do_comp(const genericptr vx, const genericptr vy)
{
#ifdef LINT
/* lint complains about possible pointer alignment problems, but we know
@@ -76,8 +71,7 @@ const genericptr vy;
* connect them up to other areas.
*/
static boolean
door_into_nonjoined(x, y)
xchar x, y;
door_into_nonjoined(xchar x, xchar y)
{
xchar tx, ty, diridx;
@@ -97,9 +91,7 @@ xchar x, y;
}
static void
finddpos(cc, xl, yl, xh, yh)
coord *cc;
xchar xl, yl, xh, yh;
finddpos(coord *cc, xchar xl, xchar yl, xchar xh, xchar yh)
{
register xchar x, y;
@@ -131,7 +123,7 @@ xchar xl, yl, xh, yh;
/* Sort rooms on the level so they're ordered from left to right on the map.
makecorridors() by default links rooms N and N+1 */
void
sort_rooms()
sort_rooms(void)
{
int i, x, y;
int ri[MAXNROFROOMS+1];
@@ -157,14 +149,9 @@ sort_rooms()
}
static void
do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, is_room)
register struct mkroom *croom;
int lowx, lowy;
register int hix, hiy;
boolean lit;
schar rtype;
boolean special;
boolean is_room;
do_room_or_subroom(register struct mkroom *croom,
int lowx, int lowy, register int hix, register int hiy,
boolean lit, schar rtype, boolean special, boolean is_room)
{
register int x, y;
struct rm *lev;
@@ -235,11 +222,8 @@ boolean is_room;
}
void
add_room(lowx, lowy, hix, hiy, lit, rtype, special)
int lowx, lowy, hix, hiy;
boolean lit;
schar rtype;
boolean special;
add_room(int lowx, int lowy, int hix, int hiy,
boolean lit, schar rtype, boolean special)
{
register struct mkroom *croom;
@@ -252,12 +236,8 @@ boolean special;
}
void
add_subroom(proom, lowx, lowy, hix, hiy, lit, rtype, special)
struct mkroom *proom;
int lowx, lowy, hix, hiy;
boolean lit;
schar rtype;
boolean special;
add_subroom(struct mkroom *proom, int lowx, int lowy, int hix, int hiy,
boolean lit, schar rtype, boolean special)
{
register struct mkroom *croom;
@@ -271,8 +251,7 @@ boolean special;
}
void
free_luathemes(keependgame)
boolean keependgame; /* False: exiting, True: discarding main dungeon */
free_luathemes(boolean keependgame) /* False: exiting, True: discarding main dungeon */
{
int i;
@@ -287,7 +266,7 @@ boolean keependgame; /* False: exiting, True: discarding main dungeon */
}
static void
makerooms()
makerooms(void)
{
boolean tried_vault = FALSE;
int themeroom_tries = 0;
@@ -348,9 +327,7 @@ makerooms()
}
static void
join(a, b, nxcor)
register int a, b;
boolean nxcor;
join(register int a, register int b, boolean nxcor)
{
coord cc, tt, org, dest;
register xchar tx, ty, xx, yy;
@@ -426,7 +403,7 @@ boolean nxcor;
}
void
makecorridors()
makecorridors(void)
{
int a, b, i;
boolean any = TRUE;
@@ -458,9 +435,7 @@ makecorridors()
}
void
add_door(x, y, aroom)
register int x, y;
register struct mkroom *aroom;
add_door(register int x, register int y, register struct mkroom *aroom)
{
register struct mkroom *broom;
register int tmp;
@@ -499,10 +474,7 @@ register struct mkroom *aroom;
}
static void
dosdoor(x, y, aroom, type)
register xchar x, y;
struct mkroom *aroom;
int type;
dosdoor(register xchar x, register xchar y, struct mkroom *aroom, int type)
{
boolean shdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE;
@@ -566,9 +538,7 @@ int type;
}
static boolean
place_niche(aroom, dy, xx, yy)
register struct mkroom *aroom;
int *dy, *xx, *yy;
place_niche(register struct mkroom *aroom, int *dy, int *xx, int *yy)
{
coord dd;
@@ -599,8 +569,7 @@ static NEARDATA const char *trap_engravings[TRAPNUM] = {
};
static void
makeniche(trap_type)
int trap_type;
makeniche(int trap_type)
{
register struct mkroom *aroom;
struct rm *rm;
@@ -664,7 +633,7 @@ int trap_type;
}
static void
make_niches()
make_niches(void)
{
int ct = rnd((g.nroom >> 1) + 1), dep = depth(&u.uz);
boolean ltptr = (!g.level.flags.noteleport && dep > 15),
@@ -683,7 +652,7 @@ make_niches()
}
static void
makevtele()
makevtele(void)
{
makeniche(TELEP_TRAP);
}
@@ -694,7 +663,7 @@ makevtele()
* each type initializes what it needs to separately.
*/
void
clear_level_structures()
clear_level_structures(void)
{
static struct rm zerorm = { GLYPH_UNEXPLORED,
0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -766,8 +735,7 @@ clear_level_structures()
* Doom) with random monsters, objects, and dungeon features.
*/
static void
fill_ordinary_room(croom)
struct mkroom *croom;
fill_ordinary_room(struct mkroom *croom)
{
int trycnt = 0;
coord pos;
@@ -867,7 +835,7 @@ struct mkroom *croom;
}
static void
makelevel()
makelevel(void)
{
register struct mkroom *croom;
branch *branchp;
@@ -1007,9 +975,8 @@ makelevel()
* mineralize(-1, -1, -1, -1, FALSE); => "default" behaviour
*/
void
mineralize(kelp_pool, kelp_moat, goldprob, gemprob, skip_lvl_checks)
int kelp_pool, kelp_moat, goldprob, gemprob;
boolean skip_lvl_checks;
mineralize(int kelp_pool, int kelp_moat, int goldprob, int gemprob,
boolean skip_lvl_checks)
{
s_level *sp;
struct obj *otmp;
@@ -1103,7 +1070,7 @@ boolean skip_lvl_checks;
}
void
mklev()
mklev(void)
{
struct mkroom *croom;
int ridx;
@@ -1145,12 +1112,9 @@ mklev()
void
#ifdef SPECIALIZATION
topologize(croom, do_ordinary)
struct mkroom *croom;
boolean do_ordinary;
topologize(struct mkroom *croom, boolean do_ordinary)
#else
topologize(croom)
struct mkroom *croom;
topologize(struct mkroom *croom)
#endif
{
register int x, y, roomno = (int) ((croom - g.rooms) + ROOMOFFSET);
@@ -1210,8 +1174,7 @@ struct mkroom *croom;
/* Find an unused room for a branch location. */
static struct mkroom *
find_branch_room(mp)
coord *mp;
find_branch_room(coord *mp)
{
struct mkroom *croom = 0;
@@ -1228,8 +1191,7 @@ coord *mp;
/* Find the room for (x,y). Return null if not in a room. */
static struct mkroom *
pos_to_room(x, y)
xchar x, y;
pos_to_room(xchar x, xchar y)
{
int i;
struct mkroom *curr;
@@ -1243,9 +1205,8 @@ xchar x, y;
/* If given a branch, randomly place a special stair or portal. */
void
place_branch(br, x, y)
branch *br; /* branch to place */
xchar x, y; /* location */
place_branch(branch *br, /* branch to place */
xchar x, xchar y) /* location */
{
coord m = {0};
d_level *dest;
@@ -1301,8 +1262,7 @@ xchar x, y; /* location */
}
static boolean
bydoor(x, y)
register xchar x, y;
bydoor(register xchar x, register xchar y)
{
register int typ;
@@ -1331,8 +1291,7 @@ register xchar x, y;
/* see whether it is allowable to create a door at [x,y] */
int
okdoor(x, y)
xchar x, y;
okdoor(xchar x, xchar y)
{
boolean near_door = bydoor(x, y);
@@ -1345,9 +1304,7 @@ xchar x, y;
}
void
dodoor(x, y, aroom)
int x, y;
struct mkroom *aroom;
dodoor(int x, int y, struct mkroom *aroom)
{
if (g.doorindex >= DOORMAX) {
impossible("DOORMAX exceeded?");
@@ -1358,8 +1315,7 @@ struct mkroom *aroom;
}
boolean
occupied(x, y)
register xchar x, y;
occupied(register xchar x, register xchar y)
{
return (boolean) (t_at(x, y) || IS_FURNITURE(levl[x][y].typ)
|| is_lava(x, y) || is_pool(x, y)
@@ -1369,10 +1325,7 @@ register xchar x, y;
/* make a trap somewhere (in croom if mazeflag = 0 && !tm) */
/* if tm != null, make trap at that location */
void
mktrap(num, mazeflag, croom, tm)
int num, mazeflag;
struct mkroom *croom;
coord *tm;
mktrap(int num, int mazeflag, struct mkroom *croom, coord *tm)
{
register int kind;
struct trap *t;
@@ -1632,10 +1585,9 @@ coord *tm;
}
void
mkstairs(x, y, up, croom)
xchar x, y;
char up; /* [why 'char' when usage is boolean?] */
struct mkroom *croom UNUSED;
mkstairs(xchar x, xchar y,
char up, /* [why 'char' when usage is boolean?] */
struct mkroom *croom UNUSED)
{
d_level dest;
@@ -1669,9 +1621,7 @@ struct mkroom *croom UNUSED;
-1 == allow an unjoined room
*/
static boolean
generate_stairs_room_good(croom, phase)
struct mkroom *croom;
int phase;
generate_stairs_room_good(struct mkroom *croom, int phase)
{
return (croom && (croom->needjoining || (phase < 0))
&& ((!has_dnstairs(croom) && !has_upstairs(croom))
@@ -1682,7 +1632,7 @@ int phase;
/* find a good room to generate an up or down stairs in */
static struct mkroom *
generate_stairs_find_room()
generate_stairs_find_room(void)
{
struct mkroom *croom;
int i, phase, tryct = 0;
@@ -1713,7 +1663,7 @@ generate_stairs_find_room()
/* construct stairs up and down within the same branch,
up and down in different rooms if possible */
static void
generate_stairs()
generate_stairs(void)
{
struct mkroom *croom = generate_stairs_find_room();
coord pos;
@@ -1739,9 +1689,7 @@ generate_stairs()
}
static void
mkfount(mazeflag, croom)
int mazeflag;
struct mkroom *croom;
mkfount(int mazeflag, struct mkroom *croom)
{
coord m;
register int tryct = 0;
@@ -1765,9 +1713,7 @@ struct mkroom *croom;
}
static boolean
find_okay_roompos(croom, crd)
struct mkroom *croom;
coord *crd;
find_okay_roompos(struct mkroom *croom, coord *crd)
{
int tryct = 0;
@@ -1781,8 +1727,7 @@ coord *crd;
}
static void
mksink(croom)
struct mkroom *croom;
mksink(struct mkroom *croom)
{
coord m;
@@ -1796,8 +1741,7 @@ struct mkroom *croom;
}
static void
mkaltar(croom)
struct mkroom *croom;
mkaltar(struct mkroom *croom)
{
coord m;
aligntyp al;
@@ -1817,8 +1761,7 @@ struct mkroom *croom;
}
static void
mkgrave(croom)
struct mkroom *croom;
mkgrave(struct mkroom *croom)
{
coord m;
register int tryct = 0;
@@ -1879,7 +1822,7 @@ struct mkroom *croom;
* attempted while blind (in order to make blind-from-birth conduct viable).]
*/
void
mkinvokearea()
mkinvokearea(void)
{
int dist;
xchar xmin = g.inv_pos.x, xmax = g.inv_pos.x,
@@ -1938,9 +1881,7 @@ mkinvokearea()
* Temporarily overrides vision in the name of a nice effect.
*/
static void
mkinvpos(x, y, dist)
xchar x, y;
int dist;
mkinvpos(xchar x, xchar y, int dist)
{
struct trap *ttmp;
struct obj *otmp;
@@ -2035,8 +1976,7 @@ int dist;
* Ludios will remain isolated until the branch is corrected by this function.
*/
static void
mk_knox_portal(x, y)
xchar x, y;
mk_knox_portal(xchar x, xchar y)
{
d_level *source;
branch *br;