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

Modified Files:
	data.c feature.c map.c socket.c 
Log Message:
Support for F_check_planets feature packet, which includes new struct
planet_cpacket which cross-checks with server to make sure all planet
info is correct.  Updated 10 times/sec for planet being orbitted, and
every 5 seconds for the other "touched" planets.  Reduces need for
small update to refresh planets, and minimizes the effect of lost
planet packets on gameplay.

Index: feature.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/feature.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- feature.c	4 Apr 2007 04:06:37 -0000	1.12
+++ feature.c	4 Apr 2007 10:34:22 -0000	1.13
@@ -79,6 +79,7 @@
     {"SP_GENERIC_32", &F_sp_generic_32, 'S', 1, 0, 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},
 
 #ifdef WARP_DEAD
     {"DEAD_WARP", &F_dead_warp, 'S', 1, 0, 0},

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- map.c	4 Apr 2007 04:06:38 -0000	1.40
+++ map.c	4 Apr 2007 10:34:22 -0000	1.41
@@ -63,6 +63,8 @@
 static int mcleararea[4][(MAXTORP + 1) * MAXPLAYER + (MAXPLASMA + 1) * MAXPLAYER];
 static int mclearx, mcleary, mclearr;	/* x,y,radius for range circle */
 static int mclearccount;
+static int planet_refresh = 0;
+static int orbit_planet_refresh = 0;
 
 /*
  *  Global Variables:
@@ -502,6 +504,27 @@
 
     for (l = planets + MAXPLANETS - 1; l >= planets; --l)
     {
+        /* Synchronize planet info (up to 10 times/second) for current orbitted planet
+           and once every 5 seconds for all other planets we have info on*/
+        if (F_check_planets)
+        {
+            if ((me->p_flags & PFORBIT)
+            && (F_sp_generic_32 ? me->pl_orbit : get_closest_planet(me->p_x, me->p_y)) == l->pl_no)
+            {
+                orbit_planet_refresh++;
+                if ((orbit_planet_refresh * 10 / server_ups) >= 1)
+                {
+                        sendPlanetsPacket(l->pl_no);
+                        orbit_planet_refresh = 0;
+                }
+            }
+            else if (l->pl_info & me->p_team)
+            {
+                if ((planet_refresh * 10 / server_ups) >= 50)
+                        sendPlanetsPacket(l->pl_no);
+            }
+        }
+
         if (!(l->pl_flags & PLREDRAW))
             continue;
 
@@ -939,6 +962,15 @@
 
     DrawPlanets ();
 
+    /* Increment counter for requesting planet sync (F_check_planets) */
+    if (F_check_planets)
+    {
+        if ((planet_refresh * 10 / server_ups) >= 50)
+            planet_refresh = 0;
+        else
+            planet_refresh++;
+    }
+
 #ifdef DEBUG_SHOW_REGIONS	/* Debugging code */
    showRegions();
 #endif

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- socket.c	4 Apr 2007 04:06:38 -0000	1.26
+++ socket.c	4 Apr 2007 10:34:22 -0000	1.27
@@ -261,7 +261,7 @@
     0,                          /* 37 */
 #endif
 
-    0,                          /* 38 */
+    sizeof (struct planet_cpacket),     /* CP_PLANET */
     0,                          /* 39 */
     0,                          /* 40 */
     0,                          /* 41 */
@@ -1586,6 +1586,7 @@
         case CP_SHIELD:
         case CP_REPAIR:
         case CP_ORBIT:
+        case CP_PLANET:
         case CP_PLANLOCK:
         case CP_PLAYLOCK:
         case CP_BOMB:
@@ -2110,6 +2111,23 @@
 }
 
 void
+sendPlanetsPacket (int pnum)
+{
+    struct planet_cpacket planPacket;
+    struct planet *pl;
+
+    pl = &planets[pnum];
+
+    planPacket.type = CP_PLANET;
+    planPacket.pnum = pl->pl_no;
+    planPacket.owner = pl->pl_owner;
+    planPacket.info = pl->pl_info;
+    planPacket.armies = htonl (pl->pl_armies);
+    planPacket.flags = htons ((short) (pl->pl_flags));
+    sendServerPacket ((struct player_spacket *) &planPacket);
+}
+
+void
 pickSocket (int old)
 {
     int newsocket;
@@ -3976,7 +3994,7 @@
       LineToConsole("\nC->S CP_REPAIR\t");
       if (log_packets > 1)
 	LineToConsole("  state=%d,",
-		((struct repair_cpacket *) packet)-> state );
+		((struct repair_cpacket *) packet)->state );
       break;
     case CP_ORBIT        :                    /* orbit planet/starbase */
       LineToConsole("\nC->S CP_ORBIT\t");
@@ -3984,6 +4002,12 @@
 	LineToConsole("  state=%d,",
 		((struct orbit_cpacket *) packet)->state );
       break;
+    case CP_PLANET       :                    /* planet info */
+      LineToConsole("\nC->S CP_PLANET\t");
+      if (log_packets > 1)
+	LineToConsole("  pnum=%d,",
+		((struct planet_cpacket *) packet)->pnum );
+      break;
     case CP_PLANLOCK     :                    /* lock on planet */
       LineToConsole("\nC->S CP_PLANLOCK\t");
       if (log_packets > 1)

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- data.c	4 Apr 2007 04:06:37 -0000	1.76
+++ data.c	4 Apr 2007 10:34:22 -0000	1.77
@@ -681,6 +681,7 @@
 int F_sp_generic_32 = 0;
 int F_full_direction_resolution = 0;
 int F_full_weapon_resolution = 0;
+int F_check_planets = 0;
 int F_show_army_count = 0;
 int F_show_other_speed = 0;
 int F_show_cloakers = 0;