Date:	Thursday May 3, 2001 @ 23:00
Author:	cameron

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

Modified Files:
	newbie.c newbiedefs.h 
Log Message:
add #define NB_ROBOTS 16 to limit the number of processes spawned to 16

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

Index: Vanilla/robots/newbie.c
diff -u Vanilla/robots/newbie.c:1.5 Vanilla/robots/newbie.c:1.6
--- Vanilla/robots/newbie.c:1.5	Tue Jul 11 08:49:23 2000
+++ Vanilla/robots/newbie.c	Thu May  3 23:00:11 2001
@@ -28,6 +28,7 @@
 #include "newbiedefs.h"
 
 int debug=0;
+int nb_robots=0;
 
 char *roboname = "Merlin";
 
@@ -86,7 +87,8 @@
     int stat=0;
     static int pid;
 
-    while ((pid = WAIT3(&stat, WNOHANG, 0)) > 0) ;
+    while ((pid = WAIT3(&stat, WNOHANG, 0)) > 0)
+        nb_robots--;
     HANDLE_SIG(SIGCHLD,reaper);
 }
 
@@ -225,7 +227,7 @@
              if ((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))
+        else if (((QUPLAY(QU_NEWBIE_PLR) + QUPLAY(QU_NEWBIE_BOT)) < (queues[QU_PICKUP].max_slots - 1)) && (nb_robots < NB_ROBOTS))
         {
             if (next_team == FED)
                 start_a_robot("-Tf");
@@ -403,16 +405,21 @@
 start_a_robot(char *team)
 {
     char            command[256];
+    int pid;
 
     sprintf(command, "%s %s %s %s -h %s -p %d -n '%s' -X robot! -b -O -i",
             RCMD, robot_host, OROBOT, team, hostname, PORT, namearg() );
    
-    if (fork() == 0) {
+    pid = fork();
+    if (pid == -1)
+     return;
+    if (pid == 0) {
         SIGNAL(SIGALRM, SIG_DFL);
         execl("/bin/sh", "sh", "-c", command, 0);
         perror("newbie'execl");
         _exit(1);
     }
+    nb_robots++;
 }
 
 static void start_internal(char *type)
Index: Vanilla/robots/newbiedefs.h
diff -u Vanilla/robots/newbiedefs.h:1.2 Vanilla/robots/newbiedefs.h:1.3
--- Vanilla/robots/newbiedefs.h:1.2	Thu Jul  6 09:53:41 2000
+++ Vanilla/robots/newbiedefs.h	Thu May  3 23:00:11 2001
@@ -48,5 +48,7 @@
 
 #define QUPLAY(A) (queues[A].max_slots - queues[A].free_slots)
 
+#define NB_ROBOTS 16
+
 #endif /* _h_newbiedefs */