Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:1170] Ever heard of SP3?




Ever heard of SP3?

Nah, me neither.

But in any case, I worked on what I thought might be an improved server
client communication channel.  After working on it a little, however, I
realized the benefits didn't even come close to the time requirements - and
quickly aborted the process.

The one area I did make a significant improvement in is the SP3_YOU packet.
I designed it to be 4 bytes less than the current SP_YOU packet, and it
sends interesting things like tractor_lock, planet_lock, and observer_lock.

I had two main goal when writing this:
  One was to enhance observer support.  The idea was to allow observers to
  see tractor locks and planet locks.

  The other was to give the cambot recordings the ability to display
  tractors/locks in a global recording.

I have a patch that I will send out to the cow-list after this.  It will
have the necessary client-side functions to support SP3_YOU.

If I recall correctly, I got the cambot stuff working, but the observer
support isn't fully coded yet.  (It would just require activating the
structures..)


NOTE:  Please _do_not_ just apply this patch.  It does nothing by itself.
	Someone else who is interested in supporting this might find it
	interesting, but it will certainly need some reviewing before
	inclusion.

Also note, the patch will look for cambot.c along with genspkt.c, socket.c,
and packets.h.  I just temporarily moved cambot.c into ntserv/ when testing
if the patch would apply..

Note 3 - I don't even know if this compiles..


****************************  Cut Here ***************************

--- /eng/home/koconnor/Server/ntserv/genspkt.c	Fri Jul 31 16:39:36 1998
+++ genspkt.c.sp3	Sat Jan 31 15:01:55 1998
@@ -99,7 +99,11 @@
 #else
     0,						/* 60 */
 #endif
+#ifdef SP3
+    sizeof(struct you_s3_spacket),             /* SP_S3_SELF */
+#else
     0,						/* 61 */
+#endif
 };
 
 struct plyr_info_spacket clientPlayersInfo[MAXPLAYER];
@@ -126,6 +130,9 @@
 
 struct youss_spacket		clientSelfShip;
 struct you_short_spacket	clientSelfShort;
+#ifdef SP3
+struct you_s3_spacket	        clientSelf3;
+#endif SP3
 
 /* HW */
 u_char clientVPlanets[MAXPLANETS*sizeof(struct planet_s_spacket)+2 +6];
@@ -178,6 +185,181 @@
 #define UPDT_LITTLE 3
 #define UPDT_LEAST 4
 
