From: fadden@uts.amdahl.com (Andy McFadden)
Newsgroups: rec.games.netrek
Subject: Re: Something seriously amiss
Date: 16 Oct 92 19:21:07 GMT
Organization: Amdahl Corporation, Sunnyvale CA

In article <1992Oct14.194445.23312@colorado.edu> sherod@newton.Colorado.EDU (Scott Herod) writes:
>The binaries from sgi.com for Irises have visable tractors but
>they always point to the point (0,0). 

This is what happens when the server deity turns the beams off.  The UDP
client code (and the visible beam code I wrote & distributed) should handle
this by automatically deactivating the beams.  Hmm, come to think of it, I
don't think the very first version I distributed did.

Just for fun, here's the code I use now.  Note that you can display little
'T' and 'P' icons whether or not the server supports the beams, but I
explicitly turn even those off.  This should work with any server using
the UDP ntserv/socket.c.

	/* ATM - visible tractor/pressor beams */
	/* (for the standard client, I am allowing them for self ONLY) */
	/* Since this is NOT a cyborg, I don't show anything if the server */
	/* doesn't allow it. */
	if (vissup >= 0 && j == me && isAlive(j) &&
					(j->p_flags & (PFTRACT|PFPRESS))) {
	    /* this keeps us from trying to show them on servers which */
	    /* don't support visible tractor beams */
	    if (j->p_tractor < 0) {
		vissup = -1;
		goto notsup;
	    } else
		vissup = 1;

	    if (!showTractor) {
		/* don't use visible beams; use icons instead */
		if (j->p_flags & PFPRESS)
                    W_WriteBitmap(dx - (shield_width/2) - 5,
                        dy + (shield_height/2) + 5, pressbits, playerColor(j));
                else
                    W_WriteBitmap(dx - (shield_width/2) - 5,
                        dy + (shield_height/2) + 5, tractbits, playerColor(j));
                clearzone[0][clearcount] = dx - (shield_width/2) - 5;
                clearzone[1][clearcount] = dy + (shield_height/2) + 5;
                clearzone[2][clearcount] = 5;
                clearzone[3][clearcount] = 5;
                clearcount++;

	    } else {
		/* use visible beams */
		double theta;
		unsigned char dir;
		int lx[2], ly[2];

		tx = (players[j->p_tractor].p_x - me->p_x) / SCALE + WINSIDE/2;
		ty = (players[j->p_tractor].p_y - me->p_y) / SCALE + WINSIDE/2;

		if (tx == dx && ty == dy)
		    continue;	/* this had better be last in for(..) */

#define XPI	3.1415926
		theta = atan2((double) (tx - dx), (double) (dy - ty)) + XPI / 2.0;
		dir = (unsigned char) (theta / XPI * 128.0);

		lx[0] = tx + (Cos[dir] * (shield_width/2));
		ly[0] = ty + (Sin[dir] * (shield_width/2));
		lx[1] = tx - (Cos[dir] * (shield_width/2));
		ly[1] = ty - (Sin[dir] * (shield_width/2));
#undef XPI
		W_MakeLine(w, dx, dy, lx[0], ly[0], foreColor);
		W_MakeLine(w, dx, dy, lx[1], ly[1], foreColor);

		clearline[0][clearlcount] = dx;
		clearline[1][clearlcount] = dy;
		clearline[2][clearlcount] = lx[0];
		clearline[3][clearlcount] = ly[0];
		clearlcount++;
		clearline[0][clearlcount] = dx;
		clearline[1][clearlcount] = dy;
		clearline[2][clearlcount] = lx[1];
		clearline[3][clearlcount] = ly[1];
		clearlcount++;
	    }
	}
notsup:	j = j;		/* lame compiler */
    }

-- 
fadden@uts.amdahl.com (Andy McFadden)
[ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]
Newsgroups: rec.games.netrek