Annotation of 43BSDTahoe/games/hack/hack.track.c, revision 1.1

1.1     ! root        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: 
        !             8: coord utrack[UTSZ];
        !             9: int utcnt = 0;
        !            10: int utpnt = 0;
        !            11: 
        !            12: initrack(){
        !            13:        utcnt = utpnt = 0;
        !            14: }
        !            15: 
        !            16: /* add to track */
        !            17: settrack(){
        !            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: 
        !            25: coord *
        !            26: gettrack(x,y) register x,y; {
        !            27: register int i,cnt,dist;
        !            28: coord 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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.