+#ifdef SP3
+/* SP_3 Stuff */
+
+#define mask02 ((u_char) (0x03))
+#define mask03 ((u_char) (0x07))
+#define mask06 ((u_char) (0x31))
+#define mask27 ((u_char) (0xfc))
+#define mask57 ((u_char) (0xe0))
+
+#define maskxy(x,y) ((1 << (y)) - (1 << (x)))
+#define mask0x(x) ((1 << (x)) - 1)
+
+inline u_char
+getNFlags1(struct player* pl, u_char *tractor, u_char *plock)
+{
+    u_char newflags;
+
+    if (pl->p_flags & PFSHIELD)      newflags |= NF1SHIELD;
+    if (pl->p_flags & PFCLOAK)       newflags |= NF1CLOAK;
+
+    /* Handle tractor/pressor/player lock/planet lock/
+     *  orbit/dock/beam up/beam down/bomb */
+    if (pl->p_flags & PFORBIT) {
+	newflags |= NF1ORBIT;
+	*plock = pl->p_planet;
+
+	if (pl->p_flags & PFBOMB)           newflags |= NF1BOMB;
+	else if (pl->p_flags & PFBEAMDOWN)  newflags |= NF1BEAMDOWN;
+	else if (pl->p_flags & PFBEAMUP)    newflags |= NF1BEAMUP;
+    }
+    else if (pl->p_flags & PFDOCK) {
+	newflags |= NF1DOCK;
+	*plock = pl->p_playerl;
+
+	if (pl->p_flags & PFBEAMDOWN)       newflags |= NF1BEAMAWAY;
+	else if (pl->p_flags & PFBEAMUP)    newflags |= NF1BEAMHERE;
+    }
+    else {
+	if (pl->p_flags & PFPRESS) {
+	    newflags |= NF1PRESS;
+	    *tractor = pl->p_tractor;
+	}
+	else if (pl->p_flags & PFTRACT) {
+	    newflags |= NF1TRACT;
+	    *tractor = pl->p_tractor;
+	}
+
+	if (pl->p_flags & PFPLOCK) {
+	    newflags |= NF1PLOCK;
+	    *plock = pl->p_playerl;
+	}
+	else if (pl->p_flags & PFPLLOCK) {
+	    newflags |= NF1PLLOCK;
+	    *plock = pl->p_planet;
+	}
+    }
+
+    /* Set alert status bits as dead/green_alert/yellow_alert/red_alert */
+    if ( pl->p_status == PALIVE
+#ifdef OBSERVERS
+	 || pl->p_status == POBSERV
+#endif
+	) {
+	/* Set normal alert status */
+	if (pl->p_flags & PFRED)          newflags |= NF1RED;
+	else if (pl->p_flags & PFYELLOW)  newflags |= NF1YELLOW;
+	else                    	  newflags |= NF1GREEN;
+    }
+    else {
+	/* Must send whodead/whydead */
+	*tractor = pl->p_whodead;
+	*plock = pl->p_whydead & mask06;  /* mask is just for safety */
+    }
+
+    return (newflags);
+}
+
+inline u_char
+getNFlags2(struct player* pl)
+{
+    u_char newflags;
+
+    if (pl->p_flags & PFWEP)         newflags |= NF2WEP;
+    if (pl->p_flags & PFENG)         newflags |= NF2ENG;
+    if (pl->p_flags & PFREPAIR)      newflags |= NF2REPAIR;
+    if (pl->p_flags & PFSELFDEST)    newflags |= NF2SELFDEST;
+    if (pl->p_flags & PFDOCKOK)      newflags |= NF2DOCKOK;
+
+    if (pl->p_flags & (PFWAR | PFREFITTING | PFTWARP))
+	newflags |= NF2NO_CONTROL;
+
+    return (newflags);
+}
+
+int
+sndSelf3(struct you_s3_spacket* youp, struct player* pl, int howmuch)
+{
+    u_char newflags1=0, newflags2=0, newflags3=0;
+    u_char other=0, misc_p=0, moreflags=0;
+    u_char st_host;
+    struct player* PLpl = pl;
+
+#ifdef OBSERVERS
+    /* Handle observers -- This is kind of a hack, but it really helps
+     * with observers */
+    if (pl->p_flags & PFOBSERV) {
+	moreflags = NEFOBSERV;
+
+	if (pl->p_flags & PFPLOCK) {
+	    /* observing player */
+	    newflags3 = NFEOBSPLAYER | (pl->p_playerl << 2);
+
+	    /* HACK - set flags and other info from observed player */
+	    PLpl = &players[pl->p_playerl];
+	} else if (pl->p_flags & PFPLLOCK) {
+	    misc = NFEOBSPLANET | (pl->p_planet << 2);
+	} else {
+	    misc = NFEOBSNOTHING;
+	}
+    }
+#endif
+
+    /* Translate player flags to new player flags */
+    newflags1 = getNFlags1(Plpl, &misc_p, &other);
+    newflags2 = getNFlags2(Plpl);
+
+    /* Set new sticky_war + hostile field */
+    st_host = (PLpl->p_hostile & mask04) | (PLpl->p_swar << 4);
+
+    /* Encode other into armies/plyr_lock */
+    misc_p |= (other << 2) & mask57;
+    other = (PLpl->p_armies & mask04) | (other << 5);
+
+    if ( howmuch == UPDT_ALL    /* HACK - force resend of packet */
+	 || newflags1 != youp->nflags1
+	 || newflags2 != youp->nflags2
+	 || newflags3 != youp->nflags3
+	 || misc_p != youp->plyr_lock
+	 || other != youp->armies
+	 || st_host != youp->war
+	 || (pl->p_no | moreflags) != youp->pnum) {
+	youp->type = SP_S3_SELF;
+	youp->pnum = pl->p_no | moreflags;
+	youp->war = st_host;
+	youp->nflags1 = newflags1;
+	youp->nflags2 = newflags2;
+	youp->nflags3 = newflags3;
+	youp->armies = other;
+	youp->plyr_lock = misc_p;
+	sendClientPacket(youp);
+	return (TRUE);
+    }
+    return (FALSE);
+}
+
+inline void
+initBitList(u_char *BitArray, int *BitCount)
+{
+    *BitArray = 0;
+    *BitCount = 0;
+}
+
+inline void
+addBitList(u_char *BitArray, int *BitCount, u_char bits, u_char num)
+{
+    BitArray[(*BitCount >> 3)] |= ((bits & mask0x(num)) <<
+				   (*BitCount & mask02));
+    BitArray[(*BitCount >> 3)+1] = ((bits & mask0x(num)) >>
+				    (8 - (*BitCount & mask02)));
+    *BitCount += num;
+}
+
+#endif SP3
+/* end SP_3 */
+
 inline int
 sndLogin( struct plyr_login_spacket* login, struct player* pl)
 {
@@ -377,6 +559,325 @@
     return (FALSE);
 }
 
