MFC: Make apps using '#define _POSIX_C_SOURCE' compile.
[dragonfly.git] / games / hack / hack.track.c
blobba09139447ed3d7ea888d2cea67c252bd25b9e1e
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.3 2006/08/21 19:45:32 pavalos Exp $ */
6 #include "hack.h"
8 #define UTSZ 50
10 coord utrack[UTSZ];
11 int utcnt = 0;
12 int utpnt = 0;
14 void
15 initrack(void)
17 utcnt = utpnt = 0;
20 /* add to track */
21 void
22 settrack(void)
24 if(utcnt < UTSZ) utcnt++;
25 if(utpnt == UTSZ) utpnt = 0;
26 utrack[utpnt].x = u.ux;
27 utrack[utpnt].y = u.uy;
28 utpnt++;
31 coord *
32 gettrack(int x, int y)
34 int i,cnt,dst;
35 coord tc;
36 cnt = utcnt;
37 for(i = utpnt-1; cnt--; i--){
38 if(i == -1) i = UTSZ-1;
39 tc = utrack[i];
40 dst = (x-tc.x)*(x-tc.x) + (y-tc.y)*(y-tc.y);
41 if(dst < 3)
42 return(dst ? &(utrack[i]) : 0);
44 return(0);