Break long commits. Don't ask for transfers when there's nothing to
[dragonfly/netmp.git] / games / hack / hack.track.c
blob0aead5e4e849d19a714ea7b263e678ffa3d7d74d
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.track.c - version 1.0.2 */
3 /* $FreeBSD: src/games/hack/hack.track.c,v 1.4 1999/11/16 10:26:38 marcel Exp $ */
4 /* $DragonFly: src/games/hack/hack.track.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
6 #include "hack.h"
8 #define UTSZ 50
10 coord utrack[UTSZ];
11 int utcnt = 0;
12 int utpnt = 0;
14 initrack(){
15 utcnt = utpnt = 0;
18 /* add to track */
19 settrack(){
20 if(utcnt < UTSZ) utcnt++;
21 if(utpnt == UTSZ) utpnt = 0;
22 utrack[utpnt].x = u.ux;
23 utrack[utpnt].y = u.uy;
24 utpnt++;
27 coord *
28 gettrack(x,y) int x,y; {
29 int i,cnt,dist;
30 coord tc;
31 cnt = utcnt;
32 for(i = utpnt-1; cnt--; i--){
33 if(i == -1) i = UTSZ-1;
34 tc = utrack[i];
35 dist = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y);
36 if(dist < 3)
37 return(dist ? &(utrack[i]) : 0);
39 return(0);