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

@@ -123,31 +123,30 @@
*/
#include "hack.h"
static void FDECL(show_mon_or_warn, (int, int, int));
static void FDECL(display_monster, (XCHAR_P, XCHAR_P, struct monst *, int,
BOOLEAN_P));
static int FDECL(swallow_to_glyph, (int, int));
static void FDECL(display_warning, (struct monst *));
static void show_mon_or_warn(int, int, int);
static void display_monster(xchar, xchar, struct monst *, int, boolean);
static int swallow_to_glyph(int, int);
static void display_warning(struct monst *);
static int FDECL(check_pos, (int, int, int));
static int FDECL(get_bk_glyph, (XCHAR_P, XCHAR_P));
static int FDECL(tether_glyph, (int, int));
static int check_pos(int, int, int);
static int get_bk_glyph(xchar, xchar);
static int tether_glyph(int, int);
#ifdef UNBUFFERED_GLYPHINFO
static glyph_info *FDECL(glyphinfo_at, (XCHAR_P, XCHAR_P, int));
static glyph_info *glyphinfo_at(xchar, xchar, int);
#endif
/*#define WA_VERBOSE*/ /* give (x,y) locations for all "bad" spots */
#ifdef WA_VERBOSE
static boolean FDECL(more_than_one, (int, int, int, int, int));
static boolean more_than_one(int, int, int, int, int);
#endif
static int FDECL(set_twall, (int, int, int, int, int, int, int, int));
static int FDECL(set_wall, (int, int, int));
static int FDECL(set_corn, (int, int, int, int, int, int, int, int));
static int FDECL(set_crosswall, (int, int));
static void FDECL(set_seenv, (struct rm *, int, int, int, int));
static void FDECL(t_warn, (struct rm *));
static int FDECL(wall_angle, (struct rm *));
static int set_twall(int, int, int, int, int, int, int, int);
static int set_wall(int, int, int);
static int set_corn(int, int, int, int, int, int, int, int);
static int set_crosswall(int, int);
static void set_seenv(struct rm *, int, int, int, int);
static void t_warn(struct rm *);
static int wall_angle(struct rm *);
#define remember_topology(x, y) (g.lastseentyp[x][y] = levl[x][y].typ)
@@ -158,9 +157,7 @@ static int FDECL(wall_angle, (struct rm *));
* attention to and correct unexplored, lit ROOM and CORR spots.
*/
void
magic_map_background(x, y, show)
xchar x, y;
int show;
magic_map_background(xchar x, xchar y, int show)
{
int glyph = back_to_glyph(x, y); /* assumes hero can see x,y */
struct rm *lev = &levl[x][y];
@@ -208,9 +205,7 @@ int show;
* the hero can physically see the location. Update the screen if directed.
*/
void
map_background(x, y, show)
register xchar x, y;
register int show;
map_background(register xchar x, register xchar y, register int show)
{
register int glyph = back_to_glyph(x, y);
@@ -227,9 +222,7 @@ register int show;
* hero can physically see the location.
*/
void
map_trap(trap, show)
register struct trap *trap;
register int show;
map_trap(register struct trap *trap, register int show)
{
register int x = trap->tx, y = trap->ty;
register int glyph = trap_to_glyph(trap);
@@ -247,9 +240,7 @@ register int show;
* see the location of the object. Update the screen if directed.
*/
void
map_object(obj, show)
register struct obj *obj;
register int show;
map_object(register struct obj *obj, register int show)
{
register int x = obj->ox, y = obj->oy;
register int glyph = obj_to_glyph(obj, newsym_rn2);
@@ -278,8 +269,7 @@ register int show;
* by newsym() if necessary.
*/
void
map_invisible(x, y)
register xchar x, y;
map_invisible(register xchar x, register xchar y)
{
if (x != u.ux || y != u.uy) { /* don't display I at hero's location */
if (g.level.flags.hero_memory)
@@ -289,8 +279,7 @@ register xchar x, y;
}
boolean
unmap_invisible(x, y)
int x, y;
unmap_invisible(int x, int y)
{
if (isok(x,y) && glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
@@ -311,8 +300,7 @@ int x, y;
* to call newsym().
*/
void
unmap_object(x, y)
register int x, y;
unmap_object(register int x, register int y)
{
register struct trap *trap;
@@ -359,16 +347,14 @@ register int x, y;
}
void
map_location(x, y, show)
int x, y, show;
map_location(int x, int y, int show)
{
_map_location(x, y, show);
}
/* display something on monster layer; may need to fixup object layer */
static void
show_mon_or_warn(x, y, monglyph)
int x, y, monglyph;
show_mon_or_warn(int x, int y, int monglyph)
{
struct obj *o;
@@ -400,12 +386,11 @@ int x, y, monglyph;
*
*/
static void
display_monster(x, y, mon, sightflags, worm_tail)
register xchar x, y; /* display position */
register struct monst *mon; /* monster to display */
int sightflags; /* 1 if the monster is physically seen;
2 if detected using Detect_monsters */
boolean worm_tail; /* mon is actually a worm tail */
display_monster(xchar x, xchar y, /* display position */
struct monst *mon, /* monster to display */
int sightflags, /* 1 if the monster is physically seen;
2 if detected using Detect_monsters */
boolean worm_tail) /* mon is actually a worm tail */
{
boolean mon_mimic = (M_AP_TYPE(mon) != M_AP_NOTHING);
int sensed = (mon_mimic && (Protection_from_shape_changers
@@ -514,8 +499,7 @@ boolean worm_tail; /* mon is actually a worm tail */
* Do not call for worm tails.
*/
static void
display_warning(mon)
register struct monst *mon;
display_warning(struct monst *mon)
{
int x = mon->mx, y = mon->my;
int glyph;
@@ -534,8 +518,7 @@ register struct monst *mon;
}
int
warning_of(mon)
struct monst *mon;
warning_of(struct monst *mon)
{
int wl = 0, tmp = 0;
@@ -553,8 +536,7 @@ struct monst *mon;
* When hero knows what happened to location, even when blind.
*/
void
feel_newsym(x, y)
xchar x, y;
feel_newsym(xchar x, xchar y)
{
if (Blind)
feel_location(x, y);
@@ -574,8 +556,7 @@ xchar x, y;
* searching only finds one monster per turn so we must check that separately.
*/
void
feel_location(x, y)
xchar x, y;
feel_location(xchar x, xchar y)
{
struct rm *lev;
struct obj *boulder;
@@ -733,8 +714,7 @@ xchar x, y;
* Possibly put a new glyph at the given location.
*/
void
newsym(x, y)
register int x, y;
newsym(register int x, register int y)
{
struct monst *mon;
int see_it;
@@ -901,8 +881,7 @@ register int x, y;
* pulled into a platform dependent routine for fancier graphics if desired.
*/
void
shieldeff(x, y)
xchar x, y;
shieldeff(xchar x, xchar y)
{
register int i;
@@ -919,8 +898,7 @@ xchar x, y;
}
static int
tether_glyph(x, y)
int x, y;
tether_glyph(int x, int y)
{
int tdx, tdy;
tdx = u.ux - x;
@@ -965,8 +943,7 @@ static struct tmp_glyph {
} tgfirst;
void
tmp_at(x, y)
int x, y;
tmp_at(int x, int y)
{
static struct tmp_glyph *tglyph = (struct tmp_glyph *) 0;
struct tmp_glyph *tmp;
@@ -1095,9 +1072,7 @@ int x, y;
* meant to be at the location.
*/
void
flash_glyph_at(x, y, tg, rpt)
int x, y;
int tg, rpt;
flash_glyph_at(int x, int y, int tg, int rpt)
{
int i, glyph[2];
@@ -1124,8 +1099,7 @@ int tg, rpt;
* being swallowed.
*/
void
swallowed(first)
int first;
swallowed(int first)
{
static xchar lastx, lasty; /* last swallowed position */
int swallower, left_ok, rght_ok;
@@ -1188,8 +1162,7 @@ int first;
* except when in water level. Special routines exist for that.
*/
void
under_water(mode)
int mode;
under_water(int mode)
{
static xchar lastx, lasty;
static boolean dela;
@@ -1239,8 +1212,7 @@ int mode;
* Very restricted display. You can only see yourself.
*/
void
under_ground(mode)
int mode;
under_ground(int mode)
{
static boolean dela;
@@ -1281,7 +1253,7 @@ int mode;
* sit.c]
*/
void
see_monsters()
see_monsters(void)
{
register struct monst *mon;
int new_warn_obj_cnt = 0;
@@ -1318,7 +1290,7 @@ see_monsters()
* changes.
*/
void
set_mimic_blocking()
set_mimic_blocking(void)
{
register struct monst *mon;
@@ -1339,7 +1311,7 @@ set_mimic_blocking()
* + hallucinating.
*/
void
see_objects()
see_objects(void)
{
register struct obj *obj;
@@ -1358,7 +1330,7 @@ see_objects()
* Update hallucinated traps.
*/
void
see_traps()
see_traps(void)
{
struct trap *trap;
int glyph;
@@ -1387,20 +1359,20 @@ static glyph_info ginfo;
* Put the cursor on the hero. Flush all accumulated glyphs before doing it.
*/
void
curs_on_u()
curs_on_u(void)
{
flush_screen(1); /* Flush waiting glyphs & put cursor on hero */
}
int
doredraw()
doredraw(void)
{
docrt();
return 0;
}
void
docrt()
docrt(void)
{
register int x, y;
register struct rm *lev;
@@ -1455,7 +1427,7 @@ docrt()
/* for panning beyond a clipped region; resend the current map data to
the interface rather than use docrt()'s regeneration of that data */
void
redraw_map()
redraw_map(void)
{
int x, y, glyph;
glyph_info bkglyphinfo = nul_glyphinfo;
@@ -1493,7 +1465,7 @@ redraw_map()
* =======================================================
*/
void
reglyph_darkroom()
reglyph_darkroom(void)
{
xchar x, y;
@@ -1528,8 +1500,7 @@ reglyph_darkroom()
* between object piles and single objects, it doesn't mark the location
* for update. */
void
newsym_force(x, y)
register int x, y;
newsym_force(int x, int y)
{
newsym(x, y);
g.gbuf[y][x].gnew = 1;
@@ -1543,8 +1514,7 @@ register int x, y;
* Store the glyph in the 3rd screen for later flushing.
*/
void
show_glyph(x, y, glyph)
int x, y, glyph;
show_glyph(int x, int y, int glyph)
{
#ifndef UNBUFFERED_GLYPHINFO
glyph_info glyphinfo;
@@ -1669,7 +1639,7 @@ static gbuf_entry nul_gbuf = {
* Turn the 3rd screen into UNEXPLORED that needs to be refreshed.
*/
void
clear_glyph_buffer()
clear_glyph_buffer(void)
{
register int x, y;
gbuf_entry *gptr = &g.gbuf[0][0];
@@ -1704,8 +1674,7 @@ clear_glyph_buffer()
/* used by tty after menu or text popup has temporarily overwritten the map
and it has been erased so shows spaces, not necessarily S_unexplored */
void
row_refresh(start, stop, y)
int start, stop, y;
row_refresh(int start, int stop, int y)
{
register int x, glyph;
register boolean force;
@@ -1741,7 +1710,7 @@ int start, stop, y;
}
void
cls()
cls(void)
{
static boolean in_cls = 0;
@@ -1760,8 +1729,7 @@ cls()
* Synch the third screen with the display.
*/
void
flush_screen(cursor_on_u)
int cursor_on_u;
flush_screen(int cursor_on_u)
{
/* Prevent infinite loops on errors:
* flush_screen->print_glyph->impossible->pline->flush_screen
@@ -1828,8 +1796,7 @@ int cursor_on_u;
* variables.
*/
int
back_to_glyph(x, y)
xchar x, y;
back_to_glyph(xchar x, xchar y)
{
int idx;
struct rm *ptr = &(levl[x][y]);
@@ -1960,9 +1927,7 @@ xchar x, y;
* a random monster in swallowed() and don't use what_mon() here.
*/
static int
swallow_to_glyph(mnum, loc)
int mnum;
int loc;
swallow_to_glyph(int mnum, int loc)
{
if (loc < S_sw_tl || S_sw_br < loc) {
impossible("swallow_to_glyph: bad swallow location");
@@ -1985,9 +1950,7 @@ int loc;
* / S_rslant (-1, 1) or ( 1,-1)
*/
int
zapdir_to_glyph(dx, dy, beam_type)
register int dx, dy;
int beam_type;
zapdir_to_glyph(int dx, int dy, int beam_type)
{
if (beam_type >= NUM_ZAP) {
impossible("zapdir_to_glyph: illegal beam type");
@@ -2004,8 +1967,7 @@ int beam_type;
* structure, so we must check the "third screen".
*/
int
glyph_at(x, y)
xchar x, y;
glyph_at(xchar x, xchar y)
{
if (x < 0 || y < 0 || x >= COLNO || y >= ROWNO)
return cmap_to_glyph(S_room); /* XXX */
@@ -2014,9 +1976,7 @@ xchar x, y;
#ifdef UNBUFFERED_GLYPHINFO
glyph_info *
glyphinfo_at(x, y, glyph)
xchar x, y;
int glyph;
glyphinfo_at(xchar x, xchar y, int glyph)
{
map_glyphinfo(x, y, glyph, 0, &ginfo);
return &ginfo;
@@ -2037,8 +1997,7 @@ int glyph;
*/
static int
get_bk_glyph(x, y)
xchar x, y;
get_bk_glyph(xchar x, xchar y)
{
int idx, bkglyph = GLYPH_UNEXPLORED;
struct rm *lev = &levl[x][y];
@@ -2145,11 +2104,8 @@ static const int explcolors[] = {
#define GMAP_ALTARCOLOR 0x00000004
void
map_glyphinfo(x, y, glyph, mgflags, glyphinfo)
xchar x, y;
int glyph;
unsigned mgflags;
glyph_info *glyphinfo;
map_glyphinfo(xchar x, xchar y, int glyph,
unsigned mgflags, glyph_info *glyphinfo)
{
register int offset, idx;
int color = NO_COLOR;
@@ -2456,8 +2412,8 @@ glyph_info *glyphinfo;
#ifdef WA_VERBOSE
static const char *FDECL(type_to_name, (int));
static void FDECL(error4, (int, int, int, int, int, int));
static const char *type_to_name(int);
static void error4(int, int, int, int, int, int);
static int bad_count[MAX_TYPE]; /* count of positions flagged as bad */
static const char *type_names[MAX_TYPE] = {
@@ -2470,15 +2426,13 @@ static const char *type_names[MAX_TYPE] = {
};
static const char *
type_to_name(type)
int type;
type_to_name(int type)
{
return (type < 0 || type >= MAX_TYPE) ? "unknown" : type_names[type];
}
static void
error4(x, y, a, b, c, dd)
int x, y, a, b, c, dd;
error4(int x, int y, int a, int b, int c, int dd)
{
pline("set_wall_state: %s @ (%d,%d) %s%s%s%s",
type_to_name(levl[x][y].typ), x, y,
@@ -2494,8 +2448,7 @@ int x, y, a, b, c, dd;
* Things that are ambiguous: lava
*/
static int
check_pos(x, y, which)
int x, y, which;
check_pos(int x, int y, int which)
{
int type;
@@ -2511,8 +2464,7 @@ int x, y, which;
/*ARGSUSED*/
#ifdef WA_VERBOSE
static boolean
more_than_one(x, y, a, b, c)
int x, y, a, b, c;
more_than_one(int x, int y, int a, int b, int c)
{
if ((a && (b | c)) || (b && (a | c)) || (c && (a | b))) {
error4(x, y, a, b, c, 0);
@@ -2527,13 +2479,13 @@ int x, y, a, b, c;
/* Return the wall mode for a T wall. */
static int
set_twall(x0, y0, x1, y1, x2, y2, x3, y3)
set_twall(
#ifdef WA_VERBOSE
int x0, y0; /* used #if WA_VERBOSE */
int x0, int y0, /* used #if WA_VERBOSE */
#else
int x0 UNUSED, y0 UNUSED;
int x0 UNUSED, int y0 UNUSED,
#endif
int x1, y1, x2, y2, x3, y3;
int x1, int y1, int x2, int y2, int x3, int y3)
{
int wmode, is_1, is_2, is_3;
@@ -2550,8 +2502,7 @@ int x1, y1, x2, y2, x3, y3;
/* Return wall mode for a horizontal or vertical wall. */
static int
set_wall(x, y, horiz)
int x, y, horiz;
set_wall(int x, int y, int horiz)
{
int wmode, is_1, is_2;
@@ -2572,8 +2523,7 @@ int x, y, horiz;
/* Return a wall mode for a corner wall. (x4,y4) is the "inner" position. */
static int
set_corn(x1, y1, x2, y2, x3, y3, x4, y4)
int x1, y1, x2, y2, x3, y3, x4, y4;
set_corn(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
int wmode, is_1, is_2, is_3, is_4;
@@ -2601,8 +2551,7 @@ int x1, y1, x2, y2, x3, y3, x4, y4;
/* Return mode for a crosswall. */
static int
set_crosswall(x, y)
int x, y;
set_crosswall(int x, int y)
{
int wmode, is_1, is_2, is_3, is_4;
@@ -2637,7 +2586,7 @@ int x, y;
/* Called from mklev. Scan the level and set the wall modes. */
void
set_wall_state()
set_wall_state(void)
{
int x, y;
int wmode;
@@ -2724,9 +2673,8 @@ unsigned char seenv_matrix[3][3] = { { SV2, SV1, SV0 },
/* Set the seen vector of lev as if seen from (x0,y0) to (x,y). */
static void
set_seenv(lev, x0, y0, x, y)
struct rm *lev;
int x0, y0, x, y; /* from, to */
set_seenv(struct rm *lev,
int x0, int y0, int x, int y) /* from, to */
{
int dx = x - x0, dy = y0 - y;
@@ -2736,9 +2684,9 @@ int x0, y0, x, y; /* from, to */
/* Called by blackout(vault.c) when vault guard removes temporary corridor,
turning spot <x0,y0> back into stone; <x1,y1> is an adjacent spot. */
void
unset_seenv(lev, x0, y0, x1, y1)
struct rm *lev; /* &levl[x1][y1] */
int x0, y0, x1, y1; /* from, to; abs(x1-x0)==1 && abs(y0-y1)==1 */
unset_seenv(struct rm *lev, /* &levl[x1][y1] */
int x0, int y0, int x1, int y1) /* from, to; abs(x1-x0)==1
&& abs(y0-y1)==1 */
{
int dx = x1 - x0, dy = y0 - y1;
@@ -2803,8 +2751,7 @@ static const int cross_matrix[4][6] = {
/* Print out a T wall warning and all interesting info. */
static void
t_warn(lev)
struct rm *lev;
t_warn(struct rm *lev)
{
static const char warn_str[] = "wall_angle: %s: case %d: seenv = 0x%x";
const char *wname;
@@ -2836,8 +2783,7 @@ struct rm *lev;
* seen vector (SV).
*/
static int
wall_angle(lev)
struct rm *lev;
wall_angle(struct rm *lev)
{
register unsigned int seenv = lev->seenv & 0xff;
const int *row;