Update of /cvsroot/netrek/client/netrekxp/src
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6576/src

Modified Files:
	data.c feature.c socket.c 
Log Message:
Next pass at generic_32 version b support.
Known issues: can't find win32 equivalent for attribute packing,
feature packet arg1 of /002 is causing pointer error to arg2

Index: feature.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/feature.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- feature.c	19 Apr 2008 20:03:01 -0000	1.22
+++ feature.c	12 Jul 2008 12:09:37 -0000	1.23
@@ -76,7 +76,7 @@
     {"SELF_8FLAGS2", &F_self_8flags2, 'S', 0, 0, 0},
     {"19FLAGS", &F_self_19flags, 'S', 1, 0, 0},
     {"SHIP_CAP", &F_ship_cap, 'S', 1, 0, 0},
-    {"SP_GENERIC_32", &F_sp_generic_32, 'S', 1, 0, 0},
+    {"SP_GENERIC_32", &F_sp_generic_32, 'S', 1, "\002", 0},
     {"FULL_DIRECTION_RESOLUTION", &F_full_direction_resolution, 'S', 1, 0, 0},
     {"FULL_WEAPON_RESOLUTION", &F_full_weapon_resolution, 'S', 1, 0, 0},
     {"CHECK_PLANETS", &F_check_planets, 'S', 1, 0, 0},
@@ -117,11 +117,15 @@
 {
     struct feature *f;
     int value;
+    char arg1, arg2;
 
     for (f = features; f->name != 0; f++)
     {
         if (strcmpi (f->name, "FEATURE_PACKETS") != 0)
         {
+            value = f->value;
+            arg1 = (f->arg1 ? *f->arg1 : 0);
+            arg2 = (f->arg2 ? *f->arg2 : 0);
             if (!strcmp(f->name, "CHECK_PLANETS"))
                 value = useCheckPlanets;
             else if (!strcmp(f->name, "FULL_DIRECTION_RESOLUTION"))
@@ -130,16 +134,10 @@
                 value = useFullWeapInfo;
             else if (!strcmp(f->name, "SP_GENERIC_32"))
                 value = useGeneric32;
-            else
-                value = f->value;
-            sendFeature (f->name,
-                         f->feature_type,
-                         value,
-                         (char) (f->arg1 ? *f->arg1 : 0),
-                         (char) (f->arg2 ? *f->arg2 : 0));
-
+            sendFeature (f->name, f->feature_type, value, arg1, arg2);
 #ifdef DEBUG
-            LineToConsole ("(C->S) %s (%c): %d\n", f->name, f->feature_type, value);
+            LineToConsole ("(C->S) %s (%c): %d (%d/%d)\n", f->name,
+                           f->feature_type, value, arg1, arg2);
 #endif
         }
     }
@@ -164,8 +162,9 @@
     }
 #endif
 
-    sprintf (buf, "%s: %s(%d)", &packet->name[0],
-             ((value == 1) ? "ON" : (value == 0) ? "OFF" : "UNKNOWN"), value);
+    sprintf (buf, "%s: %s(%d) (%d/%d)", &packet->name[0],
+             ((value == 1) ? "ON" : (value == 0) ? "OFF" : "UNKNOWN"), value,
+             packet->arg1, packet->arg2);
 
 #ifdef TOOLS
     W_WriteText (toolsWin, 0, 0, textColor, buf, strlen (buf), W_RegularFont);
@@ -213,7 +212,11 @@
         lame_base_refit = value;
         return;
     }
-   
+    if (strcmpi (packet->name, "SP_GENERIC_32") == 0)
+    {
+        generic_32_version = packet->arg1;
+        return;
+    }
     if (features[i].name == 0)
     {
         LineToConsole ("Feature %s from server unknown to client!\n", packet->name);

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- socket.c	12 Jul 2008 03:49:45 -0000	1.48
+++ socket.c	12 Jul 2008 12:09:37 -0000	1.49
@@ -922,7 +922,7 @@
         if (paradise)
 	    size = sizeof(struct motd_pic_spacket);
         else
-	    size = sizeof(struct generic_32_spacket);
+	    size = GENERIC_32_LENGTH;
 	break;
     case SP_STATS2:
     //case SP_FLAGS_ALL:
@@ -2818,28 +2818,47 @@
 #endif
     	return;
     }
