-/* $NetBSD: hack.track.c,v 1.5 2003/04/02 18:36:41 jsm Exp $ */
+/* $NetBSD: hack.track.c,v 1.8 2009/08/12 07:28:41 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.track.c,v 1.5 2003/04/02 18:36:41 jsm Exp $");
+__RCSID("$NetBSD: hack.track.c,v 1.8 2009/08/12 07:28:41 dholland Exp $");
#endif /* not lint */
#include "hack.h"
#define UTSZ 50
-coord utrack[UTSZ];
-int utcnt = 0;
-int utpnt = 0;
+static coord utrack[UTSZ];
+static int utcnt = 0;
+static int utpnt = 0;
void
-initrack()
+initrack(void)
{
utcnt = utpnt = 0;
}
/* add to track */
void
-settrack()
+settrack(void)
{
if (utcnt < UTSZ)
utcnt++;
}
coord *
-gettrack(x, y)
- int x, y;
+gettrack(int x, int y)
{
- int i, cnt, dist;
+ int i, cnt, distsq;
coord tc;
+
cnt = utcnt;
for (i = utpnt - 1; cnt--; i--) {
if (i == -1)
i = UTSZ - 1;
tc = utrack[i];
- dist = (x - tc.x) * (x - tc.x) + (y - tc.y) * (y - tc.y);
- if (dist < 3)
- return (dist ? &(utrack[i]) : 0);
+ distsq = (x - tc.x) * (x - tc.x) + (y - tc.y) * (y - tc.y);
+ if (distsq < 3)
+ return (distsq ? &(utrack[i]) : 0);
}
return (0);
}