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

Modified Files:
	local.c main.c mswindow.c newwin.c parsemeta.c 
Log Message:
- *.tamu.edu removed from metaserver listing, and direct connect via -h servername
  also removed.  This is due to the policy of blocking all players with the default
  login that comes with the client.
- added new scaling/rotation function that allows us to use higher resolution bitmaps.
  The new bitmap set (made by Defcom) are stored in 80x80 pixel blocks (rather than 20x20
  for all other bitmap sets).  In addition, only 1 bitmap per ship is needed rather than
  32 for each ship position - the rotation is done on the fly by Windows.  To take 
  advantage of the high res bitmap set, Windows 2000 or later is required.  So far
 2 bitmap sets have been completed.

Index: mswindow.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mswindow.c	2 May 2006 00:55:52 -0000	1.12
+++ mswindow.c	6 May 2006 05:40:00 -0000	1.13
@@ -27,6 +27,7 @@
 #include <limits.h>
 #include <string.h>
 #include <richedit.h>
+#include <math.h>
 
 #include "copyright2.h"
 #include "config.h"
@@ -3560,6 +3561,7 @@
     return NULL;
 }
 
+
 // Simplified version of StoreBitmap
 // Loads bitmap from resource file
 // This one is a bit more of a hog, no more giant bitmaps
@@ -3621,6 +3623,7 @@
     return NULL;
 }
 
+
 // Simplified version of StoreBitmap
 // Loads bitmap from .BMP file
 W_Icon
@@ -3771,61 +3774,104 @@
     ReleaseDC (bitmap->hwnd, hdc);
 }
 
-// Modified WriteBitmap for scaling images - BB, 5/1/2006
+
+// Modified WriteBitmap for scaling and rotating images - BB, 5/1/2006
 void
 W_WriteScaleBitmap (int x,
-               int y,
-               float SCALEX,
-               float SCALEY,
-               W_Icon icon,
-               W_Color color)
+                    int y,
+                    float SCALEX,
+                    float SCALEY,
+                    unsigned char p_dir,
+                    W_Icon icon,
+                    W_Color color)
 {
     register struct Icon *bitmap = (struct Icon *) icon;
-    register int border, width, height;
+    register int borderx, bordery, width, height;
     register int srcx, srcy;
     HDC hdc;
+    HBITMAP newbmp;
+    XFORM xForm;
+    double radians;
+    float cosine, sine, Point1x, Point1y, Point2x, Point2y, Point3x, Point3y;
+    float xscale, yscale;
+    float eDx, eDy;
 
     //Fast (I hope) rectangle intersection, don't overwrite our borders
     srcx = bitmap->x;
     srcy = bitmap->y;
-    border = bitmap->ClipRectAddr->top;
-    x += border;
-    y += border;
-    
-    if (x < border)
-    {
-        width = bitmap->width - (border - x);
-        srcx += border - x;
-        x = border;
-    }
-    else if ((width = bitmap->ClipRectAddr->right - x) > bitmap->width)
-        width = bitmap->width;
-    if (y < border)
-    {
-        height = bitmap->height - (border - y);
-        srcy += (border - y);
-        y = border;
-    }
-    else if ((height = bitmap->ClipRectAddr->bottom - y) > bitmap->height)
-        height = bitmap->height;
+    borderx = bitmap->ClipRectAddr->left;
+    x += borderx;
+    bordery = bitmap->ClipRectAddr->top;
+    y += bordery;
 
+    width = bitmap->width;
+    height = bitmap->height;
+    
     hdc = GetDC (bitmap->hwnd);
+    newbmp = CreateCompatibleBitmap ( hdc, width, height );
+
     if (NetrekPalette)
     {
         SelectPalette (hdc, NetrekPalette, FALSE);
         RealizePalette (hdc);
     }
     SelectObject (GlobalMemDC, bitmap->bm);
-
+    SelectObject (GlobalMemDC2, newbmp);
+    
+    // Copy selected section of main bitmap into newbmp before rotation
+    BitBlt (GlobalMemDC2, 0, 0, width, height, GlobalMemDC, srcx, srcy, SRCPAINT);
+    
     //Set the color of the bitmap
     //(oddly enough, 1-bit = bk color, 0-bit = text (fg) color)
     SetBkColor (hdc, colortable[color].rgb);
     SetTextColor (hdc, colortable[BLACK].rgb);
-    SetStretchBltMode(hdc, HALFTONE);  // Best quality
-    StretchBlt (hdc, x, y,          //Copy the bitmap
-            (int)(height/SCALEX), (int)(width/SCALEY), GlobalMemDC, srcx, srcy, width, height, SRCPAINT);  // <-- using OR mode
+    
+    //Convert p_dir to radians 
+    radians=(2*3.14159*p_dir*360/255)/360;
+    cosine=(float)cos(radians);
+    sine=(float)sin(radians);
+    
+    // Scale used to find bitmap center
+    xscale = (float)(width/SCALEX/2);
+    yscale = (float)(height/SCALEY/2);
+    
+    // Compute dimensions of the resulting bitmap
+    // First get the coordinates of the 3 corners other than origin
+    Point1x=(height*sine);
+    Point1y=(height*cosine);
+    Point2x=(width*cosine+height*sine);
+    Point2y=(height*cosine-width*sine);
+    Point3x=(width*cosine);
+    Point3y=-(width*sine);
 
+    eDx = x + xscale - cosine*(xscale) + sine*(yscale);
+    eDy = y + yscale - cosine*(yscale) - sine*(xscale);
+    SetGraphicsMode(hdc,GM_ADVANCED);
+
+    xForm.eM11=cosine/SCALEX;
+    xForm.eM12=sine/SCALEX;
+    xForm.eM21=-sine/SCALEY;
+    xForm.eM22=cosine/SCALEY;
+    xForm.eDx = eDx;
+    xForm.eDy = eDy;
+ 
+    SetWorldTransform(hdc,&xForm);
+    BitBlt(hdc, 0, 0, width, height, GlobalMemDC2, 0, 0, SRCPAINT);
+          
     ReleaseDC (bitmap->hwnd, hdc);
+    DeleteObject (newbmp);
+
+/*  Alternative method using PlgBlt, left in for reference purposes
+    
+    P[0].x = (long)(x + xscale - xscale*cos(angle) + yscale*sin(angle));
+    P[0].y = (long)(y + yscale - yscale*cos(angle) - xscale*sin(angle));
+    P[1].x = (long)(x + xscale - xscale*cos(angle+PI/2) + yscale*sin(angle+PI/2));
+    P[1].y = (long)(y + yscale - yscale*cos(angle+PI/2) - xscale*sin(angle+PI/2));
+    P[2].x = (long)(x + xscale - xscale*cos(angle-PI/2) + yscale*sin(angle-PI/2));
+    P[2].y = (long)(y + yscale - yscale*cos(angle-PI/2) - xscale*sin(angle-PI/2));
+
+    PlgBlt (hdc, P, GlobalMemDC, srcx, srcy, width, height, 0, 0, 0 );
+*/
 }
 
 void

