Vanilla Development Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS update: Vanilla/ntserv



Date:	Thursday December 30, 1999 @ 9:04
Author:	xyzzy

Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory swashbuckler.fortress.real-time.com:/var/tmp/cvs-serv7609

Modified Files:
	data.c data.h feature.c genspkt.c 
Log Message:
New feature, 19FLAGS.  This replaces the SELF_8FLAGS and short packets 2
sequence number flags with a better version.  19 player flags, which is all
but PFWAR and PFSELFDEST, are packed into the spare bytes in the self and
sequence number packets.  The old methods are used if the client doesn't
support 19FLAGS.  Flags sent with this method aren't re-sent with a flag
packet, saving a little bandwidth.


****************************************

Index: Vanilla/ntserv/data.c
diff -u Vanilla/ntserv/data.c:1.10 Vanilla/ntserv/data.c:1.11
--- Vanilla/ntserv/data.c:1.10	Mon Nov 22 17:58:58 1999
+++ Vanilla/ntserv/data.c	Thu Dec 30 09:04:39 1999
@@ -1,4 +1,4 @@
-/* $Id: data.c,v 1.10 1999/11/22 23:58:58 unbelver Exp $
+/* $Id: data.c,v 1.11 1999/12/30 15:04:39 xyzzy Exp $
  */
 
 #include "../ntserv/copyright.h"
@@ -387,4 +387,5 @@
 int F_cloak_maxwarp = 0;
 int F_rc_distress   = 0;
 int F_self_8flags   = 0;
+int F_19flags       = 0;	/* pack 19 flags into spare bytes */
 int sent_ship[NUM_TYPES];
Index: Vanilla/ntserv/data.h
diff -u Vanilla/ntserv/data.h:1.8 Vanilla/ntserv/data.h:1.9
--- Vanilla/ntserv/data.h:1.8	Mon Nov 22 17:58:58 1999
+++ Vanilla/ntserv/data.h	Thu Dec 30 09:04:39 1999
@@ -1,4 +1,4 @@
-/* $Id: data.h,v 1.8 1999/11/22 23:58:58 unbelver Exp $
+/* $Id: data.h,v 1.9 1999/12/30 15:04:39 xyzzy Exp $
  */
 
 #ifndef _h_data
@@ -318,6 +318,7 @@
 extern int F_cloak_maxwarp;
 extern int F_rc_distress;
 extern int F_self_8flags;
+extern int F_19flags;
 extern int sent_ship[];
 
 extern char Cambot[FNAMESIZE];
Index: Vanilla/ntserv/feature.c
diff -u Vanilla/ntserv/feature.c:1.5 Vanilla/ntserv/feature.c:1.6
--- Vanilla/ntserv/feature.c:1.5	Mon Nov 22 17:58:58 1999
+++ Vanilla/ntserv/feature.c	Thu Dec 30 09:04:39 1999
@@ -45,6 +45,7 @@
 #endif
    { "SBHOURS",			&SBhours },
    { "SELF_8FLAGS",		&F_self_8flags},
+   { "19FLAGS", 		&F_19flags},
    { "RC_DISTRESS",		&F_rc_distress}, /* xx */
    { "CLOAK_MAXWARP",		&F_cloak_maxwarp},
    { "SHIP_CAP",		&F_ship_cap},
Index: Vanilla/ntserv/genspkt.c
diff -u Vanilla/ntserv/genspkt.c:1.8 Vanilla/ntserv/genspkt.c:1.9
--- Vanilla/ntserv/genspkt.c:1.8	Thu Aug 19 03:50:22 1999
+++ Vanilla/ntserv/genspkt.c	Thu Dec 30 09:04:39 1999
@@ -490,9 +490,29 @@
 
 	if (f_many_self)
 	    self->pad1 = pl->p_no;
-	else
+	else if (F_19flags) {
+	    u_int f = pl->p_flags;
+	    self->pad1 = ((f&PFGREEN )?2:(f&PFYELLOW  )?1:0) +
+			 ((f&PFBEAMUP)?2:(f&PFBEAMDOWN)?1:0)*3 +
+			 ((f&PFPLOCK )?2:(f&PFPLLOCK  )?1:0)*9 +
+			 ((f&PFPRESS )?1:(f&PFTRACT   )?2:0)*27 +   /* weird */
+			 ((f&PFORBIT )?2:(f&PFDOCK    )?1:0)*81;
+	    /* since flags are sent now, note the update */
+	    f = (PFGREEN|PFYELLOW|PFRED|PFBEAMUP|PFBEAMDOWN|PFPLOCK|PFPLLOCK|
+	         PFPRESS|PFTRACT|PFORBIT|PFDOCK);
+	    if(send_short > 1 && commMode == COMM_UDP)  
+	        /* well send these in the sequence packet */
+		f |= (PFSHIELD|PFREPAIR|PFBOMB|PFCLOAK|
+		     PFWEP|PFENG|PFREFITTING|PFDOCKOK);
+	    clientSelfShort.flags = (clientSelfShort.flags & htonl(~f)) |
+				    htonl(pl->p_flags & f);
+	} else if (F_self_8flags) {
 	    /* FEATURE SELF_8FLAGS */
 	    self->pad1 = pl->p_flags & 255; /* For future use */
+	    /* since flags are sent now, note the update */
+	    clientSelfShort.flags = (clientSelfShort.flags & htonl(~0xff)) |
+				    htonl(pl->p_flags & 0xff);
+	};
 
 	self->damage=htons(pl->p_damage);
 	self->shield=htons(pl->p_shield);
@@ -2382,8 +2402,20 @@
     ssp = (struct sequence_spacket *) outbuf;
     ssp->type = SP_SEQUENCE;
     ssp->sequence = htons((u_short) *seq_no);
-    if (!f_many_self)
+    if (F_19flags) {
+	ssp->flag8 = (me->p_flags&PFSHIELD    ? 0x01 : 0) |
+	             (me->p_flags&PFREPAIR    ? 0x02 : 0) |
+	             (me->p_flags&PFBOMB      ? 0x04 : 0) |
+	             (me->p_flags&PFCLOAK     ? 0x08 : 0) |
+	             (me->p_flags&PFWEP       ? 0x10 : 0) |
+	             (me->p_flags&PFENG       ? 0x20 : 0) |
+	             (me->p_flags&PFREFITTING ? 0x40 : 0) |
+	             (me->p_flags&PFDOCKOK    ? 0x80 : 0);
+    } else if (!f_many_self) {
 	ssp->flag8 = (((unsigned int)me->p_flags >> 8) & 0xff); /* S_P2 */
+	clientSelfShort.flags = (clientSelfShort.flags & htonl(~0xff)) |
+	                        htonl(me->p_flags & 0xff);
+    }
     (*seq_no)++;
 
     return (sizeof(struct sequence_spacket));