Reformat all C files.

I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
This commit is contained in:
Sean Hunt
2015-05-09 13:43:16 -04:00
parent 167800afdf
commit 97d6fade74
270 changed files with 182649 additions and 173878 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 rect.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 rect.c $NHDT-Date: 1431192769 2015/05/09 17:32:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* NetHack 3.6 rect.c $Date: 2009/05/06 10:47:37 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)rect.c 3.5 1990/02/22 */
/* Copyright (c) 1990 by Jean-Christophe Collet */
@@ -8,18 +8,18 @@
int FDECL(get_rect_ind, (NhRect *));
STATIC_DCL boolean FDECL(intersect, (NhRect *,NhRect *,NhRect *));
STATIC_DCL boolean FDECL(intersect, (NhRect *, NhRect *, NhRect *));
/*
* In this file, we will handle the various rectangle functions we
* need for room generation.
*/
/*
* In this file, we will handle the various rectangle functions we
* need for room generation.
*/
#define MAXRECT 50
#define XLIM 4
#define YLIM 3
#define MAXRECT 50
#define XLIM 4
#define YLIM 3
static NhRect rect[MAXRECT+1];
static NhRect rect[MAXRECT + 1];
static int rect_cnt;
/*
@@ -30,10 +30,10 @@ static int rect_cnt;
void
init_rect()
{
rect_cnt = 1;
rect[0].lx = rect[0].ly = 0;
rect[0].hx = COLNO - 1;
rect[0].hy = ROWNO - 1;
rect_cnt = 1;
rect[0].lx = rect[0].ly = 0;
rect[0].hx = COLNO - 1;
rect[0].hy = ROWNO - 1;
}
/*
@@ -45,17 +45,19 @@ int
get_rect_ind(r)
NhRect *r;
{
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
lx = r->lx; ly = r->ly;
hx = r->hx; hy = r->hy;
for (i=0,rectp = &rect[0];i<rect_cnt;i++,rectp++)
if ( lx == rectp->lx && ly == rectp->ly &&
hx == rectp->hx && hy == rectp->hy)
return i;
return -1;
lx = r->lx;
ly = r->ly;
hx = r->hx;
hy = r->hy;
for (i = 0, rectp = &rect[0]; i < rect_cnt; i++, rectp++)
if (lx == rectp->lx && ly == rectp->ly && hx == rectp->hx
&& hy == rectp->hy)
return i;
return -1;
}
/*
@@ -66,17 +68,19 @@ NhRect *
get_rect(r)
NhRect *r;
{
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
register NhRect *rectp;
register int lx, ly, hx, hy;
register int i;
lx = r->lx; ly = r->ly;
hx = r->hx; hy = r->hy;
for (i=0,rectp = &rect[0];i<rect_cnt;i++,rectp++)
if ( lx >= rectp->lx && ly >= rectp->ly &&
hx <= rectp->hx && hy <= rectp->hy)
return rectp;
return 0;
lx = r->lx;
ly = r->ly;
hx = r->hx;
hy = r->hy;
for (i = 0, rectp = &rect[0]; i < rect_cnt; i++, rectp++)
if (lx >= rectp->lx && ly >= rectp->ly && hx <= rectp->hx
&& hy <= rectp->hy)
return rectp;
return 0;
}
/*
@@ -86,7 +90,7 @@ NhRect *r;
NhRect *
rnd_rect()
{
return rect_cnt > 0 ? &rect[rn2(rect_cnt)] : 0;
return rect_cnt > 0 ? &rect[rn2(rect_cnt)] : 0;
}
/*
@@ -99,18 +103,18 @@ STATIC_OVL boolean
intersect(r1, r2, r3)
NhRect *r1, *r2, *r3;
{
if (r2->lx > r1->hx || r2->ly > r1->hy ||
r2->hx < r1->lx || r2->hy < r1->ly)
return FALSE;
if (r2->lx > r1->hx || r2->ly > r1->hy || r2->hx < r1->lx
|| r2->hy < r1->ly)
return FALSE;
r3->lx = (r2->lx > r1->lx ? r2->lx : r1->lx);
r3->ly = (r2->ly > r1->ly ? r2->ly : r1->ly);
r3->hx = (r2->hx > r1->hx ? r1->hx : r2->hx);
r3->hy = (r2->hy > r1->hy ? r1->hy : r2->hy);
r3->lx = (r2->lx > r1->lx ? r2->lx : r1->lx);
r3->ly = (r2->ly > r1->ly ? r2->ly : r1->ly);
r3->hx = (r2->hx > r1->hx ? r1->hx : r2->hx);
r3->hy = (r2->hy > r1->hy ? r1->hy : r2->hy);
if (r3->lx > r3->hx || r3->ly > r3->hy)
return FALSE;
return TRUE;
if (r3->lx > r3->hx || r3->ly > r3->hy)
return FALSE;
return TRUE;
}
/*
@@ -121,11 +125,11 @@ void
remove_rect(r)
NhRect *r;
{
int ind;
int ind;
ind = get_rect_ind(r);
if ( ind >=0 )
rect[ind] = rect[--rect_cnt];
ind = get_rect_ind(r);
if (ind >= 0)
rect[ind] = rect[--rect_cnt];
}
/*
@@ -136,15 +140,16 @@ void
add_rect(r)
NhRect *r;
{
if (rect_cnt >= MAXRECT) {
if (wizard) pline("MAXRECT may be too small.");
return;
}
/* Check that this NhRect is not included in another one */
if (get_rect(r))
return;
rect[rect_cnt] = *r;
rect_cnt++;
if (rect_cnt >= MAXRECT) {
if (wizard)
pline("MAXRECT may be too small.");
return;
}
/* Check that this NhRect is not included in another one */
if (get_rect(r))
return;
rect[rect_cnt] = *r;
rect_cnt++;
}
/*
@@ -158,37 +163,39 @@ void
split_rects(r1, r2)
NhRect *r1, *r2;
{
NhRect r, old_r;
int i;
NhRect r, old_r;
int i;
old_r = *r1;
remove_rect(r1);
old_r = *r1;
remove_rect(r1);
/* Walk down since rect_cnt & rect[] will change... */
for (i=rect_cnt-1; i>=0; i--)
if (intersect(&rect[i], r2, &r))
split_rects(&rect[i], &r);
if (r2->ly - old_r.ly-1 > (old_r.hy < ROWNO - 1 ? 2*YLIM : YLIM+1)+4) {
r = old_r;
r.hy = r2->ly - 2;
add_rect(&r);
}
if (r2->lx - old_r.lx-1 > (old_r.hx < COLNO - 1 ? 2*XLIM : XLIM+1)+4) {
r = old_r;
r.hx = r2->lx - 2;
add_rect(&r);
}
if (old_r.hy - r2->hy-1 > (old_r.ly > 0 ? 2*YLIM : YLIM+1)+4) {
r = old_r;
r.ly = r2->hy + 2;
add_rect(&r);
}
if (old_r.hx - r2->hx-1 > (old_r.lx > 0 ? 2*XLIM : XLIM+1)+4) {
r = old_r;
r.lx = r2->hx + 2;
add_rect(&r);
}
/* Walk down since rect_cnt & rect[] will change... */
for (i = rect_cnt - 1; i >= 0; i--)
if (intersect(&rect[i], r2, &r))
split_rects(&rect[i], &r);
if (r2->ly - old_r.ly - 1
> (old_r.hy < ROWNO - 1 ? 2 * YLIM : YLIM + 1) + 4) {
r = old_r;
r.hy = r2->ly - 2;
add_rect(&r);
}
if (r2->lx - old_r.lx - 1
> (old_r.hx < COLNO - 1 ? 2 * XLIM : XLIM + 1) + 4) {
r = old_r;
r.hx = r2->lx - 2;
add_rect(&r);
}
if (old_r.hy - r2->hy - 1 > (old_r.ly > 0 ? 2 * YLIM : YLIM + 1) + 4) {
r = old_r;
r.ly = r2->hy + 2;
add_rect(&r);
}
if (old_r.hx - r2->hx - 1 > (old_r.lx > 0 ? 2 * XLIM : XLIM + 1) + 4) {
r = old_r;
r.lx = r2->hx + 2;
add_rect(&r);
}
}
/*rect.c*/