Index: newwin.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- newwin.c	2 May 2006 00:55:52 -0000	1.17
+++ newwin.c	6 May 2006 05:40:00 -0000	1.18
@@ -424,9 +424,9 @@
 /***  loadweaponsHR() - high quality ship bitmaps, 80x80
 /******************************************************************************/
 void loadbitmapsHR()
-{    
+{
     int j;
-    
+
     if ( access("bitmaps/shiplib/fedshipHR.bmp", R_OK) == 0
      && access("bitmaps/shiplib/indshipHR.bmp", R_OK) == 0
      && access("bitmaps/shiplib/klishipHR.bmp", R_OK) == 0
@@ -1094,7 +1094,7 @@
     genopic =
         W_StoreBitmap3 ("bitmaps/misclib/genocide.bmp", WINSIDE,
                         WINSIDE, BMP_GENO, w, LR_DEFAULTCOLOR);
-
+                        
 }
 
 

Index: local.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- local.c	2 May 2006 00:55:52 -0000	1.17
+++ local.c	6 May 2006 05:40:00 -0000	1.18
@@ -806,8 +806,7 @@
             {
                 W_WriteBitmap (dx - (j->p_ship.s_width / 2),
                            dy - (j->p_ship.s_height / 2),
-                           ship_bits[j->p_ship.
-                                     s_type][rosette (j->p_dir)],
+                           ship_bits[j->p_ship.s_type][rosette (j->p_dir)],
                            playerColor (j));
             }
             else
@@ -816,8 +815,9 @@
                            dy - (j->p_ship.s_height / 2),
                            (float)(BMP_SHIP_WIDTH_HR/j->p_ship.s_width),
                            (float)(BMP_SHIP_HEIGHT_HR/j->p_ship.s_height),
+                           j->p_dir,
                            ship_bitsHR[j->p_ship.s_type],
-                           playerColor (j));
+                           playerColor (j));                
             }
                               
             if (j->p_cloakphase > 0)

Index: main.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- main.c	21 Apr 2006 12:00:07 -0000	1.3
+++ main.c	6 May 2006 05:40:00 -0000	1.4
@@ -256,6 +256,8 @@
                 if (i < argc)
                 {
                     servertmp = argv[i + 1];
+                    if (strstr(servertmp,".tamu.edu") != NULL)
+                        exit (0);
                     usemeta = 0;
                     i++;
                 }
@@ -366,9 +368,9 @@
 
     if (!usemeta && !servertmp)  /* no meta type was selected, pick metaserver */
         usemeta = 1;
