Blindfold removal fix
[slashemextended.git] / src / track.c
blobd8d9e71c3b034962c1cc527592ba30b0fdf184e0
1 /* SCCS Id: @(#)track.c 3.4 87/08/08 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
4 /* track.c - version 1.0.2 */
6 #include "hack.h"
8 #define UTSZ 50
10 STATIC_VAR NEARDATA int utcnt, utpnt;
11 STATIC_VAR NEARDATA coord utrack[UTSZ];
13 #ifdef OVLB
15 void
16 initrack()
18 utcnt = utpnt = 0;
21 #endif /* OVLB */
22 #ifdef OVL1
24 /* add to track */
25 void
26 settrack()
28 if(utcnt < UTSZ) utcnt++;
29 if(utpnt == UTSZ) utpnt = 0;
30 utrack[utpnt].x = u.ux;
31 utrack[utpnt].y = u.uy;
32 utpnt++;
35 #endif /* OVL1 */
36 #ifdef OVL0
38 coord *
39 gettrack(x, y)
40 register int x, y;
42 register int cnt, ndist;
43 register coord *tc;
44 cnt = utcnt;
45 for(tc = &utrack[utpnt]; cnt--; ){
46 if(tc == utrack) tc = &utrack[UTSZ-1];
47 else tc--;
48 ndist = distmin(x,y,tc->x,tc->y);
50 /* if far away, skip track entries til we're closer */
51 if(ndist > 2) {
52 ndist -= 2; /* be careful due to extra decrement at top of loop */
53 cnt -= ndist;
54 if(cnt <= 0)
55 return (coord *) 0; /* too far away, no matches possible */
56 if(tc < &utrack[ndist])
57 tc += (UTSZ-ndist);
58 else
59 tc -= ndist;
60 } else if(ndist <= 1)
61 return(ndist ? tc : 0);
63 return (coord *)0;
66 #endif /* OVL0 */
68 /*track.c*/