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:
54
src/track.c
54
src/track.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 track.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 track.c $NHDT-Date: 1431192763 2015/05/09 17:32:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
|
||||
/* NetHack 3.6 track.c $Date: 2009/05/06 10:48:00 $ $Revision: 1.5 $ */
|
||||
/* SCCS Id: @(#)track.c 3.5 87/08/08 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
#define UTSZ 50
|
||||
#define UTSZ 50
|
||||
|
||||
STATIC_VAR NEARDATA int utcnt, utpnt;
|
||||
STATIC_VAR NEARDATA coord utrack[UTSZ];
|
||||
@@ -15,18 +15,20 @@ STATIC_VAR NEARDATA coord utrack[UTSZ];
|
||||
void
|
||||
initrack()
|
||||
{
|
||||
utcnt = utpnt = 0;
|
||||
utcnt = utpnt = 0;
|
||||
}
|
||||
|
||||
/* add to track */
|
||||
void
|
||||
settrack()
|
||||
{
|
||||
if(utcnt < UTSZ) utcnt++;
|
||||
if(utpnt == UTSZ) utpnt = 0;
|
||||
utrack[utpnt].x = u.ux;
|
||||
utrack[utpnt].y = u.uy;
|
||||
utpnt++;
|
||||
if (utcnt < UTSZ)
|
||||
utcnt++;
|
||||
if (utpnt == UTSZ)
|
||||
utpnt = 0;
|
||||
utrack[utpnt].x = u.ux;
|
||||
utrack[utpnt].y = u.uy;
|
||||
utpnt++;
|
||||
}
|
||||
|
||||
coord *
|
||||
@@ -36,25 +38,27 @@ register int x, y;
|
||||
register int cnt, ndist;
|
||||
register coord *tc;
|
||||
cnt = utcnt;
|
||||
for(tc = &utrack[utpnt]; cnt--; ){
|
||||
if(tc == utrack) tc = &utrack[UTSZ-1];
|
||||
else tc--;
|
||||
ndist = distmin(x,y,tc->x,tc->y);
|
||||
for (tc = &utrack[utpnt]; cnt--;) {
|
||||
if (tc == utrack)
|
||||
tc = &utrack[UTSZ - 1];
|
||||
else
|
||||
tc--;
|
||||
ndist = distmin(x, y, tc->x, tc->y);
|
||||
|
||||
/* if far away, skip track entries til we're closer */
|
||||
if(ndist > 2) {
|
||||
ndist -= 2; /* be careful due to extra decrement at top of loop */
|
||||
cnt -= ndist;
|
||||
if(cnt <= 0)
|
||||
return (coord *) 0; /* too far away, no matches possible */
|
||||
if(tc < &utrack[ndist])
|
||||
tc += (UTSZ-ndist);
|
||||
else
|
||||
tc -= ndist;
|
||||
} else if(ndist <= 1)
|
||||
return(ndist ? tc : 0);
|
||||
/* if far away, skip track entries til we're closer */
|
||||
if (ndist > 2) {
|
||||
ndist -= 2; /* be careful due to extra decrement at top of loop */
|
||||
cnt -= ndist;
|
||||
if (cnt <= 0)
|
||||
return (coord *) 0; /* too far away, no matches possible */
|
||||
if (tc < &utrack[ndist])
|
||||
tc += (UTSZ - ndist);
|
||||
else
|
||||
tc -= ndist;
|
||||
} else if (ndist <= 1)
|
||||
return (ndist ? tc : 0);
|
||||
}
|
||||
return (coord *)0;
|
||||
return (coord *) 0;
|
||||
}
|
||||
|
||||
/*track.c*/
|
||||
|
||||
Reference in New Issue
Block a user