Wikia

Wikihack

Source:NetHack 3.0.0/track.c

2,032pages on
this wiki
Talk0

Below is the full text to track.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/track.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /*	SCCS Id: @(#)track.c	1.4	87/08/08
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    /* track.c - version 1.0.2 */
5.    
6.    #include "hack.h"
7.    
8.    #define	UTSZ	50
9.    
10.   coord utrack[UTSZ];
11.   int utcnt = 0;
12.   int utpnt = 0;
13.   
14.   void
15.   initrack(){
16.   	utcnt = utpnt = 0;
17.   }
18.   
19.   /* add to track */
20.   void
21.   settrack(){
22.   	if(utcnt < UTSZ) utcnt++;
23.   	if(utpnt == UTSZ) utpnt = 0;
24.   	utrack[utpnt].x = u.ux;
25.   	utrack[utpnt].y = u.uy;
26.   	utpnt++;
27.   }
28.   
29.   coord *
30.   gettrack(x, y)
31.   register int x, y;
32.   {
33.   	register int i, cnt, ndist;
34.   	coord tc;
35.   	cnt = utcnt;
36.   	for(i = utpnt-1; cnt--; i--){
37.   		if(i == -1) i = UTSZ-1;
38.   		tc = utrack[i];
39.   		ndist = dist2(x,y,tc.x,tc.y);
40.   		if(ndist < 3)
41.   			return(ndist ? (coord *)&(utrack[i]) : 0);
42.   	}
43.   	return (coord *)0;
44.   }

Around Wikia's network

Random Wiki