+#ifdef SP3
+int
+addV3Player( struct player_spacket *cpl, struct player *pl, int howmuch)
+/* UPDT_PL_ABS    : Absolute coordinates.	Send dir/speed/abs x/abs y
+ * UPDT_PL_TACTIC : Player on tactical.		Send dir/speed/tac x/tac y/shield
+ * UPDT_PL_GALACT : Player on galactic.		Send speed/gal x/gal y
+ * UPDT_PL_HIDDEN : Player not seen.            Tell client to not display
+ *
+ * UPDT_PL_EXPLOD : Exploded on tactical.	Send tac x/tac y
+ * UPDT_PL_TCLOAK : Tactical cloaker.		Send dir/tac x/tac y
+ * UPDT_PL_GCLOAK : Galactic cloaker.		Send inacurate gal x/gal y
+ * UPDT_PL_OUTFIT : Player at MOTD.		Tell client to not display
+ *
+ * UPDT_PL_FCLOAK : Force old galactic cloak.	Send old gal x/gal y
+ *
+ * dir is 4 bits - used for players direction
+ * speed is 4 bits - players relative speed. (relative to maxspeed)
+ * shield is 1 bit - player shield up/down
+ * abs x/y uses 12 bit coordinates.
+ * tac x/y uses 9 bit relative coordinates.  (relative to me->p_x/y)
+ * gal x/y uses 9 bit coordinates.
+ */
+
+{
+    int dx = pl->p_x / SCALE;
+    int dy = pl->p_y / SCALE;
+
+    if ( pl->p_status == POUTFIT || pl->p_status == PDEAD
+	 || pl->p_status == PFREE) {
+	if (cpl->type == PL3OUTFIT)
+	    return (FALSE);
+
+	cpl->type = PL3OUTFIT;
+	clientV3Player.motd[clientV3Player.c_motd++] = pl;
+	return (TRUE);
+    }
+
+    if (howmuch == UPDT_PL_ABS) {
+	if ( cpl->type == PL3ABS && dx == cpl->x && dy == cpl->y
+	     && pl->p_dir == cpl->dir && pl->p_speed == cpl->speed)
+	    return (FALSE);
+	cpl->type = PL3ABS;
+	cpl->dir = pl->p_dir;
+	cpl->x = dx;
+	cpl->y = dy;
+	cpl->speed = pl->p_speed;
+	clientV3Player.abs[clientV3Player.c_abs++] = pl;
+	return (TRUE);
+    }
+
+    if (howmuch == UPDT_PL_HIDDEN) {
+	if (cpl->type == PL3HIDDEN)
+	    return (FALSE);
+
+	cpl->type = PL3HIDDEN;
+	clientV3Player.hidden[clientV3Player.c_hidden++] = pl;
+	return (TRUE);
+    }
+
+    if (howmuch == UPDT_PL_TACTIC) {
+	/* Player on tactical */
+
+	if (pl->p_status == PEXPLODE) {
+	    if ( cpl->type == PL3EXPLODE
+		 && cpl->x == dx && cpl->y == dy)
+		return (FALSE);
+
+	    cpl->type = PL3EXPLODE;
+	    cpl->x = dx;
+	    cpl->y = dy;
+	    clientV3Player.explode[clientV3Player.c_explode++] = pl;
+	    return (TRUE);
+	}
+
+	if (pl->p_flags & PFCLOAK) {
+	    if ( F_noredundant && cpl->type == PL3TCLOAK
+		 && cpl->x == dx && cpl->y == dy && cpl->dir == pl->p_dir)
+		return (FALSE);
+
+	    cpl->type = PL3TCLOAK;
+	    cpl->x = dx;
+	    cpl->y = dy;
+	    cpl->dir = pl->p_dir;
+	    clientV3Player.tcloak[clientV3Player.c_tcloak++] = pl;
+	    return (TRUE);
+	}
+
+	if ( cpl->type == PL3TACTIC
+	     && cpl->x == dx && cpl->y == dy
+	     && cpl->pnum == (pl->p_flags & PFSHIELD)
+	     && cpl->speed == pl->p_speed && cpl->dir == pl->p_dir)
+	    return (FALSE);
+	cpl->type = PL3TACTIC;
+	cpl->x = dx;
+	cpl->y = dy;
+	cpl->speed = pl->p_speed;
+	cpl->dir = pl->p_dir;
+	/* Hack: encode the shield bit somewhere.. */
+	cpl->pnum = (pl->p_flags & PFSHIELD);
+	clientV3Player.tactic[clientV3Player.c_tactic++] = pl;
+	return (TRUE);
+    }
+
+    /* On Galactic */
+
+    if (pl->p_flags & PFCLOAK) {
+	if ( cpl->type == PL3GCLOAK
+	     && (repCount % efticks(9) != 0))
+	    return (FALSE);
+
+	cpl->type = PL3GCLOAK;
+	clientV3Player.gcloak[clientV3Player.c_gcloak++] = pl;
+	return (TRUE);
+    }
+
+    if ( cpl->type == PL3GALACT
+	 && ((repCount % efticks(9) != 0)
+	     || (cpl->x == dx && cpl->y == dy && cpl->speed == pl->p_speed)))
+	return (FALSE);
+
+    cpl->type = PL3GALACT;
+    cpl->x = dx;
+    cpl->y = dy;
+    cpl->speed = pl->p_speed;
+    clientV3Player.galact[clientV3Player.c_galact++] = pl;
+    return (TRUE);
+}
+
+void
+sendV3Player()
+{
+    struct player *pl;
+
+    initBitList(clientV3Player.packet.bits, &clientV3Player.bitcount);
+
+    while (clientV3Player.c_abs > 0) {
+	pl = clientV3Player.abs[--clientV3Player.c_abs];
+
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3ABS, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_no, 5);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_speed, 4);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_dir, 4);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_x/SCALE, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   (pl->p_x/SCALE) >> 8, 4);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_y/SCALE, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   (pl->p_y/SCALE) >> 8, 4);
+	/* Total: 40 bits per ship */
+    }
+
+    if (clientV3Player.c_tactical > 0) {
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3TACTIC, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   clientV3Player.c_tactical-1, 5);
+
+	while (clientV3Player.c_tactical > 0) {
+	    int dx, dy;
+	    pl = clientV3Player.tactical[--clientV3Player.c_tactical];
+
+	    /* NEW -- fix precision loss -tsh */
+	    dx = pl->p_x/SCALE - me->p_x/SCALE + WINSIDE/2;
+	    dy = pl->p_y/SCALE - me->p_y/SCALE + WINSIDE/2;
+
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_no, 5);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       (pl->p_flags & PFSHIELD) ? 1 : 0, 1);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_speed, 4);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_dir, 4);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx >> 8, 1);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy >> 8, 1);
+	}
+	/* Total: 8 + (num_ships * 32) bits */
+    }
+
+    if (clientV3Player.c_galactic > 0) {
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3GALACT, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   clientV3Player.c_galactic-1, 5);
+
+	while (clientV3Player.c_galactic > 0) {
+	    int dx, dy;
+	    pl = clientV3Player.galactic[--clientV3Player.c_galactic];
+
+	    /* NEW -- fix precision loss -tsh */
+	    dx = pl->p_x/SCALE - me->p_x/SCALE + WINSIDE/2;
+	    dy = pl->p_y/SCALE - me->p_y/SCALE + WINSIDE/2;
+
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_no, 5);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_speed, 4);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx >> 8, 1);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy >> 8, 1);
+	}
+	/* Total: 8 + (num_ships * 27) bits */
+    }
+
+    if (clientV3Player.c_gcloak > 0) {
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3GCLOAK, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   clientV3Player.c_gcloak-1, 5);
+
+	while (clientV3Player.c_gcloak > 0) {
+	    int dx, dy;
+	    pl = clientV3Player.gcloak[--clientV3Player.c_gcloak];
+
+	    /* NEW -- fix precision loss -tsh */
+	    dx = pl->p_x/SCALE - me->p_x/SCALE + WINSIDE/2;
+	    dy = pl->p_y/SCALE - me->p_y/SCALE + WINSIDE/2;
+
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       pl->p_no, 5);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dx >> 8, 1);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy, 8);
+	    addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		       dy >> 8, 1);
+	}
+	/* Total: 8 + (num_ships * 23) bits */
+    }
+
+    while (clientV3Player.c_tcloak > 0) {
+	int dx, dy;
+	pl = clientV3Player.tcloak[--clientV3Player.c_tcloak];
+
+	/* NEW -- fix precision loss -tsh */
+	dx = pl->p_x/SCALE - me->p_x/SCALE + WINSIDE/2;
+	dy = pl->p_y/SCALE - me->p_y/SCALE + WINSIDE/2;
+
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3TCLOAK, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_no, 5);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_dir, 4);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dx, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dx >> 8, 1);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dy, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dy >> 8, 1);
+	/* Total: 30 bits per ship */
+    }
+
+    while (clientV3Player.c_explode > 0) {
+	int dx, dy;
+	pl = clientV3Player.explode[--clientV3Player.c_explode];
+
+	/* NEW -- fix precision loss -tsh */
+	dx = pl->p_x/SCALE - me->p_x/SCALE + WINSIDE/2;
+	dy = pl->p_y/SCALE - me->p_y/SCALE + WINSIDE/2;
+
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3EXPLODE, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_no, 5);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dx, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dx >> 8, 1);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dy, 8);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   dy >> 8, 1);
+	/* Total: 26 bits per ship */
+    }
+
+    while (clientV3Player.c_hidden > 0) {
+	pl = clientV3Player.hidden[--clientV3Player.c_hidden];
+
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3HIDDEN, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_no, 5);
+	/* Total: 8 bits per ship */
+    }
+
+    while (clientV3Player.c_motd > 0) {
+	pl = clientV3Player.motd[--clientV3Player.c_motd];
+
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   PL3MOTD, 3);
+	addBitList(clientV3Player.packet.bits, &clientV3Player.bitcount,
+		   pl->p_no, 5);
+	/* Total: 8 bits per ship */
+    }
+}
+#endif SP3
+
 int
 updtPlayer( struct player_spacket *cpl, struct player *pl, int howmuch)
 /* UPDT_ALL   : If needed send accurate position; accurate speed. (normal)
@@ -1059,6 +1560,22 @@
 
 	sndSelfShip(&clientSelfShip, me);
 
+/* Make sure SP_S3_SELF is applicable..  This should always test true */
+#if (defined(SP3) && (MAXPLAYER <= 32) && (MAXPLANETS <= 64))
+
+	if (use_newyou && (me->p_armies < 32)) {
+	    if (!sndSelf3(&clientSelf3, me, UPDT_MOST))
+		if (again || force) {
+		    sndSelf3(&clientSelf3, me, UPDT_ALL);
+		    if (!force)	
+			/* again - sortof boolean HW,sent SP_S_YOU again */
+			again ^= 1;
+		}
+	    return;
+	}
+
+#endif
+
 	{
 	    /* Send Self using short packets */
 
--- /eng/home/koconnor/Server/ntserv/packets.h	Fri Jul 31 16:39:26 1998
+++ packets.h.sp3	Thu Feb  5 23:37:43 1998
@@ -89,6 +89,13 @@
 #define SP_S_KILLS      58      /* # of kills player have */
 #define SP_S_STATS      59      /* see SP_STATS */
 
+#ifdef SP3
+/* SP_S3_SELF */
+#define SP_S3_SELF      61      /* redefinition of SP_S_YOU */
+
+#define SP3SHORTVERSION 12
+#endif SP3
+
 /* variable length packets */
 #define VPLAYER_SIZE    4
 #define TOTAL_SPACKETS  62
@@ -802,6 +809,71 @@
 
      u_int	flags;
 };
