Date:	Wednesday June 19, 2002 @ 1:50
Author:	cameron

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

Modified Files:
	ntscmds.c redraw.c 
Log Message:
add midflight wobble suppression

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

Index: Vanilla/ntserv/ntscmds.c
diff -u Vanilla/ntserv/ntscmds.c:1.21 Vanilla/ntserv/ntscmds.c:1.22
--- Vanilla/ntserv/ntscmds.c:1.21	Tue May 21 01:17:28 2002
+++ Vanilla/ntserv/ntscmds.c	Wed Jun 19 01:50:57 2002
@@ -1,4 +1,4 @@
-/* $Id: ntscmds.c,v 1.21 2002/05/21 06:17:28 cameron Exp $
+/* $Id: ntscmds.c,v 1.22 2002/06/19 06:50:57 cameron Exp $
  */
 
 /*
@@ -61,6 +61,7 @@
 void do_time_msg(char *comm, struct message *mess);
 void do_sbtime_msg(char *comm, struct message *mess);
 void do_queue_msg(char *comm, struct message *mess);
+void do_nowobble(char *comm, struct message *mess);
 
 #ifdef GENO_COUNT
 void do_genos_query(char *comm, struct message *mess, int who);
@@ -142,6 +143,10 @@
 		"Show how many people are on the queue.",
 		do_queue_msg },			/* QUEUE */
     { "(type QUEUE HOSTS to see the addresses of those on queue)", C_DESC },
+    { "NOWOBBLE",
+		0,
+		"Test new wobble on planet lock fix.",
+		do_nowobble },			/* NOWOBBLE */
     { "TIME",
 		C_PR_INPICKUP,
 		"Show time left on surrender timer.",
@@ -657,6 +662,22 @@
 		     queues[i].q_name);
 	}
     }
+}
+
+/* test wobble lock code */
+int nowobble;
+void do_nowobble(char *comm, struct message *mess)
+{
+    int who;
+    char *addr;
+
+    who = mess->m_from;
+    addr = addr_mess(who,MINDIV);
+
+    nowobble = atoi(comm+strlen("nowobble "));
+
+    pmessage(who, MINDIV, addr, "No wobble fix is now %s [%d] {%s}", 
+	     nowobble ? "on (new test mode)" : "off (classic mode)", nowobble, comm );
 }
 
 #ifdef TRIPLE_PLANET_MAYHEM
Index: Vanilla/ntserv/redraw.c
diff -u Vanilla/ntserv/redraw.c:1.12 Vanilla/ntserv/redraw.c:1.13
--- Vanilla/ntserv/redraw.c:1.12	Tue Feb  5 16:52:58 2002
+++ Vanilla/ntserv/redraw.c	Wed Jun 19 01:50:57 2002
@@ -617,10 +617,32 @@
 	    orbit();
 	}
 	else {
+	    int ax, ay, ad, missing;
+	    extern int nowobble;
+
+	    /* calculate course to planet from current coordinates */
 	    course = newcourse(pln->pl_x, pln->pl_y);
-            /* jac: avoid superfluous midflight wobble */
-            if ( (ABS(course-me->p_desdir) > 2) || (dist < ENTORBDIST*10) )
-	    set_course(course);
+
+            /* avoid superfluous midflight wobble */
+	    if (nowobble) {
+	      /* test case; at 6 o'clock on earth, lock on altair, warp 8 */
+	      /* calculate arrival point at current course */
+	      ax = (double) (me->p_x + Cos[me->p_desdir] * dist);
+	      ay = (double) (me->p_y + Sin[me->p_desdir] * dist);
+	      ad = hypot((double) (ax - pln->pl_x),
+			 (double) (ay - pln->pl_y));
+	      
+	      /* change to the corrected course if the expected error
+		 exceeds the remaining distance divided by the nowobble
+		 factor (25 works well) */
+	      missing = (ad > dist / nowobble);
+	      if (missing)
+		set_course(course);
+	    } else {
+	      /* classical behaviour */
+	      if ( (ABS(course-me->p_desdir) > 2) || (dist < ENTORBDIST*10) )
+		set_course(course);
+	    }
 	}
     }
 }