-    if (packet->version < 'a')
-        return;
-    else if (packet->version == 'a')
+    return;
+}
+
+void
+handleGeneric32_a (struct generic_32_spacket_a *packet)
+{
+
+    if (sizeof(struct generic_32_spacket) != GENERIC_32_LENGTH)
     {
-        me->p_repair_time = packet->repair_time;
-        me->pl_orbit = packet->pl_orbit;
-        return;
+#ifdef DEBUG
+    	LineToConsole("Generic32 packet length of %d, ignoring packet.\n", sizeof(struct generic_32_spacket));
+#endif
+    	return;
     }
-    else if (packet->version == 'b') 
+    me->p_repair_time = packet->repair_time;
+    me->pl_orbit = packet->pl_orbit;
+    return;
+}
+
+void
+handleGeneric32_b (struct generic_32_spacket_b *packet)
+{
+
+    if (sizeof(struct generic_32_spacket) != GENERIC_32_LENGTH)
     {
-        me->p_repair_time = ntohs (packet->repair_time);
-        me->pl_orbit = packet->pl_orbit;
-        context->gameup = ntohs(packet->gameup);
-        context->tournament_teams = packet->tournament_teams;
-        context->tournament_age = packet->tournament_age;
-        context->tournament_age_units = packet->tournament_age_units;
-        context->tournament_remain = packet->tournament_remain;
-        context->tournament_remain_units = packet->tournament_remain_units;
-        context->starbase_remain = packet->starbase_remain;
-        context->team_remain = packet->team_remain;
-        return;
+#ifdef DEBUG
+    	LineToConsole("Generic32 packet length of %d, ignoring packet.\n", sizeof(struct generic_32_spacket));
+#endif
+    	return;
     }
+    me->p_repair_time = ntohs (packet->repair_time);
+    me->pl_orbit = packet->pl_orbit;
+    context->gameup = ntohs(packet->gameup);
+    context->tournament_teams = packet->tournament_teams;
+    context->tournament_age = packet->tournament_age;
+    context->tournament_age_units = packet->tournament_age_units;
+    context->tournament_remain = packet->tournament_remain;
+    context->tournament_remain_units = packet->tournament_remain_units;
+    context->starbase_remain = packet->starbase_remain;
+    context->team_remain = packet->team_remain;
+    return;
 }
 
 void
@@ -2986,7 +3005,14 @@
     if (paradise)
         handleMotdPic ((struct motd_pic_spacket *) sbuf);
     else
-        handleGeneric32 ((struct generic_32_spacket *) sbuf);
+    {
+    	if (generic_32_version == 'a')
+    	    handleGeneric32_a ((struct generic_32_spacket_a *) sbuf);
+    	else if (generic_32_version == 'b')
+    	    handleGeneric32_b ((struct generic_32_spacket_b *) sbuf);
+    	else
+            handleGeneric32 ((struct generic_32_spacket *) sbuf);
+    }
     return;
 }
 void handlePacket33 (unsigned char *sbuf)
@@ -5086,10 +5112,29 @@
 	{
 	  LineToConsole("\nS->C SP_GENERIC_32\t");
 	  if (log_packets > 1)
-	    LineToConsole("  version=%d, repair_time=%d, pl_orbit=%d,",
-		   ((struct generic_32_spacket *) packet)->version,
-		   ntohs(((struct generic_32_spacket *) packet)->repair_time),
-		   ntohs(((struct generic_32_spacket *) packet)->pl_orbit) );
+	  {
+	    if (generic_32_version == 'a')
+	      LineToConsole("  version=%d, repair_time=%d, pl_orbit=%d,",
+		     ((struct generic_32_spacket_a *) packet)->version,
+		     ((struct generic_32_spacket_a *) packet)->repair_time,
+		     ((struct generic_32_spacket_a *) packet)->pl_orbit);
+	    else if (generic_32_version == 'b')
+	      LineToConsole("  version=%d, repair_time=%d, pl_orbit=%d, gameup=%d, tourn_teams=%d, tourn_age=%d, tourn_age_units=%d, tourn_remain=%d, tourn_remain_units=%d, starbase_remain=%d, team_remain=%d,",
+		     ((struct generic_32_spacket_b *) packet)->version,
+		     ntohs(((struct generic_32_spacket_b *) packet)->repair_time),
+		     ((struct generic_32_spacket_b *) packet)->pl_orbit,
+		     ((struct generic_32_spacket_b *) packet)->gameup,
+		     ((struct generic_32_spacket_b *) packet)->tournament_teams,
+		     ((struct generic_32_spacket_b *) packet)->tournament_age,
+		     ((struct generic_32_spacket_b *) packet)->tournament_age_units,
+		     ((struct generic_32_spacket_b *) packet)->tournament_remain,
+		     ((struct generic_32_spacket_b *) packet)->tournament_remain_units,
+		     ((struct generic_32_spacket_b *) packet)->starbase_remain,
+		     ((struct generic_32_spacket_b *) packet)->team_remain );      
+		      
+	    else
+	      LineToConsole("  version=unknown," );
+	  }
 	  break;
 	}
        case SP_FLAGS_ALL    :

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- data.c	12 Jul 2008 03:49:45 -0000	1.112
+++ data.c	12 Jul 2008 12:09:37 -0000	1.113
@@ -928,4 +928,5 @@
 int fullBitmapRotation = 1;     /* draw old bitmap sets to all angles */
 int hideConsole = 0;            /* show console window or not */
 
+int generic_32_version = 0;     /* what version of generic_32 does server send us */
 struct context *context;