+
+#ifdef SP3
+/* SP_S3_SELF */
+
+/* flag definitions for nflags1 */
+/* These are the most critical flags: */
+#define NF1SHIELD	   0x01
+#define NF1CLOAK	   0x02
+
+#define NF1GREEN	0x04
+#define NF1YELLOW	0x08
+#define NF1RED		(NF1GREEN | NF1YELLOW)
+#define NF1ALERTMASK	(NF1GREEN | NF1YELLOW)
+
+#define NF1TRACT	0x10		/* tractor beam activated */
+#define NF1PRESS	0x20		/* pressor beam activated */
+#define NF1PLOCK	0x40		/* Locked on a player */
+#define NF1PLLOCK	0x80		/* Locked on a planet */
+#define NF1ORBIT	(NF1TRACT | NF1PRESS)
+#define NF1DOCK		(NF1PLOCK | NF1PLLOCK)	/* docked to a starbase */
+#define NF1BEAMUP	(NF1ORBIT | NF1PLOCK)
+#define NF1BEAMDOWN	(NF1ORBIT | NF1PLLOCK)
+#define NF1BEAMAWAY	(NF1DOCK | NF1TRACT)	/* Beam up to starbase */
+#define NF1BEAMHERE	(NF1DOCK | NF1PRESS)	/* Beam down from starbase */
+#define NF1BOMB		(NF1ORBIT | NF1DOCK)
+#define NF1ORBITMASK	(NF1TRACT | NF1PRESS | NF1PLOCK | NF1PLLOCK)
+
+/* flag definitions for nflags2 */
+#define NF2WEP		0x01
+#define NF2ENG		0x02
+#define NF2REPAIR	0x04
+#define NF2SELFDEST	0x08
+#define NF2DOCKOK	0x10		/* docking permission */
+#define NF2NO_CONTROL	0x20		/* PFWAR | PFREFITTING | PFTWARP */
+
+/* flag definitions for nflags3 */
+/* This is somewhat of a hack(but it would be pad otherwise..)
+ * - if NEFOBSERV is set use nflags3 to tell client who/what is being
+ * observed */
+#define NF3OBSPLAYER	0x01
+#define NF3OBSPLANET	0x02
+#define NF3OBSNOTHING	(NFEOBSPLAYER | NFEOBSPLANET)
+#define NF3OBSMASK	(NFEOBSPLAYER | NFEOBSPLANET)
+/* nflags3 bits 3-7 used to send planet/player lock of observed "object" */
+
+/* flag definitions for extra_flags */
+#define NEFOBSERV          0x80		/* observering */
+
+struct you_s3_spacket {       /* SP_S3_SELF */
+    char       type;
+
+    u_char     pnum;		/* bits: 0-4 = player num; 5-7 = extra_flags */
+
+    u_char     nflags1;		/* player flags reorganized for compactness */
+    u_char     nflags2;
+    u_char     nflags3;
+
+    u_char     war;		/* 0-3 = hostile; 4-7 = swar */
+
+    u_char     armies;		/* 0-4 = armies */
+    u_char     plyr_lock;	/* 0-4 = tractor_lock/whodead */
+
+    /* armies 5-7 & play_num 5-7 = whydead/player_lock/planet_lock */
+};
+#endif SP3
 
 struct youss_spacket {          /* SP_S_YOU_SS */
      char       type;
--- /eng/home/koconnor/Server/ntserv/socket.c	Fri Jul 31 16:39:32 1998
+++ socket.c.sp3	Sat Jan 31 15:01:54 1998
@@ -242,6 +242,9 @@
 FAT_NODE fat_s_you;
 FAT_NODE fat_s_planet;
 FAT_NODE fat_s_kills;	/* S_P2 */
+#ifdef SP3
+FAT_NODE fat_s3_you;
+#endif
 FAT_NODE fat_s_phaser[MAXPLAYER]; 
 FAT_NODE fat_status;
 FAT_NODE fat_planet[MAXPLANETS];
@@ -449,6 +452,11 @@
 	fat_s_you.packet = (PTR) &clientSelfShort;
 	fat_s_you.pkt_size = sizeof(struct you_short_spacket);
 	fat_s_you.prev = fat_s_you.next = (FAT_NODE *) NULL;
+#ifdef SP3
+	fat_s3_you.packet = (PTR) &clientSelf3;
+	fat_s3_you.pkt_size = sizeof(struct you_new_spacket);
+	fat_s3_you.prev = fat_s3_you.next = (FAT_NODE *) NULL;
+#endif SP3
 	fat_s_planet.packet = (PTR) clientVPlanets;
 	fat_s_planet.pkt_size = 0;	/* It's dynamic */
 	fat_s_planet.prev =  fat_s_planet.next = (FAT_NODE *) NULL;
@@ -495,8 +503,8 @@
     }
 #endif
 
