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

Modified Files:
	dashboard.c dashboard3.c data.c feature.c local.c map.c 
	socket.c 
Log Message:
Fixed phaser length bug with paradise servers.  Paradise servers use different protocol for transmitting phaser damage to client.
Added support for paradise feature packets for terrain and ship army cap.
Cleaned up todo list.

Index: dashboard.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/dashboard.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dashboard.c	19 Apr 2008 16:22:58 -0000	1.27
+++ dashboard.c	19 Apr 2008 20:03:00 -0000	1.28
@@ -798,14 +798,27 @@
         old_dam = me->p_damage;
     }
 
-    if (me->p_ship.s_type == ASSAULT)
-        cur_max = (((kills * 3) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 3));
-    else if (me->p_ship.s_type == STARBASE)
-        cur_max = me->p_ship.s_maxarmies;
+    if (!paradise && !F_armies_shipcap)
+    {
+        if (me->p_ship.s_type == ASSAULT)
+            cur_max = (((kills * 3) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 3));
+        else if (me->p_ship.s_type == STARBASE)
+            cur_max = me->p_ship.s_maxarmies;
+        else
+            cur_max = (((kills * 2) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 2));
+    }
     else
-        cur_max = (((kills * 2) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 2));
+    {
+        if (me->p_ship.s_armies & 0x80)
+            cur_max = (int) (kills * (me->p_ship.s_armies & 0x7f) / 10);
+        else
+            cur_max = me->p_ship.s_maxarmies;
+
+        if(cur_max > me->p_ship.s_maxarmies)
+            cur_max = me->p_ship.s_maxarmies;
+    }
 
     if (fr || me->p_armies != old_arm || cur_max != old_cur_arm)
     {
@@ -969,14 +982,27 @@
         old_dam = me->p_damage;
     }
 
-    if (me->p_ship.s_type == ASSAULT)
-        cur_max = (((kills * 3) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 3));
-    else if (me->p_ship.s_type == STARBASE)
-        cur_max = me->p_ship.s_maxarmies;
+    if (!paradise && !F_armies_shipcap)
+    {
+        if (me->p_ship.s_type == ASSAULT)
+            cur_max = (((kills * 3) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 3));
+        else if (me->p_ship.s_type == STARBASE)
+            cur_max = me->p_ship.s_maxarmies;
+        else
+            cur_max = (((kills * 2) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 2));
+    }
     else
