games: Massive style(9) cleanup commit. Reduces differences to NetBSD.
[dragonfly.git] / games / hack / hack.track.c
blob76a398a521292d20dd25dd8ccfeb786651fb4fbc
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)
25 utcnt++;
26 if (utpnt == UTSZ)
27 utpnt = 0;
28 utrack[utpnt].x = u.ux;
29 utrack[utpnt].y = u.uy;
30 utpnt++;
33 coord *
34 gettrack(int x, int y)
36 int i, cnt, dst;
37 coord tc;
39 cnt = utcnt;
40 for (i = utpnt - 1; cnt--; i--) {
41 if (i == -1)
42 i = UTSZ - 1;
43 tc = utrack[i];
44 dst = (x - tc.x) * (x - tc.x) + (y - tc.y) * (y - tc.y);
45 if (dst < 3)
46 return (dst ? &(utrack[i]) : 0);
48 return (0);