-    /* This moved from its mysterious location in updateMessages to here */
-    /* It checks to see if the system defaults file has changed and reopens
+    /* This moved from it's mysterious location in updateMessages to here */
+    /* It checks to see if the system defaults file has changed, and reopens
        the log files if necessary.  What this has to do with sending messages -
        I dont know. */
     update_sys_defaults();
@@ -638,6 +646,11 @@
 	case SP_S_PLANET:
         case SP_S_PHASER:       /* S_P2 */
 	case SP_S_KILLS:	/* S_P2 */
+#ifdef SP3
+	case SP_S3_SELF:
+	    /* these are semi-critical; flag as semi-critical and fall through*/
+	    issc = 1;
+#endif SP3
 	case SP_S_YOU_SS:
 	case SP_S_PLAYER:
 	case SP_S_TORP:
@@ -2385,6 +2398,11 @@
 	fat_s_kills.pkt_size = sizes[SP_S_KILLS];
 	fatp = &fat_s_kills;
 	break;
+#ifdef SP3
+    case SP_S3_SELF:
+	fatp = &fat_s3_you;
+	break;
+#endif SP3
     default:
 	ERROR(1,("Fat error: bad semi-critical type in updateFat\n"));
 	return;
@@ -2802,6 +2869,9 @@
     case SPK_VON:
 	if ( packet->version != (char)OLDSHORTVERSION
 	     && packet->version != (char)SP2SHORTVERSION
+#ifdef SP3
+	     && packet->version != (char)SHORTVERSION
+#endif SP3
 	    ) {
 	    new_warning(UNDEF,"Your SHORT Protocol Version is not right!");
 	    packet->req = SPK_VOFF;
@@ -2809,6 +2879,12 @@
 	}
 	if (!send_short) 
 	    new_warning(UNDEF,"Sending variable and short packets. "); /* sned only firsttime */