-        cur_max = (((kills * 2) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 2));
+    {
+        if (me->p_ship.s_armies & 0x80)
+            cur_max = (int) (kills * (me->p_ship.s_armies & 0x7f) / 10);
+        else
+            cur_max = me->p_ship.s_maxarmies;
+
+        if(cur_max > me->p_ship.s_maxarmies)
+            cur_max = me->p_ship.s_maxarmies;
+    }
 
     if (fr || me->p_armies != old_arm || cur_max != old_cur_arm)
     {

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- local.c	16 Apr 2008 00:08:17 -0000	1.111
+++ local.c	19 Apr 2008 20:03:03 -0000	1.112
@@ -1774,29 +1774,18 @@
                     /* Here I will have to compute end coordinate */
                     /* Server will sometimes send us this information though,
                        so check if we have it first */
-                    if (!paradise && php->ph_x > 0 && php->ph_y > 0 && php->ph_x < GWIDTH && php->ph_y < GWIDTH)
+                    if (php->ph_x > 0 && php->ph_y > 0 && php->ph_x < GWIDTH && php->ph_y < GWIDTH)
                     {
                         tx = (php->ph_x - me->p_x) / scaleFactor + TWINSIDE / 2;
                         ty = (php->ph_y - me->p_y) / scaleFactor + TWINSIDE / 2;
                     }
                     else
                     {
-                        /* Paradise servers changed the ship cap protocol for
-                           phaser damage :( */
-                        if (paradise)
-                        {
-                            tx = (int) (j->p_ship.s_phaserdamage * Cos[php->ph_dir]);
-
-                            ty = (int) (j->p_ship.s_phaserdamage * Sin[php->ph_dir]);
-                        }
-                        else
-                        {
-                            tx = (int) (PHASEDIST * j->p_ship.s_phaserdamage / 100 *
-                                        Cos[php->ph_dir]);
+                        tx = (int) (PHASEDIST * j->p_ship.s_phaserdamage / 100 *
+                                    Cos[php->ph_dir]);
 
-                            ty = (int) (PHASEDIST * j->p_ship.s_phaserdamage / 100 *
-                                        Sin[php->ph_dir]);
-                        }
+                        ty = (int) (PHASEDIST * j->p_ship.s_phaserdamage / 100 *
+                                    Sin[php->ph_dir]);
 
                         tx = (j->p_x + tx - me->p_x) / scaleFactor + TWINSIDE / 2;
                         ty = (j->p_y + ty - me->p_y) / scaleFactor + TWINSIDE / 2;

Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- socket.c	19 Apr 2008 16:23:00 -0000	1.44
+++ socket.c	19 Apr 2008 20:03:05 -0000	1.45
@@ -2719,8 +2719,8 @@
 	    temp->ship->s_type = ntohs(packet->s_type);
 	    temp->ship->s_torpspeed = ntohs(packet->s_torpspeed);
 	    temp->ship->s_phaserdamage = ntohs(packet->s_phaserrange);
-	    if (paradise)	/* paradise compatibility */
-		temp->ship->s_phaserdamage *= PHASEDIST / 100;
+	    if (paradise)	/* paradise changed the protocol for this field :( */
+		temp->ship->s_phaserdamage = (temp->ship->s_phaserdamage * 100) / PHASEDIST;
 	    temp->ship->s_maxspeed = ntohl(packet->s_maxspeed);
 	    temp->ship->s_width = ntohs (packet->s_width);
 	    temp->ship->s_height = ntohs (packet->s_height);
@@ -2730,8 +2730,8 @@
 	    temp->ship->s_maxwpntemp = ntohl(packet->s_maxwpntemp);
 	    temp->ship->s_maxegntemp = ntohl(packet->s_maxegntemp);
 	    temp->ship->s_maxarmies = ntohs(packet->s_maxarmies);
-	    //if(F_armies_shipcap == 1)
-  	    //  temp->ship->s_armies = packet->s_armies;
+	    if (F_armies_shipcap == 1)
+		temp->ship->s_armies = packet->s_armies;
 	    temp->ship->s_letter = packet->s_letter;
 	    temp->ship->s_desig[0] = packet->s_desig1;
 	    temp->ship->s_desig[1] = packet->s_desig2;
@@ -2759,8 +2759,8 @@
     temp->ship->s_type = ntohs(packet->s_type);
     temp->ship->s_torpspeed = ntohs(packet->s_torpspeed);
     temp->ship->s_phaserdamage = ntohs(packet->s_phaserrange);
-    if (paradise)	/* paradise compatibility */
-         temp->ship->s_phaserdamage *= PHASEDIST / 100;
+    if (paradise)	/* paradise changed the protocol for this field :( */
+         temp->ship->s_phaserdamage = (temp->ship->s_phaserdamage * 100) / PHASEDIST;
     temp->ship->s_maxspeed = ntohl(packet->s_maxspeed);
     temp->ship->s_width = ntohs (packet->s_width);
     temp->ship->s_height = ntohs (packet->s_height);

Index: dashboard3.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/dashboard3.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dashboard3.c	16 Apr 2008 00:08:07 -0000	1.12
+++ dashboard3.c	19 Apr 2008 20:03:00 -0000	1.13
@@ -531,17 +531,29 @@
             }
         }
     }
-    
-    if (me->p_ship.s_type == ASSAULT)
-        cur_arm = (((kills * 3) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 3));
-    else if (me->p_ship.s_type == STARBASE)
-        cur_arm = me->p_ship.s_maxarmies;
+
+    if (!paradise && !F_armies_shipcap)
+    {
+        if (me->p_ship.s_type == ASSAULT)
+            cur_arm = (((kills * 3) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 3));
+        else if (me->p_ship.s_type == STARBASE)
+            cur_arm = me->p_ship.s_maxarmies;
+        else
+            cur_arm = (((kills * 2) > me->p_ship.s_maxarmies) ?
+                       me->p_ship.s_maxarmies : (int) (kills * 2));
+    }
     else
