Date:	Thursday July 6, 2000 @ 9:53
Author:	karthik

Update of /home/netrek/cvsroot/Vanilla/robots
In directory swashbuckler.fortress.real-time.com:/var/tmp/cvs-serv11012

Modified Files:
	newbie.c newbiedefs.h 
Log Message:
Newbie server changes to properly limit humans to 8 players by means of a       separate queue, as well as to stop reporting bots to the metaserver. (When      the human queue is full, the game will still be reported as Wait Queue, but     when it is not full, only the human count will be reported.)                    


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

Index: Vanilla/robots/newbie.c
diff -u Vanilla/robots/newbie.c:1.2 Vanilla/robots/newbie.c:1.3
--- Vanilla/robots/newbie.c:1.2	Sun May 28 06:06:16 2000
+++ Vanilla/robots/newbie.c	Thu Jul  6 09:53:41 2000
@@ -72,6 +72,7 @@
 static void start_a_robot(char *team);
 static void stop_a_robot(void);
 static int is_robots_only(void);
+static int num_humans(void);
 static void exitRobot(void);
 static char * namearg(void);
 static int num_players(int *next_team);
@@ -120,9 +121,12 @@
     if (!debug)
         SIGNAL(SIGINT, cleanup);
 
-    class = ATT;
+    class = STARBASE;
     target = -1;                /* no target 7/27/91 TC */
-    if ( (pno = pickslot(QU_ROBOT)) < 0) exit(0);
+    if ( (pno = pickslot(QU_NEWBIE_DMN)) < 0) {
+       printf("exiting! %d\n", pno);
+       exit(0);
+    }
     me = &players[pno];
     myship = &me->p_ship;
     mystats = &me->p_stats;
@@ -212,9 +216,13 @@
         int next_team;
         int np = num_players(&next_team);
 
-        if (queues[QU_PICKUP].count > 0 || np > MIN_NUM_PLAYERS)
-            stop_a_robot();
-        else if (np < MIN_NUM_PLAYERS ) {
+         if (!(ticks % ROBOEXITWAIT))
+             /* Stop multiple bots if multiple people have joined since the
+                last ROBOEXITWAIT */
+             while ((QUPLAY(QU_NEWBIE_PLR) + QUPLAY(QU_NEWBIE_BOT)) >= queues[QU_PICKUP].max_slots)
+                 stop_a_robot();
+        else if ((QUPLAY(QU_NEWBIE_PLR) + QUPLAY(QU_NEWBIE_BOT)) < (queues[QU_PICKUP].max_slots - 1))
+        {
             if (next_team == FED)
                 start_a_robot("-Tf");
             else
@@ -241,31 +249,36 @@
 
 static int is_robots_only(void)
 {
-   register        i;
-   register struct player *j;
+   return !num_humans();
+}
 
+static int num_humans(void) {
+   int i;
+   struct player *j;
+   int count = 0;
+
    for (i = 0, j = players; i < MAXPLAYER; i++, j++) {
       if (j->p_status == PFREE)
 	 continue;
       if (j->p_flags & PFROBOT)
 	 continue;
+      if (j->p_status == POBSERV)
+         continue;
 
       if (!rprog(j->p_login, j->p_monitor))
           /* Found a human. */
-	 return 0;
+	 count++;
    }
 
-   /* Didn't find any humans. */
-   return 1;
+   return count;
 }
 
-
 static void stop_a_robot(void)
 {
     int i;
     struct player *j;
 
-    /* Simplistic: nuke the first robot we see. */
+    /* Nuke robot from the team with the fewest humans. */
     for (i = 0, j = players; i < MAXPLAYER; i++, j++) {
         if (j->p_status == PFREE)
             continue;
Index: Vanilla/robots/newbiedefs.h
diff -u Vanilla/robots/newbiedefs.h:1.1 Vanilla/robots/newbiedefs.h:1.2
--- Vanilla/robots/newbiedefs.h:1.1	Tue May 23 20:13:11 2000
+++ Vanilla/robots/newbiedefs.h	Thu Jul  6 09:53:41 2000
@@ -33,15 +33,20 @@
 
 /* Newbie server specific additions */
 
-#define MIN_NUM_PLAYERS	15 /* How many players to maintain. */
+#define MIN_NUM_PLAYERS	16 /* How many players to maintain. */
+#define MAX_HUMANS 8 /* Max number of humans to let in. */
 
 #define PORT 2592
 
 #define HOWOFTEN 1                       /*Robot moves every HOWOFTEN cycles*/
 #define PERSEC (1000000/UPDATE/HOWOFTEN) /* # of robo calls per second*/
 
-#define ROBOCHECK (10*PERSEC)		/* start or stop a robot */
+#define ROBOCHECK (1*PERSEC)		/* start or stop a robot */
+#define ROBOEXITWAIT (5*ROBOCHECK)  /* wait between exiting bots so that
+                                       multiple bots don't exit */
 #define SENDINFO  (120*PERSEC)		/* send info to all */
+
+#define QUPLAY(A) (queues[A].max_slots - queues[A].free_slots)
 
 #endif /* _h_newbiedefs */