-
-	if (hideConsole)
-		FreeConsole ();
+        
+    if (hideConsole)
+	FreeConsole ();
 
     if (usage || err)
     {

Index: parsemeta.c
===================================================================
RCS file: /cvsroot/netrek/client/netrekxp/src/parsemeta.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- parsemeta.c	21 Apr 2006 12:00:07 -0000	1.4
+++ parsemeta.c	6 May 2006 05:40:00 -0000	1.5
@@ -299,8 +299,8 @@
 			slist->pkt_rtt[i] = -1;
 #endif
 
-        /* Don't list Paradise Servers  */
-        if (slist->typeflag != 'P')
+        /* Don't list Paradise Servers or *.tamu.edu */
+        if (slist->typeflag != 'P' && strstr(slist->address,".tamu.edu") == NULL)
         {
 
 #ifdef DEBUG
@@ -572,27 +572,31 @@
 metarefresh (int i)
 /* Refresh line i in the list */
 {
-	struct servers *slist;
-	W_Color color = textColor;
+    struct servers *slist;
+    W_Color color = textColor;
     char buf[LINE + 1];
 
 #ifdef METAPING
-	DWORD lag = 0;
-	int idx, replies = 0;
+    DWORD lag = 0;
+    int idx, replies = 0;
 #endif
 
-	slist = serverlist + i;
-
+    slist = serverlist + i;
+    
+    // Don't list *.tamu.edu
+    if (strstr(slist->address,".tamu.edu") != NULL)
+        return;
+        
 #ifdef METAPING
-	if (metaPing)
-		sprintf (buf, "%-34s %14s ",
-			slist->address, statusStrings[slist->status]);
-	else
+    if (metaPing)
+	sprintf (buf, "%-34s %14s ",
+		slist->address, statusStrings[slist->status]);
+    else
 #endif
 	sprintf (buf, "%-40s %14s ",
 		slist->address, statusStrings[slist->status]);
 
-	if (slist->status == statusConnecting) color = W_Yellow;
+    if (slist->status == statusConnecting) color = W_Yellow;
 
     if (slist->status <= statusNull)
     {
@@ -634,44 +638,44 @@
             break;
         }
     }
-	else
-	{
-		strcat (buf, "               ");
-	}
+    else
+    {
+	strcat (buf, "               ");
+    }
 
 #ifdef METAPING
-	if (metaPing)
+    if (metaPing)
+    {
+	/* Print out the lag statistics */
+	for (idx = 0; idx < RTT_AVG_BUFLEN; ++idx)
 	{
-		/* Print out the lag statistics */
-		for (idx = 0; idx < RTT_AVG_BUFLEN; ++idx)
+		if (serverlist[i].pkt_rtt[idx] != -3 &&
+		    serverlist[i].pkt_rtt[idx] != -2 &&
+		    serverlist[i].pkt_rtt[idx] != -1)      // dont count these non-values
 		{
-			if (serverlist[i].pkt_rtt[idx] != -3 &&
-			    serverlist[i].pkt_rtt[idx] != -2 &&
-			    serverlist[i].pkt_rtt[idx] != -1)      // dont count these non-values
-			{
-				//printf ("i=%d  idx=%d  replies=%d  rtt=%ld  lag=%ld\n", i , idx, replies, serverlist[i].pkt_rtt[idx], lag);
-			    lag += serverlist[i].pkt_rtt[idx];
-			    replies++;
-			}
+			//printf ("i=%d  idx=%d  replies=%d  rtt=%ld  lag=%ld\n", i , idx, replies, serverlist[i].pkt_rtt[idx], lag);
+		    lag += serverlist[i].pkt_rtt[idx];
+		    replies++;
 		}
+	}
     
-		//printf("i=%d  replies=%ld  idx=%ld   rtt=%ld  %s\n", i, replies,
-		//	   ((serverlist[i].cur_idx + RTT_AVG_BUFLEN - 1) % RTT_AVG_BUFLEN),
-		//	   serverlist[i].pkt_rtt[(serverlist[i].cur_idx + RTT_AVG_BUFLEN - 1) % RTT_AVG_BUFLEN],
-		//	   serverlist[i].address);
+	//printf("i=%d  replies=%ld  idx=%ld   rtt=%ld  %s\n", i, replies,
+	//	   ((serverlist[i].cur_idx + RTT_AVG_BUFLEN - 1) % RTT_AVG_BUFLEN),
+	//	   serverlist[i].pkt_rtt[(serverlist[i].cur_idx + RTT_AVG_BUFLEN - 1) % RTT_AVG_BUFLEN],
+	//	   serverlist[i].address);
 
-		if (replies > 0)
-		{
-			lag = lag / replies;
-			if (lag < 1000) sprintf (buf + strlen (buf), " %3ldms", lag);
-			else strcat(buf, " >1sec");
-		}
-		else if (replies == 0 && serverlist[i].pkt_rtt[0] == -2)
-			strcat(buf, " Unknw"); // Unknown host
-		else if (replies == 0 && serverlist[i].pkt_rtt[0] == -3)
-			strcat(buf, " TmOut"); // TimeOut
-		else strcat(buf, "      ");
+	if (replies > 0)
+	{
+		lag = lag / replies;
+		if (lag < 1000) sprintf (buf + strlen (buf), " %3ldms", lag);
+		else strcat(buf, " >1sec");
 	}
+	else if (replies == 0 && serverlist[i].pkt_rtt[0] == -2)
+		strcat(buf, " Unknw"); // Unknown host
+	else if (replies == 0 && serverlist[i].pkt_rtt[0] == -3)
+		strcat(buf, " TmOut"); // TimeOut
+	else strcat(buf, "      ");
+    }
 #endif
 
     W_WriteText (metaWin, 0, i, color, buf, strlen (buf), 0);