-        cur_arm = (((kills * 2) > me->p_ship.s_maxarmies) ?
-                   me->p_ship.s_maxarmies : (int) (kills * 2));
-    
-        
+    {
+        if (me->p_ship.s_armies & 0x80)
+            cur_arm = (int) (kills * (me->p_ship.s_armies & 0x7f) / 10);
+        else
+            cur_arm = me->p_ship.s_maxarmies;
+
+        if(cur_arm > me->p_ship.s_maxarmies)
+            cur_arm = me->p_ship.s_maxarmies;
+    }
+
     if (fr || (old_arm != me->p_armies) || (old_cur_arm != cur_arm))
     {
         W_ClearArea (tstatw, W_Textwidth/3 + 5 * (BAR_LENGTH + 5), 2,

Index: data.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- data.c	19 Apr 2008 16:22:58 -0000	1.109
+++ data.c	19 Apr 2008 20:03:00 -0000	1.110
@@ -772,6 +772,8 @@
 int F_show_visibility_range = 0;
 int F_sp_flags_all = 0;
 int F_why_dead_2 = 0;
+int F_terrain = 0;		/* paradise */
+int F_armies_shipcap = 0;	/* paradise */
 
 #ifdef RECORDGAME
 int F_many_self = 0;

Index: feature.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/feature.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- feature.c	16 Apr 2008 00:08:11 -0000	1.21
+++ feature.c	19 Apr 2008 20:03:01 -0000	1.22
@@ -101,6 +101,10 @@
     {"SHOW_VISIBILITY_RANGE", &F_show_visibility_range, 'S', 1, 0, 0},
     {"SP_FLAGS_ALL", &F_sp_flags_all, 'S', 1, 0, 0},
     {"WHY_DEAD_2", &F_why_dead_2, 'S', 1, 0, 0},
+    /* paradise terrain features */
+    {"TERRAIN", &F_terrain, 'S', 1, 0, 0},
+    /* armies in paradise ship_cap_spacket */
+    {"ARMIES_IN_SHIPCAP", &F_armies_shipcap, 'S', 1, 0, 0},
     {0, 0, 0, 0, 0, 0}
 };
 

Index: map.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- map.c	16 Apr 2008 00:08:17 -0000	1.64
+++ map.c	19 Apr 2008 20:03:04 -0000	1.65
@@ -1395,29 +1395,17 @@
                         /* Here I will have to compute end coordinate */
                         /* Server will sometimes send us this information though,
                            so check if we have it first */
-                        if (!paradise && ph->ph_x > 0 && ph->ph_y > 0 && ph->ph_x < GWIDTH && ph->ph_y < GWIDTH)
+                        if (ph->ph_x > 0 && ph->ph_y > 0 && ph->ph_x < GWIDTH && ph->ph_y < GWIDTH)
                         {
                             tx = ph->ph_x * GWINSIDE / GWIDTH;
                             ty = ph->ph_y * GWINSIDE / GWIDTH;
                         }
                         else
                         {
-                            if (paradise)
-                            {
-                            /* Paradise servers changed the ship cap protocol for
-                               phaser damage :( */
-                            tx = (int) (j->p_x + j->p_ship.s_phaserdamage
-                                * Cos[ph->ph_dir]) * GWINSIDE / GWIDTH;
-                            ty = (int) (j->p_y + j->p_ship.s_phaserdamage
-                                * Sin[ph->ph_dir]) * GWINSIDE / GWIDTH;
-                            }
-                            else
-                            {
                             tx = (int) (j->p_x + PHASEDIST * j->p_ship.s_phaserdamage / 100
                                 * Cos[ph->ph_dir]) * GWINSIDE / GWIDTH;
                             ty = (int) (j->p_y + PHASEDIST * j->p_ship.s_phaserdamage / 100
                                 * Sin[ph->ph_dir]) * GWINSIDE / GWIDTH;
-                            }
                         }
                         break;
                     case PHHIT2: