Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / games / hack / hack.track.c
CommitLineData
15637ed4
RG
1/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2/* hack.track.c - version 1.0.2 */
3
4#include "hack.h"
5
6#define UTSZ 50
7
8coord utrack[UTSZ];
9int utcnt = 0;
10int utpnt = 0;
11
12initrack(){
13 utcnt = utpnt = 0;
14}
15
16/* add to track */
17settrack(){
18 if(utcnt < UTSZ) utcnt++;
19 if(utpnt == UTSZ) utpnt = 0;
20 utrack[utpnt].x = u.ux;
21 utrack[utpnt].y = u.uy;
22 utpnt++;
23}
24
25coord *
26gettrack(x,y) register x,y; {
27register int i,cnt,dist;
28coord tc;
29 cnt = utcnt;
30 for(i = utpnt-1; cnt--; i--){
31 if(i == -1) i = UTSZ-1;
32 tc = utrack[i];
33 dist = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y);
34 if(dist < 3)
35 return(dist ? &(utrack[i]) : 0);
36 }
37 return(0);
38}