+#ifdef SP3
+	if (packet->version == (char) SHORTVERSION) {
+	    send_short = 2;
+	    use_newyou = 1;
+	} else
+#endif SP3
 	    if (packet->version == (char) SP2SHORTVERSION)
 		send_short = 2;  /* New packets are sent S_P2 */
 	    else
--- /eng/home/koconnor/Server/tools/cambot.c	Fri Jul 31 16:40:08 1998
+++ ../tools/cambot.c.sp3	Thu Feb  5 23:52:36 1998
@@ -28,7 +28,11 @@
 #define RECORDFILE "cambot.pkt"
 FILE *packetsFile;
 
+#ifdef SP3
+struct you_s3_spacket clientSelfs[MAXPLAYER];
+#else
 struct you_short_spacket clientSelfs[MAXPLAYER];
+#endif SP3
 struct youss_spacket clientSelfShips[MAXPLAYER];
 struct player cambot_me;
 struct itimerval udt;
@@ -153,7 +155,11 @@
 	struct pstatus_spacket *pstatus;
 	struct plyr_login_spacket *login;
 	struct stats_spacket *stats;
+#ifdef SP3
+	struct you_s3_spacket *self;
+#else
 	struct you_short_spacket *self;
+#endif SP3
 	struct youss_spacket *self2;
 
 	clientVKillsCount = 0;
@@ -167,7 +173,11 @@
 	     i++, pl++, cpli++, cpl++, kills++, pstatus++, login++,
 		 stats++, self++, self2++) {
 	    sndSelfShip(self2, pl);
+#ifdef SP3
+	    sndSelf3(self, pl, UPDT_MOST);
+#else
 	    sndSSelf(self, pl, UPDT_MOST);
+#endif
 	    sndLogin(login, pl);
 	    sndPlayerInfo(cpli, pl);
 	    sndKills(kills, pl);


-- 
 ------------------------------------------------------------------------
 | Kevin O'Connor                     "BTW, IMHO we need a FAQ for      |
 | koconnor@cse.buffalo.edu            'IMHO', 'FAQ', 'BTW', etc. !"    |
 ------------------------------------------------------------------------
+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com